[pypy-svn] r61190 - in pypy/trunk: lib-python/modified-2.5.2 pypy/module/sys

arigo at codespeak.net arigo at codespeak.net
Wed Jan 21 15:07:50 CET 2009


Author: arigo
Date: Wed Jan 21 15:07:50 2009
New Revision: 61190

Modified:
   pypy/trunk/lib-python/modified-2.5.2/site.py
   pypy/trunk/pypy/module/sys/__init__.py
   pypy/trunk/pypy/module/sys/state.py
Log:
Kill sys.prefix and sys.exec_prefix, and replace them with sys.pypy_prefix.
It points to the root of the checkout.


Modified: pypy/trunk/lib-python/modified-2.5.2/site.py
==============================================================================
--- pypy/trunk/lib-python/modified-2.5.2/site.py	(original)
+++ pypy/trunk/lib-python/modified-2.5.2/site.py	Wed Jan 21 15:07:50 2009
@@ -175,38 +175,11 @@
     return known_paths
 
 def addsitepackages(known_paths):
-    """Add site-packages (and possibly site-python) to sys.path"""
-    prefixes = [sys.prefix]
-    if sys.exec_prefix != sys.prefix:
-        prefixes.append(sys.exec_prefix)
-    for prefix in prefixes:
-        if prefix:
-            if sys.platform in ('os2emx', 'riscos'):
-                sitedirs = [os.path.join(prefix, "Lib", "site-packages")]
-            elif os.sep == '/':
-                sitedirs = [os.path.join(prefix,
-                                         "lib",
-                                         "python" + sys.version[:3],
-                                         "site-packages"),
-                            os.path.join(prefix, "lib", "site-python")]
-            else:
-                sitedirs = [prefix, os.path.join(prefix, "lib", "site-packages")]
-            if sys.platform == 'darwin':
-                # for framework builds *only* we add the standard Apple
-                # locations. Currently only per-user, but /Library and
-                # /Network/Library could be added too
-                if 'Python.framework' in prefix:
-                    home = os.environ.get('HOME')
-                    if home:
-                        sitedirs.append(
-                            os.path.join(home,
-                                         'Library',
-                                         'Python',
-                                         sys.version[:3],
-                                         'site-packages'))
-            for sitedir in sitedirs:
-                if os.path.isdir(sitedir):
-                    addsitedir(sitedir, known_paths)
+    """Add site-packages to sys.path, in a PyPy-specific way."""
+    if hasattr(sys, 'pypy_prefix'):
+        sitedir = os.path.join(sys.pypy_prefix, "site-packages")
+        if os.path.isdir(sitedir):
+            addsitedir(sitedir, known_paths)
     return None
 
 

Modified: pypy/trunk/pypy/module/sys/__init__.py
==============================================================================
--- pypy/trunk/pypy/module/sys/__init__.py	(original)
+++ pypy/trunk/pypy/module/sys/__init__.py	Wed Jan 21 15:07:50 2009
@@ -18,8 +18,6 @@
         'platform'              : 'space.wrap(sys.platform)', 
         'maxint'                : 'space.wrap(sys.maxint)', 
         'byteorder'             : 'space.wrap(sys.byteorder)', 
-        'exec_prefix'           : 'space.wrap(sys.exec_prefix)', 
-        'prefix'                : 'space.wrap(sys.prefix)', 
         'maxunicode'            : 'space.wrap(sys.maxunicode)',
         'maxint'                : 'space.wrap(sys.maxint)',
         'stdin'                 : 'state.getio(space).w_stdin',
@@ -29,6 +27,8 @@
         'stderr'                : 'state.getio(space).w_stderr',
         '__stderr__'            : 'state.getio(space).w_stderr',
         'pypy_objspaceclass'    : 'space.wrap(repr(space))',
+        #'pypy_prefix': added by pypy_initial_path() when it succeeds, pointing
+        # to the trunk of a checkout or to the dir /usr/share/pypy-1.1 .
 
         'path'                  : 'state.get(space).w_path', 
         'modules'               : 'state.get(space).w_modules', 

Modified: pypy/trunk/pypy/module/sys/state.py
==============================================================================
--- pypy/trunk/pypy/module/sys/state.py	(original)
+++ pypy/trunk/pypy/module/sys/state.py	Wed Jan 21 15:07:50 2009
@@ -62,6 +62,8 @@
     except OSError:
         return space.w_None
     else:
+        space.setitem(space.sys.w_dict, space.wrap('pypy_prefix'),
+                                        space.wrap(srcdir))
         return space.newlist([space.wrap(p) for p in path])
 
 pypy_initial_path.unwrap_spec = [ObjSpace, str]



More information about the Pypy-commit mailing list