[pypy-svn] r74976 - in pypy/branch/sys-prefix: lib/pypy1.2/lib_pypy/ctypes_config_cache pypy/interpreter/test pypy/rlib pypy/tool pypy/tool/test pypy/translator/goal pypy/translator/sandbox

antocuni at codespeak.net antocuni at codespeak.net
Mon May 31 17:02:23 CEST 2010


Author: antocuni
Date: Mon May 31 17:02:20 2010
New Revision: 74976

Modified:
   pypy/branch/sys-prefix/lib/pypy1.2/lib_pypy/ctypes_config_cache/rebuild.py
   pypy/branch/sys-prefix/pypy/interpreter/test/test_module.py
   pypy/branch/sys-prefix/pypy/rlib/rmd5.py
   pypy/branch/sys-prefix/pypy/rlib/rsha.py
   pypy/branch/sys-prefix/pypy/rlib/rzipfile.py
   pypy/branch/sys-prefix/pypy/tool/compat.py
   pypy/branch/sys-prefix/pypy/tool/lib_pypy.py
   pypy/branch/sys-prefix/pypy/tool/test/test_lib_pypy.py
   pypy/branch/sys-prefix/pypy/translator/goal/targetpypystandalone.py
   pypy/branch/sys-prefix/pypy/translator/sandbox/pypy_interact.py
   pypy/branch/sys-prefix/pypy/translator/sandbox/sandlib.py
Log:
remove most of the remaining references to pypy/lib, and make them pointing to lib_pypy



Modified: pypy/branch/sys-prefix/lib/pypy1.2/lib_pypy/ctypes_config_cache/rebuild.py
==============================================================================
--- pypy/branch/sys-prefix/lib/pypy1.2/lib_pypy/ctypes_config_cache/rebuild.py	(original)
+++ pypy/branch/sys-prefix/lib/pypy1.2/lib_pypy/ctypes_config_cache/rebuild.py	Mon May 31 17:02:20 2010
@@ -4,7 +4,10 @@
 # hack: we cannot directly import autopath, as we are outside the pypy
 # package.  However, we pretend to be inside pypy/tool and manually run it, to
 # get the correct path
-autopath_py = '../../../../pypy/tool/autopath.py'
+import os.path
+this_dir = os.path.dirname(__file__)
+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))
 
 import os, sys

Modified: pypy/branch/sys-prefix/pypy/interpreter/test/test_module.py
==============================================================================
--- pypy/branch/sys-prefix/pypy/interpreter/test/test_module.py	(original)
+++ pypy/branch/sys-prefix/pypy/interpreter/test/test_module.py	Mon May 31 17:02:20 2010
@@ -54,7 +54,7 @@
         r = repr(sys)
         assert r == "<module 'sys' (built-in)>"
         
