Author: Stefano Rivera <[email protected]>
Branch:
Changeset: r2607:b1196289cab3
Date: 2016-01-17 07:47 -0800
http://bitbucket.org/cffi/cffi/changeset/b1196289cab3/
Log: Don't blow away PYTHONPATH
Rather parse it, and prefix our base directory, if necessary.
diff --git a/testing/embedding/test_basic.py b/testing/embedding/test_basic.py
--- a/testing/embedding/test_basic.py
+++ b/testing/embedding/test_basic.py
@@ -29,6 +29,14 @@
py.test.skip(str(_link_error))
+def prefix_pythonpath():
+ cffi_base = os.path.dirname(os.path.dirname(local_dir))
+ pythonpath = os.environ.get('PYTHONPATH', '').split(':')
+ if cffi_base not in pythonpath:
+ pythonpath.insert(0, cffi_base)
+ return ':'.join(pythonpath)
+
+
class EmbeddingTests:
_compiled_modules = {}
@@ -69,8 +77,7 @@
# find a solution to that: we could hack sys.path inside the
# script run here, but we can't hack it in the same way in
# execute().
- env_extra = {'PYTHONPATH':
- os.path.dirname(os.path.dirname(local_dir))}
+ env_extra = {'PYTHONPATH': prefix_pythonpath()}
output = self._run([sys.executable, os.path.join(local_dir,
filename)],
env_extra=env_extra)
match = re.compile(r"\bFILENAME: (.+)").search(output)
@@ -114,8 +121,7 @@
def execute(self, name):
path = self.get_path()
- env_extra = {}
- env_extra['PYTHONPATH'] = os.path.dirname(os.path.dirname(local_dir))
+ env_extra = {'PYTHONPATH': prefix_pythonpath()}
libpath = os.environ.get('LD_LIBRARY_PATH')
if libpath:
libpath = path + ':' + libpath
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit