From 873beae5672a76a0d0179f416a97775c82bcdeb2 Mon Sep 17 00:00:00 2001 From: "Gordon P. Hemsley" Date: Fri, 29 May 2020 00:01:12 -0400 Subject: [PATCH 1/3] #4278: Don't pin wildcard versions in lockfile Fixes bug introduced by 552d1274eacbd04c61f46f639bd967d294f25e6a, which activated the (unused) changes made much earlier in a08a2da52488fa31b1e74b22211f383566fef16b. --- news/4278.bugfix.rst | 1 + pipenv/utils.py | 2 +- tests/integration/test_lock.py | 13 +++++++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 news/4278.bugfix.rst diff --git a/news/4278.bugfix.rst b/news/4278.bugfix.rst new file mode 100644 index 00000000..21396490 --- /dev/null +++ b/news/4278.bugfix.rst @@ -0,0 +1 @@ +Fix a bug that caused non-specific versions to be pinned in ``Pipfile.lock``. diff --git a/pipenv/utils.py b/pipenv/utils.py index d008e761..ce1354cd 100644 --- a/pipenv/utils.py +++ b/pipenv/utils.py @@ -1191,7 +1191,7 @@ def get_locked_dep(dep, pipfile_section, prefer_pipfile=True): lockfile_name, lockfile_dict = lockfile_entry.copy().popitem() lockfile_version = lockfile_dict.get("version", "") # Keep pins from the lockfile - if prefer_pipfile and lockfile_version != version and version.startswith("=="): + if prefer_pipfile and lockfile_version != version and version.startswith("==") and "*" not in version: lockfile_dict["version"] = version lockfile_entry[lockfile_name] = lockfile_dict return lockfile_entry diff --git a/tests/integration/test_lock.py b/tests/integration/test_lock.py index 672fbedf..48232e60 100644 --- a/tests/integration/test_lock.py +++ b/tests/integration/test_lock.py @@ -748,3 +748,16 @@ def test_lock_nested_vcs_direct_url(PipenvInstance): assert "git" in p.lockfile["default"]["sibling-package"] assert "subdirectory" in p.lockfile["default"]["sibling-package"] assert "version" not in p.lockfile["default"]["sibling-package"] + + +@pytest.mark.lock +@pytest.mark.install +def test_lock_package_with_wildcard_version(PipenvInstance): + with PipenvInstance(chdir=True) as p: + c = p.pipenv("install 'six==1.11.*'") + assert c.ok + assert "six" in p.pipfile["packages"] + assert p.pipfile["packages"]["six"] == "==1.11.*" + assert "six" in p.lockfile["default"] + assert "version" in p.lockfile["default"]["six"] + assert p.lockfile["default"]["six"]["version"] == "==1.11.0" From af649b2b865db90e3c6eed91a6523a343ca3bf03 Mon Sep 17 00:00:00 2001 From: frostming Date: Fri, 29 May 2020 13:35:56 +0800 Subject: [PATCH 2/3] Fix incorrect environment when inside venv --- news/4276.bgufix.rst | 1 + pipenv/project.py | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 news/4276.bgufix.rst diff --git a/news/4276.bgufix.rst b/news/4276.bgufix.rst new file mode 100644 index 00000000..960ab08b --- /dev/null +++ b/news/4276.bgufix.rst @@ -0,0 +1 @@ +Fix a bug that system-wide packages will be considered when inside a venv. diff --git a/pipenv/project.py b/pipenv/project.py index 40b6b263..16bc715d 100644 --- a/pipenv/project.py +++ b/pipenv/project.py @@ -330,11 +330,11 @@ class Project(object): def get_environment(self, allow_global=False): # type: (bool) -> Environment - if allow_global: + is_venv = is_in_virtualenv() + if allow_global and not is_venv: prefix = sys.prefix else: prefix = self.virtualenv_location - is_venv = is_in_virtualenv() sources = self.sources if self.sources else [DEFAULT_SOURCE] environment = Environment( prefix=prefix, is_venv=is_venv, sources=sources, pipfile=self.parsed_pipfile, From 08ec79d5db261b88c5b74caab17d765181fcd29f Mon Sep 17 00:00:00 2001 From: frostming Date: Fri, 29 May 2020 13:40:50 +0800 Subject: [PATCH 3/3] fix filename --- news/{4276.bgufix.rst => 4276.bugfix.rst} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename news/{4276.bgufix.rst => 4276.bugfix.rst} (100%) diff --git a/news/4276.bgufix.rst b/news/4276.bugfix.rst similarity index 100% rename from news/4276.bgufix.rst rename to news/4276.bugfix.rst