[pypy-commit] pypy default: Make sure sys.prefix is always defined, even if it contains the
arigo
pypy.commits at gmail.com
Sun May 28 12:41:38 EDT 2017
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r91433:ac573ca24687
Date: 2017-05-28 18:21 +0200
http://bitbucket.org/pypy/pypy/changeset/ac573ca24687/
Log: Make sure sys.prefix is always defined, even if it contains the
translation-time value. Fix obscure issues where the PyPy is not
usable even on the same machine. It will still emit the warning
lines but at least work.
diff --git a/pypy/interpreter/app_main.py b/pypy/interpreter/app_main.py
--- a/pypy/interpreter/app_main.py
+++ b/pypy/interpreter/app_main.py
@@ -798,8 +798,8 @@
'"license" for more information.')
STDLIB_WARNING = """\
-debug: WARNING: Library path not found, using compiled-in sys.path.
-debug: WARNING: 'sys.prefix' will not be set.
+debug: WARNING: Library path not found, using compiled-in sys.path, with
+debug: WARNING: sys.prefix = %r
debug: WARNING: Make sure the pypy binary is kept inside its tree of files.
debug: WARNING: It is ok to create a symlink to it from somewhere else."""
@@ -818,12 +818,8 @@
executable = sys.pypy_find_executable(executable)
stdlib_path = sys.pypy_find_stdlib(executable)
if stdlib_path is None:
- for lib_path in sys.path:
- stdlib_path = sys.pypy_find_stdlib(lib_path)
- if stdlib_path is not None:
- break
- if stdlib_path is None:
- print >> sys.stderr, STDLIB_WARNING
+ print >> sys.stderr, STDLIB_WARNING % (
+ getattr(sys, 'prefix', '<missing>'),)
else:
sys.path[:] = stdlib_path
# from this point on, we are free to use all the unicode stuff we want,
diff --git a/pypy/module/sys/__init__.py b/pypy/module/sys/__init__.py
--- a/pypy/module/sys/__init__.py
+++ b/pypy/module/sys/__init__.py
@@ -39,8 +39,8 @@
'stderr' : 'state.getio(space).w_stderr',
'__stderr__' : 'state.getio(space).w_stderr',
'pypy_objspaceclass' : 'space.newtext(repr(space))',
- #'prefix' : # added by pypy_initial_path() when it
- #'exec_prefix' : # succeeds, pointing to trunk or /usr
+ 'prefix' : 'state.get(space).w_initial_prefix',
+ 'exec_prefix' : 'state.get(space).w_initial_prefix',
'path' : 'state.get(space).w_path',
'modules' : 'state.get(space).w_modules',
'argv' : 'state.get(space).w_argv',
diff --git a/pypy/module/sys/state.py b/pypy/module/sys/state.py
--- a/pypy/module/sys/state.py
+++ b/pypy/module/sys/state.py
@@ -19,8 +19,11 @@
def setinitialpath(self, space):
from pypy.module.sys.initpath import compute_stdlib_path
+ # This initial value for sys.prefix is normally overwritten
+ # at runtime by initpath.py
+ srcdir = os.path.dirname(pypydir)
+ self.w_initial_prefix = space.newtext(srcdir)
# Initialize the default path
- srcdir = os.path.dirname(pypydir)
path = compute_stdlib_path(self, srcdir)
self.w_path = space.newlist([space.newtext(p) for p in path])
More information about the pypy-commit
mailing list