From 2ca0ed4ca3c0acef032fbff727d4be5f65514e5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Coavoux?= Date: Fri, 30 Jun 2023 14:07:39 -0400 Subject: [PATCH 1/3] Ensure version match operator when building specifier from pipfile --- .../requirementslib/models/requirements.py | 6 +++++- tests/integration/test_install_basic.py | 16 ++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/pipenv/vendor/requirementslib/models/requirements.py b/pipenv/vendor/requirementslib/models/requirements.py index 8617a68189..1f672c6597 100644 --- a/pipenv/vendor/requirementslib/models/requirements.py +++ b/pipenv/vendor/requirementslib/models/requirements.py @@ -34,7 +34,7 @@ from pipenv.patched.pip._internal.req.req_install import InstallRequirement from pipenv.patched.pip._internal.utils.temp_dir import global_tempdir_manager from pipenv.patched.pip._internal.utils.urls import path_to_url, url_to_path -from pipenv.patched.pip._vendor.distlib.util import cached_property +from pipenv.patched.pip._vendor.distlib.util import cached_property, COMPARE_OP from pipenv.patched.pip._vendor.packaging.markers import Marker from pipenv.patched.pip._vendor.packaging.requirements import Requirement as PackagingRequirement from pipenv.patched.pip._vendor.packaging.specifiers import ( @@ -2544,6 +2544,10 @@ def from_pipfile(cls, name, pipfile): if hasattr(pipfile, "keys"): _pipfile = dict(pipfile).copy() _pipfile["version"] = get_version(pipfile) + + # We ensure version contains an operator. Default to equals (==) + if _pipfile["version"] and COMPARE_OP.match(_pipfile["version"]) is None: + _pipfile["version"] = "=={}".format(_pipfile["version"]) vcs = next(iter([vcs for vcs in VCS_LIST if vcs in _pipfile]), None) if vcs: _pipfile["vcs"] = vcs diff --git a/tests/integration/test_install_basic.py b/tests/integration/test_install_basic.py index 54bf7e8e56..cbbf052c29 100644 --- a/tests/integration/test_install_basic.py +++ b/tests/integration/test_install_basic.py @@ -90,6 +90,22 @@ def test_install_without_dev(pipenv_instance_private_pypi): assert c.returncode == 0 +@pytest.mark.basic +@pytest.mark.install +def test_install_with_version_req_default_operator(pipenv_instance_pypi): + """Ensure that running `pipenv install` work when spec is package = "X.Y.Z". """ + with pipenv_instance_pypi(chdir=True) as p: + with open(p.pipfile_path, "w") as f: + contents = """ +[packages] +fastapi = "0.95.0" + """.strip() + f.write(contents) + c = p.pipenv("install") + assert c.returncode == 0 + assert "fastapi" in p.pipfile["packages"] + + @pytest.mark.basic @pytest.mark.install def test_install_without_dev_section(pipenv_instance_pypi): From 20033663ff0557b98876b2c86d61807d7f4cef4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Coavoux?= Date: Mon, 3 Jul 2023 14:52:25 -0400 Subject: [PATCH 2/3] Add news --- news/5765.bugfix | 1 + 1 file changed, 1 insertion(+) create mode 100644 news/5765.bugfix diff --git a/news/5765.bugfix b/news/5765.bugfix new file mode 100644 index 0000000000..e0cb622d35 --- /dev/null +++ b/news/5765.bugfix @@ -0,0 +1 @@ +Fixes regression on Pipfile requirements syntax. Ensure default operator is provided to requirement lib to avoid crash. \ No newline at end of file From 62363f1fe7021f7a8ac033a17d220b8a90c0021d Mon Sep 17 00:00:00 2001 From: Matt Davis Date: Mon, 3 Jul 2023 21:54:43 -0400 Subject: [PATCH 3/3] Rename 5765.bugfix to 5765.bugfix.rst --- news/{5765.bugfix => 5765.bugfix.rst} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename news/{5765.bugfix => 5765.bugfix.rst} (53%) diff --git a/news/5765.bugfix b/news/5765.bugfix.rst similarity index 53% rename from news/5765.bugfix rename to news/5765.bugfix.rst index e0cb622d35..06c57c4b47 100644 --- a/news/5765.bugfix +++ b/news/5765.bugfix.rst @@ -1 +1 @@ -Fixes regression on Pipfile requirements syntax. Ensure default operator is provided to requirement lib to avoid crash. \ No newline at end of file +Fixes regression on Pipfile requirements syntax. Ensure default operator is provided to requirement lib to avoid crash.