summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2019-12-01 09:38:13 -0500
committerJason R. Coombs <jaraco@jaraco.com>2019-12-01 09:38:13 -0500
commita2e883e1b838db529d992d4c6c8ab73c16f48591 (patch)
treefe3f3e4974beab2f02560803c3dcfb34974cdff2
parent2292718a151994efb7d364312c73d5b536988049 (diff)
downloadpython-setuptools-git-a2e883e1b838db529d992d4c6c8ab73c16f48591.tar.gz
Extract function to strip the marker for concise code in the long function.
-rw-r--r--setuptools/installer.py19
1 files changed, 14 insertions, 5 deletions
diff --git a/setuptools/installer.py b/setuptools/installer.py
index ba9cfce9..527b95de 100644
--- a/setuptools/installer.py
+++ b/setuptools/installer.py
@@ -64,11 +64,8 @@ def fetch_build_egg(dist, req):
pkg_resources.get_distribution('wheel')
except pkg_resources.DistributionNotFound:
dist.announce('WARNING: The wheel package is not available.', log.WARN)
- # Ignore environment markers: if we're here, it's needed. This ensure
- # we don't try to ask pip for something like `babel; extra == "i18n"`,
- # which would always be ignored.
- req = pkg_resources.Requirement.parse(str(req))
- req.marker = None
+ # Ignore environment markers; if supplied, it is required.
+ req = strip_marker(req)
# Take easy_install options into account, but do not override relevant
# pip environment variables (like PIP_INDEX_URL or PIP_QUIET); they'll
# take precedence.
@@ -130,3 +127,15 @@ def fetch_build_egg(dist, req):
dist = pkg_resources.Distribution.from_filename(
dist_location, metadata=dist_metadata)
return dist
+
+
+def strip_marker(req):
+ """
+ Return a new requirement without the environment marker to avoid
+ calling pip with something like `babel; extra == "i18n"`, which
+ would always be ignored.
+ """
+ # create a copy to avoid mutating the input
+ req = pkg_resources.Requirement.parse(str(req))
+ req.marker = None
+ return req