Skip to content

Commit

Permalink
requirements parsing: do not include egg name twice
Browse files Browse the repository at this point in the history
Requirements with a wheel path with extras caused a constraint line with
egg name which was included twice.
For example:

```
'spacy = {file = "https://files.pythonhosted.org/packages/.../spacy-3.4.3-cp39-..._x86_64.whl", extras = ["transformers"]}'
```

Produced a constraint line like the following:
```
https://files.pythonhosted.org/.../spacy-3.4.3-..._x86_64.whl#egg=spacy#egg=spacy[transformers]
```

This line triggered an unhandled excpetion `pipenv.exceptions.ResolutionFailure`,
as in pypa/pipenv#5536.

Signed-off-by: Oz Tiram <oz.tiram@gmail.com>
  • Loading branch information
oz123 committed Dec 21, 2022
1 parent 59fe02b commit bb631a1
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/requirementslib/models/requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -1831,7 +1831,7 @@ def from_pipfile(cls, name, pipfile):
line = "{0}&subdirectory={1}".format(line, pipfile["subdirectory"])
if editable:
line = "-e {0}".format(line)
arg_dict["parsed_line"] = Line(line)
arg_dict["parsed_line"] = Line(line, extras=extras)
arg_dict["setup_info"] = arg_dict["parsed_line"].setup_info
return cls(**arg_dict) # type: ignore

Expand Down Expand Up @@ -2525,6 +2525,8 @@ def get_line_instance(self):
self.is_file_or_url
and not local_editable
and not self.req.get_uri().startswith("file://")
# fix for file uri with egg names and extras
and not len(self.req.line_part.split("#")) > 1
):
line_parts.append(f"#egg={self._name}{self.extras_as_pip}")
else:
Expand Down

0 comments on commit bb631a1

Please sign in to comment.