Skip to content

Commit

Permalink
Canonicalize InstallRequirement.extras
Browse files Browse the repository at this point in the history
since dist.extras are already canonicalized, pip needs to canonicalize
extras before matching them with dist.extras

Fixes pypa#3810
  • Loading branch information
xavfernandez committed Oct 29, 2016
1 parent 1dfee1f commit 62b0218
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions pip/req/req_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ def _strip_extras(path):
return path_no_extras, extras


def _safe_extras(extras):
return set(pkg_resources.safe_extra(extra) for extra in extras)


class InstallRequirement(object):

def __init__(self, req, comes_from, source_dir=None, editable=False,
Expand All @@ -85,7 +89,7 @@ def __init__(self, req, comes_from, source_dir=None, editable=False,
add_msg = traceback.format_exc()
raise InstallationError(
"Invalid requirement: '%s'\n%s" % (req, add_msg))
self.extras = req.extras
self.extras = _safe_extras(req.extras)

self.req = req
self.comes_from = comes_from
Expand Down Expand Up @@ -149,7 +153,7 @@ def from_editable(cls, editable_req, comes_from=None, default_vcs=None,
wheel_cache=wheel_cache)

if extras_override is not None:
res.extras = extras_override
res.extras = _safe_extras(extras_override)

return res

Expand Down Expand Up @@ -224,7 +228,8 @@ def from_line(
wheel_cache=wheel_cache, constraint=constraint)

if extras:
res.extras = Requirement('placeholder' + extras).extras
res.extras = _safe_extras(
Requirement('placeholder' + extras).extras)

return res

Expand Down Expand Up @@ -1158,7 +1163,7 @@ def parse_editable(editable_req, default_vcs=None):
return (
package_name,
url_no_extras,
Requirement("placeholder" + extras).extras,
Requirement("placeholder" + extras.lower()).extras,
)
else:
return package_name, url_no_extras, None
Expand Down

0 comments on commit 62b0218

Please sign in to comment.