From: <sv...@ww...> - 2006-04-03 06:58:21
|
Author: mkrose Date: 2006-04-02 23:58:13 -0700 (Sun, 02 Apr 2006) New Revision: 1872 Added: trunk/csp/cspsim/__init__.py Modified: trunk/csp/__init__.py trunk/csp/csplib/__init__.py Log: Clean up the module paths for generated modules, making them more consistent and hopefully more compatible with tools like modulefinder. Browse at: https://www.zerobar.net/viewcvs/viewcvs.cgi?view=rev&rev=1872 Modified: trunk/csp/__init__.py =================================================================== --- trunk/csp/__init__.py 2006-04-02 08:08:21 UTC (rev 1871) +++ trunk/csp/__init__.py 2006-04-03 06:58:13 UTC (rev 1872) @@ -16,20 +16,31 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - import sys import os dir = os.path.abspath(__path__[0]) -# bring compiled modules into the csp package -__path__.insert(0, os.path.join(dir, 'cspsim', '.bin')) - -def initDynamicLoading(): - """Enable lazy loading of shared library modules if available""" +def _configureModules(): if os.name == 'posix': - import dl - sys.setdlopenflags(dl.RTLD_GLOBAL|dl.RTLD_LAZY) + try: + import dl + # enable lazy loading of shared library modules if available. + sys.setdlopenflags(dl.RTLD_GLOBAL|dl.RTLD_LAZY) + except ImportError: + sys.stderr.write('import dl failed; lazy module loading not enabled.\n') + else: + # if CSPDEVPACK is defined in the environment, add the devpack bin + # directory to the execution path. this ensures that devpack libraries + # will be found before other (potentially incompatible) versions of the + # same libraries. note that windows is currently the only system with + # a devpack. + devpack = os.environ.get('CSPDEVPACK') + if devpack: + bin = os.path.join(devpack, 'usr', 'bin') + path = [bin] + if 'PATH' in os.environ: + path.append(os.environ.get('PATH')) + os.environ['PATH'] = os.pathsep.join(path) -initDynamicLoading() - +_configureModules() Modified: trunk/csp/csplib/__init__.py =================================================================== --- trunk/csp/csplib/__init__.py 2006-04-02 08:08:21 UTC (rev 1871) +++ trunk/csp/csplib/__init__.py 2006-04-03 06:58:13 UTC (rev 1872) @@ -24,8 +24,21 @@ bin = os.path.join(os.path.dirname(__file__), '.bin') sys.path.insert(0, bin) -import csplib as _csplib +try: + import csplib as _csplib +except ImportError, e: + sys.stderr.write(str(e)) + 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. +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() Added: trunk/csp/cspsim/__init__.py =================================================================== --- trunk/csp/cspsim/__init__.py 2006-04-02 08:08:21 UTC (rev 1871) +++ trunk/csp/cspsim/__init__.py 2006-04-03 06:58:13 UTC (rev 1872) @@ -0,0 +1,24 @@ +# Wrapper for csp/cspsim/.bin/cspsim.py, which is generated by +# SWIG during the build. + +import os +import sys + +bin = os.path.join(os.path.dirname(__file__), '.bin') +sys.path.insert(0, bin) + +try: + from cspsim import * +except ImportError, e: + sys.stderr.write(str(e)) + 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. +Check that all targets have been built successfully. See the +README file for build instructions. +""") + sys.exit(1) + +sys.path = sys.path[1:] + |