Skip to content

Commit

Permalink
Strip Requires-Dist metadata parsed from METADATA files
Browse files Browse the repository at this point in the history
These can contain a leading \n if the requirement was long and wrapped by
email.message.EmailMessage.as_bytes().
  • Loading branch information
sbidoul committed Oct 1, 2023
1 parent 38b913b commit 925e594
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/pip/_internal/metadata/importlib/_dists.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,9 @@ def is_extra_provided(self, extra: str) -> bool:
def iter_dependencies(self, extras: Collection[str] = ()) -> Iterable[Requirement]:
contexts: Sequence[Dict[str, str]] = [{"extra": e} for e in extras]
for req_string in self.metadata.get_all("Requires-Dist", []):
req = Requirement(req_string)
# strip() because email.message.Message.get_all() may return a leading \n
# in case a long header was wrapped.
req = Requirement(req_string.strip())
if not req.marker:
yield req
elif not extras and req.marker.evaluate({"extra": ""}):
Expand Down

0 comments on commit 925e594

Please sign in to comment.