Skip to content

Commit

Permalink
built index mapping using canonical package names instead of raw pack…
Browse files Browse the repository at this point in the history
…age names
  • Loading branch information
mangin authored and oz123 committed Jan 17, 2024
1 parent dc26121 commit 463d9c8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,6 @@ def _iter_found_candidates(
# Hopefully the Project model can correct this mismatch in the future.
template = ireqs[0]
assert template.req, "Candidates found on index must be PEP 508"
project_name = template.req.name
name = canonicalize_name(template.req.name)

extras: FrozenSet[str] = frozenset()
Expand Down Expand Up @@ -283,7 +282,7 @@ def _get_installed_candidate() -> Optional[Candidate]:

def iter_index_candidate_infos() -> Iterator[IndexCandidateInfo]:
result = self._finder.find_best_candidate(
project_name=project_name,
project_name=name,
specifier=specifier,
hashes=hashes,
)
Expand Down
20 changes: 15 additions & 5 deletions pipenv/utils/resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from pipenv.patched.pip._internal.req.req_install import InstallRequirement
from pipenv.patched.pip._internal.utils.temp_dir import global_tempdir_manager
from pipenv.patched.pip._vendor import pkg_resources, rich
from pipenv.patched.pip._vendor.packaging.utils import canonicalize_name
from pipenv.project import Project
from pipenv.utils.fileutils import create_tracked_tempdir
from pipenv.utils.requirements import normalize_name
Expand Down Expand Up @@ -200,6 +201,7 @@ def create(
for package_name, dep in deps.items(): # Build up the index and markers lookups
if not dep:
continue
canonical_package_name = canonicalize_name(package_name)
is_constraint = True
install_req, _ = expansive_install_req_from_line(dep, expand_env=True)
original_deps[package_name] = dep
Expand All @@ -210,14 +212,18 @@ def create(
pipfile_entries[package_name] = pipfile_entry
if isinstance(pipfile_entry, dict):
if packages[package_name].get("index"):
index_lookup[package_name] = packages[package_name].get("index")
index_lookup[canonical_package_name] = packages[package_name].get(
"index"
)
if packages[package_name].get("skip_resolver"):
is_constraint = False
skipped[package_name] = dep
elif index:
index_lookup[package_name] = index
index_lookup[canonical_package_name] = index
else:
index_lookup[package_name] = project.get_default_index()["name"]
index_lookup[canonical_package_name] = project.get_default_index()[
"name"
]
if install_req.markers:
markers_lookup[package_name] = install_req.markers
if is_constraint:
Expand Down Expand Up @@ -546,9 +552,13 @@ def collect_hashes(self, ireq):
return set()

sources = self.sources # Enforce index restrictions
if ireq.name in self.index_lookup:
canonical_ireq_name = canonicalize_name(ireq.name)
if canonical_ireq_name in self.index_lookup:
sources = list(
filter(lambda s: s.get("name") == self.index_lookup[ireq.name], sources)
filter(
lambda s: s.get("name") == self.index_lookup[canonical_ireq_name],
sources,
)
)
source = sources[0] if len(sources) else None
if source:
Expand Down

0 comments on commit 463d9c8

Please sign in to comment.