aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrobnagler <github@q33.us>2019-02-26 17:10:49 +0000
committerrobnagler <github@q33.us>2019-02-26 17:10:49 +0000
commit5b2175ebd9f4a669097e8309a53e3b843dcbb218 (patch)
treec185970c9abd13ef9f83195b37839667c5ed2067
parent0483cca44855280d25e7798680bb520da8923e16 (diff)
downloadexternal_python_setuptools-5b2175ebd9f4a669097e8309a53e3b843dcbb218.tar.gz
external_python_setuptools-5b2175ebd9f4a669097e8309a53e3b843dcbb218.tar.bz2
external_python_setuptools-5b2175ebd9f4a669097e8309a53e3b843dcbb218.zip
uniquify paths in PYTHONPATH
When running in a complex environment with lots of installed packages, PYTHONPATH gets way too long. Instead, just make sure that paths_on_pythonpath doesn't contain duplicates
-rw-r--r--setuptools/command/test.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/setuptools/command/test.py b/setuptools/command/test.py
index dde0118c..997fd8b0 100644
--- a/setuptools/command/test.py
+++ b/setuptools/command/test.py
@@ -186,11 +186,12 @@ class test(Command):
orig_pythonpath = os.environ.get('PYTHONPATH', nothing)
current_pythonpath = os.environ.get('PYTHONPATH', '')
try:
- prefix = os.pathsep.join(paths)
- to_join = filter(None, [prefix, current_pythonpath])
- new_path = os.pathsep.join(to_join)
- if new_path:
- os.environ['PYTHONPATH'] = new_path
+ to_join = []
+ for x in list(paths) + current_pythonpath.split(os.pathsep):
+ if x not in to_join:
+ to_join.append(x)
+ if to_join:
+ os.environ['PYTHONPATH'] = os.pathsep.join(to_join)
yield
finally:
if orig_pythonpath is nothing: