[pypy-svn] pypy default: fix test_getsitepackages by deciding that pypy does not support site-python, only site-packages

antocuni commits-noreply at bitbucket.org
Mon Feb 14 15:23:58 CET 2011


Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: 
Changeset: r41907:3849dfadc6b2
Date: 2011-02-14 15:12 +0100
http://bitbucket.org/pypy/pypy/changeset/3849dfadc6b2/

Log:	fix test_getsitepackages by deciding that pypy does not support
	site-python, only site-packages

diff --git a/lib-python/modified-2.7.0/test/test_site.py b/lib-python/modified-2.7.0/test/test_site.py
--- a/lib-python/modified-2.7.0/test/test_site.py
+++ b/lib-python/modified-2.7.0/test/test_site.py
@@ -168,6 +168,10 @@
             self.assertEqual(len(dirs), 1)
             wanted = os.path.join('xoxo', 'Lib', 'site-packages')
             self.assertEquals(dirs[0], wanted)
+        elif '__pypy__' in sys.builtin_module_names:
+            self.assertEquals(len(dirs), 1)
+            wanted = os.path.join('xoxo', 'site-packages')
+            self.assertEquals(dirs[0], wanted)
         elif os.sep == '/':
             self.assertEqual(len(dirs), 2)
             wanted = os.path.join('xoxo', 'lib', 'python' + sys.version[:3],

diff --git a/lib-python/modified-2.7.0/site.py b/lib-python/modified-2.7.0/site.py
--- a/lib-python/modified-2.7.0/site.py
+++ b/lib-python/modified-2.7.0/site.py
@@ -281,13 +281,7 @@
     will find its `site-packages` subdirectory depending on the system
     environment, and will return a list of full paths.
     """
-    # pypy specific logic
-    if hasattr(sys, 'pypy_version_info') and hasattr(sys, 'prefix'):
-        from distutils.sysconfig import get_python_lib
-        sitedir = get_python_lib(standard_lib=False)
-        return [sitedir]
-
-    # cpython logic
+    is_pypy = '__pypy__' in sys.builtin_module_names
     sitepackages = []
     seen = set()
 
@@ -298,6 +292,10 @@
 
         if sys.platform in ('os2emx', 'riscos'):
             sitepackages.append(os.path.join(prefix, "Lib", "site-packages"))
+        elif is_pypy:
+            from distutils.sysconfig import get_python_lib
+            sitedir = get_python_lib(standard_lib=False, prefix=prefix)
+            sitepackages.append(sitedir)
         elif os.sep == '/':
             sitepackages.append(os.path.join(prefix, "lib",
                                         "python" + sys.version[:3],


More information about the Pypy-commit mailing list