Commit a2e883e1 authored by Jason R. Coombs's avatar Jason R. Coombs

Extract function to strip the marker for concise code in the long function.

parent 2292718a
...@@ -64,11 +64,8 @@ def fetch_build_egg(dist, req): ...@@ -64,11 +64,8 @@ def fetch_build_egg(dist, req):
pkg_resources.get_distribution('wheel') pkg_resources.get_distribution('wheel')
except pkg_resources.DistributionNotFound: except pkg_resources.DistributionNotFound:
dist.announce('WARNING: The wheel package is not available.', log.WARN) dist.announce('WARNING: The wheel package is not available.', log.WARN)
# Ignore environment markers: if we're here, it's needed. This ensure # Ignore environment markers; if supplied, it is required.
# we don't try to ask pip for something like `babel; extra == "i18n"`, req = strip_marker(req)
# which would always be ignored.
req = pkg_resources.Requirement.parse(str(req))
req.marker = None
# Take easy_install options into account, but do not override relevant # Take easy_install options into account, but do not override relevant
# pip environment variables (like PIP_INDEX_URL or PIP_QUIET); they'll # pip environment variables (like PIP_INDEX_URL or PIP_QUIET); they'll
# take precedence. # take precedence.
...@@ -130,3 +127,15 @@ def fetch_build_egg(dist, req): ...@@ -130,3 +127,15 @@ def fetch_build_egg(dist, req):
dist = pkg_resources.Distribution.from_filename( dist = pkg_resources.Distribution.from_filename(
dist_location, metadata=dist_metadata) dist_location, metadata=dist_metadata)
return dist 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
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