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 for issue where requirement is a file or URL but does conntain hashes. #5327

Merged
merged 9 commits into from
Sep 3, 2022
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ repos:
hooks:
- id: black

- repo: https://gitlab.com/pycqa/flake8
- repo: https://github.com/PyCQA/flake8
rev: 4.0.1
hooks:
- id: flake8
Expand Down
1 change: 1 addition & 0 deletions news/5306.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix the issue from ``2022.9.2`` where tarball URL packages were being skipped on batch_install.
21 changes: 18 additions & 3 deletions pipenv/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1601,7 +1601,7 @@ def pip_install_deps(
requirement.is_vcs
or requirement.vcs
or requirement.editable
or requirement.is_file_or_url
or (requirement.is_file_or_url and not requirement.hashes)
)
if vcs_or_editable:
ignore_hash = True
Expand All @@ -1627,10 +1627,25 @@ def pip_install_deps(

cmds = []
files = []
standard_deps = list(filter(lambda d: not (d.is_vcs or d.vcs or d.editable), deps))
standard_deps = list(
filter(
lambda d: not (
d.is_vcs or d.vcs or d.editable or (d.is_file_or_url and not d.hashes)
),
deps,
)
)
if standard_deps:
files.append(standard_requirements)
editable_deps = list(filter(lambda d: d.is_vcs or d.vcs or d.editable, deps))
editable_deps = list(
filter(
lambda d: d.is_vcs
or d.vcs
or d.editable
or (d.is_file_or_url and not d.hashes),
deps,
)
)
if editable_deps:
files.append(editable_requirements)
for file in files:
Expand Down
8 changes: 8 additions & 0 deletions tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,12 +343,18 @@ def __init__(

if pipfile:
p_path = os.sep.join([self.path, 'Pipfile'])
try:
os.remove(p_path)
except FileNotFoundError:
pass
with open(p_path, 'a'):
os.utime(p_path, None)

self.chdir = False or chdir
self.pipfile_path = p_path
self._pipfile = _Pipfile(Path(p_path))
else:
self._pipfile = None

def __enter__(self):
if self.chdir:
Expand All @@ -357,6 +363,8 @@ def __enter__(self):

def __exit__(self, *args):
warn_msg = 'Failed to remove resource: {!r}'
if self.pipfile_path:
os.remove(self.pipfile_path)
if self.chdir:
os.chdir(self.original_dir)
self.path = None
Expand Down
22 changes: 22 additions & 0 deletions tests/integration/test_install_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,3 +545,25 @@ def test_install_does_not_exclude_packaging(PipenvInstance):
assert c.returncode == 0
c = p.pipenv("run python -c 'from dataclasses_json import DataClassJsonMixin'")
assert c.returncode == 0


def test_install_tarball_is_actually_installed(PipenvInstance):
""" Test case for Issue 5326"""
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"

[packages]
dataclasses-json = {file = "https://files.pythonhosted.org/packages/85/94/1b30216f84c48b9e0646833f6f2dd75f1169cc04dc45c48fe39e644c89d5/dataclasses-json-0.5.7.tar.gz"}
""".strip()
f.write(contents)
c = p.pipenv("lock")
assert c.returncode == 0
c = p.pipenv("sync")
assert c.returncode == 0
c = p.pipenv("run python -c 'from dataclasses_json import dataclass_json'")
assert c.returncode == 0