[pypy-dev] Translation with pypy picking up wrong libraries

David Naylor naylor.b.david at gmail.com
Wed Jun 27 20:47:28 CEST 2012


On Monday, 25 June 2012 23:33:12 Ronny Pfannschmidt wrote:
> Hi David,
> 
> i created the kill-import_from_lib_pypy branch,
> which should fix the issue - its still in testing,
> please take a look if any issue comes up

Alas, the changes you made to pypy/tool/compat.py and pypy/translator/goal/targetpypystandalone.py didn't work in my setup...
[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 235, in get_entry_point
[translation:ERROR]     from lib_pypy.ctypes_config_cache.rebuild import try_rebuild
[translation:ERROR]    File "/usr/local/lib/pypy1.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/tool/autopath.py'

I have the following changes:
# cd pypy
# mkdir lib
# mv lib-python/2.7 lib/pypy1.9
# mv lib_pypy lib/pypy1.9/lib_pypy
# patch << _EOF
--- lib/pypy1.9/lib_pypy/ctypes_config_cache/rebuild.py~        2012-06-22 11:42:55.000000000 +0200
+++ lib/pypy1.9/lib_pypy/ctypes_config_cache/rebuild.py 2012-06-22 11:43:12.000000000 +0200
@@ -6,7 +6,7 @@
 # get the correct path
 import os.path
 this_dir = os.path.dirname(__file__)
-autopath_py = os.path.join(this_dir, '../../pypy/tool/autopath.py')
+autopath_py = os.path.join(this_dir, '../../../../pypy/tool/autopath.py')
 autopath_py = os.path.abspath(autopath_py)
 execfile(autopath_py, dict(__name__='autopath', __file__=autopath_py))
 
--- pypy/module/sys/state.py.orig       2012-06-07 14:24:48.000000000 +0200
+++ pypy/module/sys/state.py    2012-06-22 14:45:23.000000000 +0200
@@ -36,14 +36,12 @@
 platform = sys.platform
 
 def getinitialpath(state, prefix):
-    from pypy.module.sys.version import CPYTHON_VERSION
-    dirname = '%d.%d' % (CPYTHON_VERSION[0],
-                         CPYTHON_VERSION[1])
-    lib_python = os.path.join(prefix, 'lib-python')
-    python_std_lib = os.path.join(lib_python, dirname)
+    from pypy.module.sys.version import PYPY_VERSION
+    libpath = os.path.join(prefix, 'lib')
+    python_std_lib = os.path.join(libpath, 'pypy%d.%d' % PYPY_VERSION[:2])
     checkdir(python_std_lib)
     
-    lib_pypy = os.path.join(prefix, 'lib_pypy')
+    lib_pypy = os.path.join(python_std_lib, 'lib_pypy')
     checkdir(lib_pypy)
 
     importlist = []
--- pypy/tool/lib_pypy.py.orig  2012-06-07 14:24:48.000000000 +0200
+++ pypy/tool/lib_pypy.py       2012-06-22 14:46:42.000000000 +0200
@@ -1,12 +1,11 @@
 import py
 import pypy
 import pypy.module
-from pypy.module.sys.version import CPYTHON_VERSION
+from pypy.module.sys.version import PYPY_VERSION
 
 LIB_ROOT = py.path.local(pypy.__path__[0]).dirpath()
-LIB_PYPY =  LIB_ROOT.join('lib_pypy')
-LIB_PYTHON = LIB_ROOT.join('lib-python', '%d.%d' % CPYTHON_VERSION[:2])
-
+LIB_PYTHON =  LIB_ROOT.join('lib', 'pypy%d.%d' % PYPY_VERSION[:2])
+LIB_PYPY = LIB_PYTHON.join('lib_pypy')
 
 def import_from_lib_pypy(modname):
     modname = LIB_PYPY.join(modname+'.py')
_EOF

and with the following patch the translate works successfully for me:
# patch << _EOF
--- 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())
_EOF

Sorry, I should have mentioned this is my earlier post...
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 196 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.python.org/pipermail/pypy-dev/attachments/20120627/7781fb08/attachment.pgp>


More information about the pypy-dev mailing list