Author: Armin Rigo <[email protected]>
Branch:
Changeset: r87387:d1382b9d843b
Date: 2016-09-26 09:01 +0200
http://bitbucket.org/pypy/pypy/changeset/d1382b9d843b/
Log: If libpypy-c.so is a symlink, look first around the non-deferred
path to libpypy-c.so, and then look around where the symlink points
to. Should fix virtualenv (e.g. seen in
module.test_lib_pypy.cffi_tests.cffi0.test_zintegration)
diff --git a/pypy/module/sys/initpath.py b/pypy/module/sys/initpath.py
--- a/pypy/module/sys/initpath.py
+++ b/pypy/module/sys/initpath.py
@@ -157,6 +157,22 @@
return space.wrap(resolvedirof(filename))
+def find_stdlib_link(state, executable):
+ path, prefix = find_stdlib(state, executable)
+ if path is None:
+ if os.path.islink(executable):
+ # If we can't find the stdlib from the given 'executable',
+ # which is usually the path of libpypy-c.so, then we try
+ # to look if this libpypy-c.so is a symlink and follow that.
+ try:
+ link = _readlink_maybe(executable)
+ except OSError:
+ pass
+ else:
+ return find_stdlib_link(state, link)
+ return path, prefix
+
+
@unwrap_spec(executable='str0', dynamic=int)
def pypy_find_stdlib(space, executable, dynamic=1):
if dynamic and space.config.translation.shared:
@@ -164,7 +180,7 @@
if dynamic_location:
executable = rffi.charp2str(dynamic_location)
pypy_init_free(dynamic_location)
- path, prefix = find_stdlib(get_state(space), executable)
+ path, prefix = find_stdlib_link(get_state(space), executable)
if path is None:
return space.w_None
w_prefix = space.wrap(prefix)
@@ -229,11 +245,7 @@
dlerror());
return NULL;
}
- char *p = realpath(info.dli_fname, NULL);
- if (p == NULL) {
- p = strdup(info.dli_fname);
- }
- return p;
+ return strdup(info.dli_fname);
}
"""
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit