Skip to content

Commit e1e9ecf

Browse files
authored
Fix breakage that was almost released (#6303)
* Fix breakage that was almost released * Add test of the kind of breakage experienced
1 parent 4ac54d7 commit e1e9ecf

File tree

3 files changed

+53
-8
lines changed

3 files changed

+53
-8
lines changed

pipenv/project.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -764,7 +764,7 @@ def lockfile(self, categories=None):
764764
for category in categories:
765765
lock_section = lockfile.get(category)
766766
if lock_section is None:
767-
lockfile[category] = lock_section = {}
767+
lockfile[category] = {}
768768

769769
return lockfile
770770

pipenv/utils/locking.py

+3-7
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,8 @@ def format_requirement_for_lockfile(
6666
vcs = link.scheme.split("+", 1)[0]
6767

6868
# Get VCS URL from original deps or normalize the link URL
69-
if name in original_deps:
70-
entry[vcs] = original_deps[name]
71-
else:
72-
vcs_url, _ = normalize_vcs_url(link.url)
73-
entry[vcs] = vcs_url
69+
vcs_url, _ = normalize_vcs_url(link.url)
70+
entry[vcs] = vcs_url
7471

7572
# Handle subdirectory information
7673
if pipfile_entry.get("subdirectory"):
@@ -137,7 +134,7 @@ def get_locked_dep(project, dep, pipfile_section, current_entry=None):
137134
# initialize default values
138135
is_top_level = False
139136

140-
# # if the dependency has a name, find corresponding entry in pipfile
137+
# if the dependency has a name, find corresponding entry in pipfile
141138
if isinstance(dep, dict) and dep.get("name"):
142139
dep_name = pep423_name(dep["name"])
143140
for pipfile_key, pipfile_entry in pipfile_section.items():
@@ -183,7 +180,6 @@ def prepare_lockfile(project, results, pipfile, lockfile_section, old_lock_data=
183180
# If the current entry is a dict, merge the new details
184181
lockfile_section[dep_name].update(lockfile_entry[dep_name])
185182
lockfile_section[dep_name] = translate_markers(lockfile_section[dep_name])
186-
187183
return lockfile_section
188184

189185

tests/integration/test_install_vcs.py

+49
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,52 @@ def test_install_vcs_ref_by_commit_hash(pipenv_instance_private_pypi):
7171
)
7272
assert "six" in p.pipfile["packages"]
7373
assert "six" in p.lockfile["default"]
74+
75+
76+
@pytest.mark.vcs
77+
@pytest.mark.dev
78+
@pytest.mark.install
79+
def test_vcs_dev_package_install(pipenv_instance_pypi):
80+
"""Ensure VCS packages can be properly installed into dev-packages via --dev flag with existing Pipfile."""
81+
with pipenv_instance_pypi() as p:
82+
# Create a Pipfile with some existing packages
83+
with open(p.pipfile_path, "w") as f:
84+
contents = """
85+
[[source]]
86+
url = "https://pypi.org/simple"
87+
verify_ssl = true
88+
name = "pypi"
89+
90+
[packages]
91+
six = "*"
92+
93+
[dev-packages]
94+
pytest-xdist = {git = "https://github.com/pytest-dev/pytest-xdist.git", ref = "v3.6.1"}
95+
""".strip()
96+
f.write(contents)
97+
98+
# Install a VCS package with --dev flag
99+
c = p.pipenv("install --dev -v")
100+
assert c.returncode == 0
101+
102+
# Verify package appears in dev-packages in Pipfile
103+
assert "pytest-xdist" in p.pipfile["dev-packages"]
104+
assert p.pipfile["dev-packages"]["pytest-xdist"]["git"] == "https://github.com/pytest-dev/pytest-xdist.git"
105+
assert p.pipfile["dev-packages"]["pytest-xdist"]["ref"] == "v3.6.1"
106+
107+
# Verify package appears in develop section of lockfile
108+
assert "pytest-xdist" in p.lockfile["develop"]
109+
assert p.lockfile["develop"]["pytest-xdist"]["git"] == "git+https://github.com/pytest-dev/pytest-xdist.git"
110+
assert p.lockfile["develop"]["pytest-xdist"]["ref"] == "4dd2978031eaf7017c84a1cc77667379a2b11c64"
111+
112+
# Verify the package is importable
113+
c = p.pipenv('run python -c "import xdist"')
114+
assert c.returncode == 0
115+
116+
# Test that dependencies were also installed correctly
117+
c = p.pipenv('run python -c "import execnet"') # pytest-xdist depends on execnet
118+
assert c.returncode == 0
119+
120+
# Verify no duplicate entries in default packages
121+
assert "pytest-xdist" not in p.pipfile.get("packages", {})
122+
assert "pytest-xdist" not in p.lockfile.get("default", {})

0 commit comments

Comments
 (0)