fixed a bug with locking packages with uncanonical names

This commit is contained in:
Aleksandr Mangin
2024-01-05 14:07:39 +01:00
committed by Oz Tiram
parent 8e0608593a
commit dc261212c8
3 changed files with 30 additions and 1 deletions
+1
View File
@@ -0,0 +1 @@
Fix a bug with locking projects that contains packages with non canonical names from private indexes
@@ -247,6 +247,7 @@ class Factory:
# 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()
@@ -282,7 +283,7 @@ class Factory:
def iter_index_candidate_infos() -> Iterator[IndexCandidateInfo]:
result = self._finder.find_best_candidate(
project_name=name,
project_name=project_name,
specifier=specifier,
hashes=hashes,
)
+27
View File
@@ -285,6 +285,33 @@ pipenv-test-private-package = {version = "*", index = "testpypi"}
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):