Derive Requirement name from ireq is possible

This is useful when resolving the wheel cache.
This commit is contained in:
Tzu-ping Chung 2020-05-07 17:12:15 +08:00
parent 1ebeab5146
commit dab7b94ade
1 changed files with 15 additions and 14 deletions

View File

@ -101,11 +101,11 @@ class Factory(object):
def _make_candidate_from_link( def _make_candidate_from_link(
self, self,
link, # type: Link link, # type: Link
extras, # type: Set[str] extras, # type: Set[str]
parent, # type: InstallRequirement parent, # type: InstallRequirement
name=None, # type: Optional[str] name, # type: Optional[str]
version=None, # type: Optional[_BaseVersion] version, # type: Optional[_BaseVersion]
): ):
# type: (...) -> Candidate # type: (...) -> Candidate
# TODO: Check already installed candidate, and use it if the link and # TODO: Check already installed candidate, and use it if the link and
@ -176,15 +176,16 @@ class Factory(object):
def make_requirement_from_install_req(self, ireq): def make_requirement_from_install_req(self, ireq):
# type: (InstallRequirement) -> Requirement # type: (InstallRequirement) -> Requirement
if ireq.link: if not ireq.link:
# TODO: Get name and version from ireq, if possible? return SpecifierRequirement(ireq, factory=self)
# Specifically, this might be needed in "name @ URL" cand = self._make_candidate_from_link(
# syntax - need to check where that syntax is handled. ireq.link,
candidate = self._make_candidate_from_link( extras=set(ireq.extras),
ireq.link, extras=set(ireq.extras), parent=ireq, parent=ireq,
) name=canonicalize_name(ireq.name) if ireq.name else None,
return self.make_requirement_from_candidate(candidate) version=None,
return SpecifierRequirement(ireq, factory=self) )
return self.make_requirement_from_candidate(cand)
def make_requirement_from_candidate(self, candidate): def make_requirement_from_candidate(self, candidate):
# type: (Candidate) -> ExplicitRequirement # type: (Candidate) -> ExplicitRequirement