diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2019-04-05 15:12:21 -0400 |
---|---|---|
committer | Jason R. Coombs <jaraco@jaraco.com> | 2019-04-05 15:12:21 -0400 |
commit | 8db41e478db4ded53b9836f62211f8c9371ec7c9 (patch) | |
tree | 8aa20b8f4041f23ec046dd3d53277e02aad97351 /setuptools/command | |
parent | 5b2175ebd9f4a669097e8309a53e3b843dcbb218 (diff) | |
download | external_python_setuptools-8db41e478db4ded53b9836f62211f8c9371ec7c9.tar.gz external_python_setuptools-8db41e478db4ded53b9836f62211f8c9371ec7c9.tar.bz2 external_python_setuptools-8db41e478db4ded53b9836f62211f8c9371ec7c9.zip |
Rely on unique_everseen to avoid unnecessarily polluting the PYTHONPATH with duplicate entries.
Diffstat (limited to 'setuptools/command')
-rw-r--r-- | setuptools/command/test.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/setuptools/command/test.py b/setuptools/command/test.py index 997fd8b0..973e4eb2 100644 --- a/setuptools/command/test.py +++ b/setuptools/command/test.py @@ -15,6 +15,7 @@ from pkg_resources import (resource_listdir, resource_exists, normalize_path, working_set, _namespace_packages, evaluate_marker, add_activation_listener, require, EntryPoint) from setuptools import Command +from .build_py import _unique_everseen __metaclass__ = type @@ -186,12 +187,11 @@ class test(Command): orig_pythonpath = os.environ.get('PYTHONPATH', nothing) current_pythonpath = os.environ.get('PYTHONPATH', '') try: - 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) + prefix = os.pathsep.join(_unique_everseen(paths)) + to_join = filter(None, [prefix, current_pythonpath]) + new_path = os.pathsep.join(to_join) + if new_path: + os.environ['PYTHONPATH'] = new_path yield finally: if orig_pythonpath is nothing: |