Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the assumption that all sources are named. #5004

Merged
merged 3 commits into from
Mar 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions news/5002.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fixes issue with new index safety restriction, whereby an unnamed extra sources index
caused and error to be thrown during install.
2 changes: 1 addition & 1 deletion pipenv/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1403,7 +1403,7 @@ def pip_install(
if index and not extra_indexes:
extra_indexes = []
if requirement.index:
extra_indexes = list(filter(lambda d: d['name'] == requirement.index, project.sources))
extra_indexes = list(filter(lambda d: d.get('name') == requirement.index, project.sources))
if not extra_indexes:
extra_indexes = list(project.sources)
if requirement and requirement.vcs or requirement.editable:
Expand Down
27 changes: 27 additions & 0 deletions tests/integration/test_install_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -497,3 +497,30 @@ def test_rewrite_outline_table(PipenvInstance):
assert 'six = {version = "*"}' in contents
assert 'requests = {version = "*"' in contents
assert 'flask = "*"' in contents


@flaky
@pytest.mark.dev
@pytest.mark.basic
@pytest.mark.install
@pytest.mark.needs_internet
def test_install_with_unnamed_source(PipenvInstance):
"""Ensure that running `pipenv install` doesn't break with an unamed index"""
with PipenvInstance(chdir=True) 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://pypi.org/simple"
verify_ssl = true

[packages]
requests = {version="*", index="pypi"}
""".strip()
f.write(contents)
c = p.pipenv("install")
assert c.returncode == 0