Skip to content

Commit

Permalink
fixed a bug with locking packages with uncanonical names
Browse files Browse the repository at this point in the history
  • Loading branch information
mangin committed Jan 5, 2024
1 parent 8e06085 commit f63095d
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
1 change: 1 addition & 0 deletions news/6056.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix a bug with locking projects that contains packages with non canonical names from private indexes
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ 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 @@ -282,7 +283,7 @@ def _get_installed_candidate() -> Optional[Candidate]:

def iter_index_candidate_infos() -> Iterator[IndexCandidateInfo]:
result = self._finder.find_best_candidate(
project_name=name,
project_name=project_name,
specifier=specifier,
hashes=hashes,
)
Expand Down
27 changes: 27 additions & 0 deletions tests/integration/test_lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,33 @@ def test_private_index_lock_requirements(pipenv_instance_private_pypi):
assert c.returncode == 0


@pytest.mark.lock
@pytest.mark.index
@pytest.mark.install # private indexes need to be uncached for resolution
@pytest.mark.requirements
@pytest.mark.needs_internet
def test_private_index_lock_requirements_for_not_canonical_package(pipenv_instance_private_pypi):
with pipenv_instance_private_pypi() as p:
with open(p.pipfile_path, 'w') as f:
contents = """
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
[[source]]
url = "https://test.pypi.org/simple"
verify_ssl = true
name = "testpypi"
[packages]
pipenv_test_private_package = {version = "*", index = "testpypi"}
""".strip()
f.write(contents)
c = p.pipenv('lock')
assert c.returncode == 0


@pytest.mark.index
@pytest.mark.install
def test_lock_updated_source(pipenv_instance_private_pypi):
Expand Down

0 comments on commit f63095d

Please sign in to comment.