From 802dc0d06501f98dc2b35ab6ad025b43647840bd Mon Sep 17 00:00:00 2001 From: Matt Davis Date: Sat, 3 Sep 2022 07:15:46 -0400 Subject: [PATCH 1/8] possible fix for issue where requirement is a file or URL but does contain hashes. --- pipenv/core.py | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/pipenv/core.py b/pipenv/core.py index 5f30a32e8f..4ba9e15e41 100644 --- a/pipenv/core.py +++ b/pipenv/core.py @@ -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 @@ -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: From 281e06e1a75f48201cf29e02376b3d5f7e015750 Mon Sep 17 00:00:00 2001 From: Matt Davis Date: Sat, 3 Sep 2022 07:21:15 -0400 Subject: [PATCH 2/8] add news fragment. --- news/5306.bugfix.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 news/5306.bugfix.rst diff --git a/news/5306.bugfix.rst b/news/5306.bugfix.rst new file mode 100644 index 0000000000..4515622351 --- /dev/null +++ b/news/5306.bugfix.rst @@ -0,0 +1 @@ +Fix the issue from ``2022.9.2`` where tarball URL packages were being skipped on batch_install. From 272d5620749cbaadc9e90511e235651951f20d2e Mon Sep 17 00:00:00 2001 From: Matt Davis Date: Sat, 3 Sep 2022 09:34:46 -0400 Subject: [PATCH 3/8] change flake8 repo since gitlab is down for maintenace. --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e0739d1046..3515fc9f3d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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 From d943dfd1d6c8fe3239f9fd7b9e300ef6f7c7559c Mon Sep 17 00:00:00 2001 From: Matt Davis Date: Sat, 3 Sep 2022 10:28:47 -0400 Subject: [PATCH 4/8] Add test case that fails on main branch and covers example fix of the issue. --- tests/integration/test_install_basic.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/integration/test_install_basic.py b/tests/integration/test_install_basic.py index 3c7959cb4f..94e93858f8 100644 --- a/tests/integration/test_install_basic.py +++ b/tests/integration/test_install_basic.py @@ -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] +six = {file = "https://files.pythonhosted.org/packages/71/39/171f1c67cd00715f190ba0b100d606d440a28c93c7714febeca8b79af85e/six-1.16.0.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 'import six'") + assert c.returncode == 0 From 9a380839e198dc4b5582719d4a0b3db48b312f66 Mon Sep 17 00:00:00 2001 From: Matt Davis Date: Sat, 3 Sep 2022 11:17:14 -0400 Subject: [PATCH 5/8] Have the tests cleanup Pipfile after itself. --- tests/integration/conftest.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index 3ad6bd1673..526843ba92 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -357,6 +357,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 From 9725bd12fef4db177a3593962c1d85ac17839136 Mon Sep 17 00:00:00 2001 From: Matt Davis Date: Sat, 3 Sep 2022 13:21:21 -0400 Subject: [PATCH 6/8] Try to fix cross test pollution of Pipfile. --- tests/integration/conftest.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index 526843ba92..69d03ed75f 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -349,6 +349,8 @@ def __init__( 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: From a9d9d6ad5548c93240ee38de472e2b07ab7c4a6f Mon Sep 17 00:00:00 2001 From: Matt Davis Date: Sat, 3 Sep 2022 13:48:24 -0400 Subject: [PATCH 7/8] Try to fix cross test pollution of Pipfile. --- tests/integration/conftest.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index 69d03ed75f..cee5b1bf41 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -343,6 +343,10 @@ 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) From 334ab205ed5e8eeade975641f75158462a829729 Mon Sep 17 00:00:00 2001 From: Matt Davis Date: Sat, 3 Sep 2022 14:33:38 -0400 Subject: [PATCH 8/8] Use a different library since I could not figure out the six conflicts this caused with other tests. --- tests/integration/test_install_basic.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/integration/test_install_basic.py b/tests/integration/test_install_basic.py index 94e93858f8..a0e8767056 100644 --- a/tests/integration/test_install_basic.py +++ b/tests/integration/test_install_basic.py @@ -558,12 +558,12 @@ def test_install_tarball_is_actually_installed(PipenvInstance): name = "pypi" [packages] -six = {file = "https://files.pythonhosted.org/packages/71/39/171f1c67cd00715f190ba0b100d606d440a28c93c7714febeca8b79af85e/six-1.16.0.tar.gz"} +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 'import six'") + c = p.pipenv("run python -c 'from dataclasses_json import dataclass_json'") assert c.returncode == 0