Merge pull request #7993 from uranusjr/new-resolver-normal-test-progress

Canonicalise project name from InstallationCandidate
This commit is contained in:
Paul Moore 2020-04-08 09:12:50 +01:00 committed by GitHub
commit bd912cf0de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 5 deletions

View File

@ -163,10 +163,19 @@ class _InstallRequirementBackedCandidate(Candidate):
# These should be "proper" errors, not just asserts, as they
# can result from user errors like a requirement "foo @ URL"
# when the project at URL has a name of "bar" in its metadata.
assert (self._name is None or
self._name == canonicalize_name(self._dist.project_name))
assert (self._version is None or
self._version == self.dist.parsed_version)
assert (
self._name is None or
self._name == canonicalize_name(self._dist.project_name)
), "Name mismatch: {!r} vs {!r}".format(
self._name, canonicalize_name(self._dist.project_name),
)
assert (
self._version is None or
self._version == self._dist.parsed_version
), "Version mismatch: {!r} vs {!r}".format(
self._version, self._dist.parsed_version,
)
return self._dist
def _get_requires_python_specifier(self):

View File

@ -1,3 +1,4 @@
from pip._vendor.packaging.utils import canonicalize_name
from pip._vendor.pkg_resources import (
DistributionNotFound,
VersionConflict,
@ -121,7 +122,7 @@ class Factory(object):
link=ican.link,
extras=extras,
parent=parent,
name=ican.name,
name=canonicalize_name(ican.name),
version=ican.version,
)
return self._make_candidate_from_dist(