summaryrefslogtreecommitdiff
path: root/setuptools/command
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2022-02-26 12:57:38 -0500
committerJason R. Coombs <jaraco@jaraco.com>2022-02-26 12:57:38 -0500
commit339c29920abdabdd9e6b5983ae711efb61b15d76 (patch)
tree135317324e560155389eae5bc3b3524f0ccf8807 /setuptools/command
parentd387ae78b3c6384cee30a441045e5b33f2a226b4 (diff)
downloadpython-setuptools-git-339c29920abdabdd9e6b5983ae711efb61b15d76.tar.gz
Extract method for processing site dirs
Diffstat (limited to 'setuptools/command')
-rw-r--r--setuptools/command/easy_install.py37
1 files changed, 22 insertions, 15 deletions
diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py
index a526d705..905bc627 100644
--- a/setuptools/command/easy_install.py
+++ b/setuptools/command/easy_install.py
@@ -310,21 +310,8 @@ class easy_install(Command):
# default --record from the install command
self.set_undefined_options('install', ('record', 'record'))
self.all_site_dirs = get_site_dirs()
- if self.site_dirs is not None:
- normpath = map(normalize_path, sys.path)
- site_dirs = [
- os.path.expanduser(s.strip()) for s in
- self.site_dirs.split(',')
- ]
- for d in site_dirs:
- if not os.path.isdir(d):
- log.warn("%s (in --site-dirs) does not exist", d)
- elif normalize_path(d) not in normpath:
- raise DistutilsOptionError(
- d + " (in --site-dirs) is not on sys.path"
- )
- else:
- self.all_site_dirs.append(normalize_path(d))
+ self.all_site_dirs.extend(self._process_site_dirs(self.site_dirs))
+
if not self.editable:
self.check_site_dir()
self.index_url = self.index_url or "https://pypi.org/simple/"
@@ -366,6 +353,26 @@ class easy_install(Command):
self.outputs = []
@staticmethod
+ def _process_site_dirs(site_dirs):
+ if site_dirs is None:
+ return
+
+ normpath = map(normalize_path, sys.path)
+ site_dirs = [
+ os.path.expanduser(s.strip()) for s in
+ site_dirs.split(',')
+ ]
+ for d in site_dirs:
+ if not os.path.isdir(d):
+ log.warn("%s (in --site-dirs) does not exist", d)
+ elif normalize_path(d) not in normpath:
+ raise DistutilsOptionError(
+ d + " (in --site-dirs) is not on sys.path"
+ )
+ else:
+ yield normalize_path(d)
+
+ @staticmethod
def _validate_optimize(value):
try:
value = int(value)