-        import _pypy_interact # known to be in pypy/lib
+        import _pypy_interact # known to be in lib_pypy
         r = repr(_pypy_interact)
         assert (r.startswith("<module '_pypy_interact' from ") and
                 ('lib_pypy/_pypy_interact.py' in r or

Modified: pypy/branch/sys-prefix/pypy/rlib/rmd5.py
==============================================================================
--- pypy/branch/sys-prefix/pypy/rlib/rmd5.py	(original)
+++ pypy/branch/sys-prefix/pypy/rlib/rmd5.py	Mon May 31 17:02:20 2010
@@ -2,7 +2,7 @@
 """
 RPython implementation of MD5 checksums.
 
-See also the pure Python implementation in pypy/lib/md5.py, which might
+See also the pure Python implementation in lib_pypy/md5.py, which might
 or might not be faster than this one on top of CPython.
 
 This is an implementation of the MD5 hash function,

Modified: pypy/branch/sys-prefix/pypy/rlib/rsha.py
==============================================================================
--- pypy/branch/sys-prefix/pypy/rlib/rsha.py	(original)
+++ pypy/branch/sys-prefix/pypy/rlib/rsha.py	Mon May 31 17:02:20 2010
@@ -2,7 +2,7 @@
 
 """A sample implementation of SHA-1 in RPython.
 
-   See also the pure Python implementation in pypy/lib/sha.py, which might
+   See also the pure Python implementation in lib_pypy/sha.py, which might
    or might not be faster than this one on top of CPython.
 
    Framework adapted from Dinu Gherman's MD5 implementation by

Modified: pypy/branch/sys-prefix/pypy/rlib/rzipfile.py
==============================================================================
--- pypy/branch/sys-prefix/pypy/rlib/rzipfile.py	(original)
+++ pypy/branch/sys-prefix/pypy/rlib/rzipfile.py	Mon May 31 17:02:20 2010
@@ -12,7 +12,8 @@
     rzlib = None
 
 # XXX hack to get crc32 to work
-from pypy.lib.binascii import crc_32_tab
+from pypy.tool.lib_pypy import import_from_lib_pypy
+crc_32_tab = import_from_lib_pypy('binascii').crc_32_tab
 
 rcrc_32_tab = [r_uint(i) for i in crc_32_tab]
 

Modified: pypy/branch/sys-prefix/pypy/tool/compat.py
==============================================================================
--- pypy/branch/sys-prefix/pypy/tool/compat.py	(original)
+++ pypy/branch/sys-prefix/pypy/tool/compat.py	Mon May 31 17:02:20 2010
@@ -6,5 +6,8 @@
     try:
         from md5 import md5
     except ImportError:
-        # no _md5 module on this platform
-        from pypy.lib.md5 import md5
+        # no _md5 module on this platform. Try hard to find a pure-python one
+        # by fishing it from lib_pypy
+        from pypy.tool.lib_pypy import import_from_lib_pypy
+        md5 = import_from_lib_pypy('md5')
+        del import_from_lib_pypy

Modified: pypy/branch/sys-prefix/pypy/tool/lib_pypy.py
==============================================================================
--- pypy/branch/sys-prefix/pypy/tool/lib_pypy.py	(original)
+++ pypy/branch/sys-prefix/pypy/tool/lib_pypy.py	Mon May 31 17:02:20 2010
@@ -6,3 +6,8 @@
     prefix = py.path.local(pypy.__path__[0]).dirpath()
     pypy_ver = 'pypy%d.%d' % PYPY_VERSION[:2]
     return prefix.join('lib', pypy_ver, 'lib_pypy')
+
+def import_from_lib_pypy(modname):
+    dirname = get_lib_pypy_dir()
+    modname = dirname.join(modname+'.py')
+    return modname.pyimport()

Modified: pypy/branch/sys-prefix/pypy/tool/test/test_lib_pypy.py
==============================================================================
--- pypy/branch/sys-prefix/pypy/tool/test/test_lib_pypy.py	(original)
+++ pypy/branch/sys-prefix/pypy/tool/test/test_lib_pypy.py	Mon May 31 17:02:20 2010
@@ -4,3 +4,9 @@
 def test_lib_pypy_exists():
     dirname = lib_pypy.get_lib_pypy_dir()
     assert dirname.check(dir=1)
+
+def test_import_from_lib_pypy():
+    binascii = lib_pypy.import_from_lib_pypy('binascii')
+    assert type(binascii) is type(lib_pypy)
+    assert binascii.__name__ == 'lib_pypy.binascii'
+    assert hasattr(binascii, 'crc_32_tab')

Modified: pypy/branch/sys-prefix/pypy/translator/goal/targetpypystandalone.py
==============================================================================
--- pypy/branch/sys-prefix/pypy/translator/goal/targetpypystandalone.py	(original)
+++ pypy/branch/sys-prefix/pypy/translator/goal/targetpypystandalone.py	Mon May 31 17:02:20 2010
@@ -226,7 +226,8 @@
         return PyPyJitPolicy()
     
     def get_entry_point(self, config):
-        from pypy.lib.ctypes_config_cache import rebuild
+        from pypy.tool.lib_pypy import import_from_lib_pypy
+        rebuild = import_from_lib_pypy('ctypes_config_cache/rebuild')
         rebuild.try_rebuild()
 
         space = make_objspace(config)

Modified: pypy/branch/sys-prefix/pypy/translator/sandbox/pypy_interact.py
==============================================================================
--- pypy/branch/sys-prefix/pypy/translator/sandbox/pypy_interact.py	(original)
+++ pypy/branch/sys-prefix/pypy/translator/sandbox/pypy_interact.py	Mon May 31 17:02:20 2010
@@ -57,6 +57,7 @@
                 'pypy-c': RealFile(self.executable),
                 'lib-python': RealDir(os.path.join(pypydist, 'lib-python'),
                                       exclude=exclude),
+                # XXX: fix this (and write a test!)
                 'pypy': Dir({
                     'lib': RealDir(os.path.join(pypydist, 'pypy', 'lib'),
                                    exclude=exclude),

Modified: pypy/branch/sys-prefix/pypy/translator/sandbox/sandlib.py
==============================================================================
--- pypy/branch/sys-prefix/pypy/translator/sandbox/sandlib.py	(original)
+++ pypy/branch/sys-prefix/pypy/translator/sandbox/sandlib.py	Mon May 31 17:02:20 2010
@@ -6,7 +6,6 @@
 
 import py
 import sys, os, posixpath, errno, stat, time
-from pypy.lib import marshal   # see below
 from pypy.rpython.module.ll_os_stat import s_StatResult
 from pypy.tool.ansi_print import AnsiLog
 from pypy.rlib.rarithmetic import r_longlong
@@ -26,12 +25,14 @@
 py.log.setconsumer("sandlib", MyAnsiLog())
 
 
-# Note: we use pypy.lib.marshal instead of the built-in marshal
+# Note: we use lib_pypy/marshal.py instead of the built-in marshal
 # for two reasons.  The built-in module could be made to segfault
 # or be attackable in other ways by sending malicious input to
 # load().  Also, marshal.load(f) blocks with the GIL held when
 # f is a pipe with no data immediately avaialble, preventing the
 # _waiting_thread to run.
+from pypy.tool.lib_pypy import import_from_lib_pypy
+marshal = import_from_lib_pypy('marshal')
 
 def read_message(f, timeout=None):
     # warning: 'timeout' is not really reliable and should only be used



More information about the Pypy-commit mailing list