Commit 8db41e47 authored by Jason R. Coombs's avatar Jason R. Coombs

Rely on unique_everseen to avoid unnecessarily polluting the PYTHONPATH with duplicate entries.

parent 5b2175eb
......@@ -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:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment