summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSviatoslav Sydorenko <wk@sydorenko.org.ua>2020-12-31 18:02:31 +0100
committerSviatoslav Sydorenko <wk@sydorenko.org.ua>2020-12-31 18:38:49 +0100
commit9c88e35e0e54712f8ac361faffe5bc9cd370ad8d (patch)
tree18ba5d7065052189e237ac4433169ee1eca995a1
parent818680c71d2a407f76ae9dc9edaee6c8b338ab2c (diff)
downloadpython-setuptools-git-9c88e35e0e54712f8ac361faffe5bc9cd370ad8d.tar.gz
Simplify `setuptools.installer.fetch_build_egg`
-rw-r--r--setuptools/installer.py23
1 files changed, 8 insertions, 15 deletions
diff --git a/setuptools/installer.py b/setuptools/installer.py
index e630b874..ac2aba18 100644
--- a/setuptools/installer.py
+++ b/setuptools/installer.py
@@ -80,20 +80,17 @@ def fetch_build_egg(dist, req):
if 'allow_hosts' in opts:
raise DistutilsError('the `allow-hosts` option is not supported '
'when using pip to install requirements.')
- if 'PIP_QUIET' in os.environ or 'PIP_VERBOSE' in os.environ:
- quiet = False
- else:
- quiet = True
+ quiet = 'PIP_QUIET' not in os.environ and 'PIP_VERBOSE' not in os.environ
if 'PIP_INDEX_URL' in os.environ:
index_url = None
elif 'index_url' in opts:
index_url = opts['index_url'][1]
else:
index_url = None
- if 'find_links' in opts:
- find_links = _fixup_find_links(opts['find_links'][1])[:]
- else:
- find_links = []
+ find_links = (
+ _fixup_find_links(opts['find_links'][1])[:] if 'find_links' in opts
+ else []
+ )
if dist.dependency_links:
find_links.extend(dist.dependency_links)
eggs_dir = os.path.realpath(dist.get_egg_cache_dir())
@@ -112,16 +109,12 @@ def fetch_build_egg(dist, req):
cmd.append('--quiet')
if index_url is not None:
cmd.extend(('--index-url', index_url))
- if find_links is not None:
- for link in find_links:
- cmd.extend(('--find-links', link))
+ for link in find_links or []:
+ cmd.extend(('--find-links', link))
# If requirement is a PEP 508 direct URL, directly pass
# the URL to pip, as `req @ url` does not work on the
# command line.
- if req.url:
- cmd.append(req.url)
- else:
- cmd.append(str(req))
+ cmd.append(req.url or str(req))
try:
subprocess.check_call(cmd)
except subprocess.CalledProcessError as e: