From 7690671ea1e9be18d5a0d78abe3c401079e8e29c Mon Sep 17 00:00:00 2001 From: Daniel Simon Date: Thu, 18 Oct 2018 18:30:52 +0200 Subject: [PATCH 1/4] Fix _pyversion if include dir contains other files --- pipenv/project.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pipenv/project.py b/pipenv/project.py index a3e31bfd..c2dc9668 100644 --- a/pipenv/project.py +++ b/pipenv/project.py @@ -926,8 +926,8 @@ class Project(object): @property def _pyversion(self): include_dir = vistir.compat.Path(self.virtualenv_location) / "include" - python_path = next(iter(list(include_dir.iterdir())), None) - if python_path and python_path.name.startswith("python"): + python_path = next((x for x in include_dir.iterdir() if x.name.startswith("python")), None) + if python_path: python_version = python_path.name.replace("python", "") py_version_short, abiflags = python_version[:3], python_version[3:] return {"py_version_short": py_version_short, "abiflags": abiflags} From 14eef87c0d27ea75956598e3cd36a6a6cb181348 Mon Sep 17 00:00:00 2001 From: jxltom Date: Sun, 21 Oct 2018 12:53:08 +0800 Subject: [PATCH 2/4] Do not add extra to markers when translating markers --- pipenv/utils.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pipenv/utils.py b/pipenv/utils.py index b9345afa..b965e46d 100644 --- a/pipenv/utils.py +++ b/pipenv/utils.py @@ -1182,7 +1182,9 @@ def translate_markers(pipfile_entry): new_pipfile = dict(pipfile_entry).copy() marker_set = set() if "markers" in new_pipfile: - marker_set.add(str(Marker(new_pipfile.get("markers")))) + marker = str(Marker(new_pipfile.pop("markers"))) + if 'extra' not in marker: + marker_set.add(marker) for m in pipfile_markers: entry = "{0}".format(pipfile_entry[m]) if m != "markers": From 91a63e07e2efe255e8094b38f4d30096de3d55c4 Mon Sep 17 00:00:00 2001 From: jxltom Date: Sun, 21 Oct 2018 12:53:33 +0800 Subject: [PATCH 3/4] Add test on locking package with extras --- tests/integration/test_lock.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/integration/test_lock.py b/tests/integration/test_lock.py index ac296476..1f1719d0 100644 --- a/tests/integration/test_lock.py +++ b/tests/integration/test_lock.py @@ -167,6 +167,28 @@ maya = "*" assert c.return_code == 0 +@pytest.mark.extras +@pytest.mark.lock +def test_lock_extras_without_install(PipenvInstance, pypi): + with PipenvInstance(pypi=pypi) as p: + with open(p.pipfile_path, 'w') as f: + contents = """ +[packages] +requests = {version = "*", extras = ["socks"]} + """.strip() + f.write(contents) + + c = p.pipenv('lock') + assert c.return_code == 0 + assert "requests" in p.lockfile["default"] + assert "pysocks" in p.lockfile["default"] + assert "markers" not in p.lockfile["default"]['pysocks'] + + c = p.pipenv('lock -r') + assert c.return_code == 0 + assert "extra == 'socks'" not in c.out.strip() + + @pytest.mark.extras @pytest.mark.lock @pytest.mark.complex From 7b3493bb611923e339c3cac8ae34c511a3773455 Mon Sep 17 00:00:00 2001 From: jxltom Date: Sun, 21 Oct 2018 12:56:50 +0800 Subject: [PATCH 4/4] Add fixed 3026 in news --- news/3026.bugfix | 1 + 1 file changed, 1 insertion(+) create mode 100644 news/3026.bugfix diff --git a/news/3026.bugfix b/news/3026.bugfix new file mode 100644 index 00000000..6a194d1f --- /dev/null +++ b/news/3026.bugfix @@ -0,0 +1 @@ +Fixed unnecessary extras are added when translating markers