From 3b18e07289d1cd4cdd046d46c244d77938732e5e Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Mon, 10 Apr 2017 11:24:25 -0400 Subject: Consolidate technique for reading PYTHONPATH. --- setuptools/command/easy_install.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'setuptools/command') diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py index 55d26560..e30ca3ac 100755 --- a/setuptools/command/easy_install.py +++ b/setuptools/command/easy_install.py @@ -474,8 +474,7 @@ class easy_install(Command): else: self.pth_file = None - PYTHONPATH = os.environ.get('PYTHONPATH', '').split(os.pathsep) - if instdir not in map(normalize_path, filter(None, PYTHONPATH)): + if instdir not in map(normalize_path, _pythonpath()): # only PYTHONPATH dirs need a site.py, so pretend it's there self.sitepy_installed = True elif self.multi_version and not os.path.exists(pth_file): @@ -1348,6 +1347,11 @@ class easy_install(Command): setattr(self, attr, val) +def _pythonpath(): + items = os.environ.get('PYTHONPATH', '').split(os.pathsep) + return filter(None, items) + + def get_site_dirs(): """ Return a list of 'site' dirs @@ -1356,8 +1360,7 @@ def get_site_dirs(): sitedirs = [] # start with PYTHONPATH - pythonpath_items = os.environ.get('PYTHONPATH', '').split(os.pathsep) - sitedirs.extend(filter(None, pythonpath_items)) + sitedirs.extend(_pythonpath()) prefixes = [sys.prefix] if sys.exec_prefix != sys.prefix: -- cgit v1.2.3