From: <sv...@ww...> - 2006-04-08 20:38:50
|
Author: mkrose Date: 2006-04-08 13:38:41 -0700 (Sat, 08 Apr 2006) New Revision: 1875 Modified: trunk/csp/__init__.py trunk/csp/csplib/__init__.py trunk/csp/cspsim/__init__.py Log: Revert __init__ modules to use __path__ to access .bin. This method is much cleaner and can be made to work with py2exe. Browse at: https://www.zerobar.net/viewcvs/viewcvs.cgi?view=rev&rev=1875 Modified: trunk/csp/__init__.py =================================================================== --- trunk/csp/__init__.py 2006-04-08 20:36:55 UTC (rev 1874) +++ trunk/csp/__init__.py 2006-04-08 20:38:41 UTC (rev 1875) @@ -44,3 +44,4 @@ os.environ['PATH'] = os.pathsep.join(path) _configureModules() + Modified: trunk/csp/csplib/__init__.py =================================================================== --- trunk/csp/csplib/__init__.py 2006-04-08 20:36:55 UTC (rev 1874) +++ trunk/csp/csplib/__init__.py 2006-04-08 20:38:41 UTC (rev 1875) @@ -15,14 +15,16 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - import exceptions import os.path import sys import types +# this path hack allows the csplib extension module to be loaded +# transparently from the .bin directory. extending rather than +# replacing __path__ is necessary for py2exe imports to work. bin = os.path.join(os.path.dirname(__file__), '.bin') -sys.path.insert(0, bin) +__path__.append(bin) try: import csplib as _csplib @@ -31,14 +33,13 @@ sys.stderr.write( """ Unable to import csplib.py from csp/csplib/.bin. This file and -and others needed by cspsim are generatedd during the build. +and others needed by cspsim are generated during the build. Check that all targets have been built successfully. See the README file for build instructions. """) sys.exit(1) from csplib import * -sys.path = sys.path[1:] version = _csplib.getVersion() Modified: trunk/csp/cspsim/__init__.py =================================================================== --- trunk/csp/cspsim/__init__.py 2006-04-08 20:36:55 UTC (rev 1874) +++ trunk/csp/cspsim/__init__.py 2006-04-08 20:38:41 UTC (rev 1875) @@ -4,8 +4,11 @@ import os import sys +# this path hack allows the cspsim extension module to be loaded +# transparently from the .bin directory. extending rather than +# replacing __path__ is necessary for py2exe imports to work. bin = os.path.join(os.path.dirname(__file__), '.bin') -sys.path.insert(0, bin) +__path__.append(bin) try: from cspsim import * @@ -14,11 +17,9 @@ sys.stderr.write( """ Unable to import cspsim.py from csp/cspsim/.bin. This file and -and others needed by cspsim are generatedd during the build. +and others needed by cspsim are generated during the build. Check that all targets have been built successfully. See the README file for build instructions. """) sys.exit(1) -sys.path = sys.path[1:] - |