Skip to content

Commit

Permalink
Merge pull request #3070 from jxltom/fixed-unnecessary-extras-are-add…
Browse files Browse the repository at this point in the history
…ed-in-lockfiles

Fixed unnecessary extras are added in lockfiles
  • Loading branch information
techalchemy authored Oct 21, 2018
2 parents 1960934 + 7b3493b commit ab30481
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
1 change: 1 addition & 0 deletions news/3026.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed unnecessary extras are added when translating markers
4 changes: 3 additions & 1 deletion pipenv/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down
22 changes: 22 additions & 0 deletions tests/integration/test_lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,28 @@ def test_complex_deps_lock_and_install_properly(PipenvInstance, pip_src_dir, pyp
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
Expand Down

0 comments on commit ab30481

Please sign in to comment.