Hi, I'm experimenting with using non-default library directories by tweeking pypy.tool.lib_pypy however I came up with the following error when translating with pypy:
[translation:ERROR] Error: [translation:ERROR] Traceback (most recent call last): [translation:ERROR] File "translate.py", line 274, in main [translation:ERROR] default_goal='compile') [translation:ERROR] File "/tmp/home/DragonSA/ports/pypy/work/pypy-pypy-341e1e3821ff/pypy/translator/driver.py", line 810, in from_targetspec [translation:ERROR] spec = target(driver, args) [translation:ERROR] File "targetpypystandalone.py", line 228, in target [translation:ERROR] return self.get_entry_point(config) [translation:ERROR] File "targetpypystandalone.py", line 236, in get_entry_point [translation:ERROR] rebuild = import_from_lib_pypy('ctypes_config_cache/rebuild') [translation:ERROR] File "/tmp/home/DragonSA/ports/pypy/work/pypy-pypy-341e1e3821ff/pypy/tool/lib_pypy.py", line 12, in import_from_lib_pypy [translation:ERROR] return modname.pyimport() [translation:ERROR] File "/tmp/home/DragonSA/ports/pypy/work/pypy-pypy-341e1e3821ff/py/_path/local.py", line 531, in pyimport [translation:ERROR] mod = __import__(modname, None, None, ['__doc__']) [translation:ERROR] File "/usr/local/pypy-1.9/lib_pypy/ctypes_config_cache/rebuild.py", line 11, in <module> [translation:ERROR] execfile(autopath_py, dict(__name__='autopath', __file__=autopath_py)) [translation:ERROR] IOError: [Errno 2] No such file or directory: '/usr/local/pypy-1.9/pypy/tool/autopath.py' This error does not happen when translating with python. Upon investigation I found that pypy has: # pypy -c 'import sys; import pypy.tool.lib_pypy; print "ctypes_config_cache" in sys.modules.keys()' True but python has: # python -c 'import sys; import pypy.tool.lib_pypy; print "ctypes_config_cache" in sys.modules.keys()' False also: # pypy -c 'import sys; import pypy.tool.lib_pypy; print sys.modules["ctypes_config_cache"]' <module 'ctypes_config_cache' from '/usr/local/pypy-1.9/lib_pypy/ctypes_config_cache/__init__.pyc'> note the above always happens regardless of pypy.tool.lib_pypy being modified or not. It appears to me that there are two bugs: 1) pypy ends up importing ctypes_config_cache when it shouldn't??? 2) py/_path/local.py doesn't ensure import from correct location And attached is a patch for fixing (2), which works around (1). Regards
--- py/_path/local.py~ 2012-06-22 12:20:36.000000000 +0200 +++ py/_path/local.py 2012-06-22 12:21:45.000000000 +0200 @@ -516,6 +516,9 @@ pkgpath = self.pypkgpath() if pkgpath is not None: if ensuresyspath: + import sys + if pkgpath.basename in sys.modules: + del sys.modules[pkgpath.basename] self._prependsyspath(pkgpath.dirpath()) pkg = __import__(pkgpath.basename, None, None, []) names = self.new(ext='').relto(pkgpath.dirpath())
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ pypy-dev mailing list pypy-dev@python.org http://mail.python.org/mailman/listinfo/pypy-dev