Skip to content

Commit

Permalink
Merge pull request pypa#6136 from AlexandreArpin/hotfix/nested-vcs-de…
Browse files Browse the repository at this point in the history
…pendency-lock

Add nested vcs dependency subdirectory when locking to Pipfile.lock (Fix pypa#6120)
  • Loading branch information
matteius authored Apr 23, 2024
2 parents ba7584d + 0bdb85d commit 584e917
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions news/6136.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix a bug that vcs subdependencies were locked without their subdirectory fragment if they had one
10 changes: 9 additions & 1 deletion pipenv/utils/locking.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
clean_resolved_dep,
determine_vcs_revision_hash,
expansive_install_req_from_line,
normalize_vcs_url,
pep423_name,
translate_markers,
)
Expand Down Expand Up @@ -61,9 +62,16 @@ def format_requirement_for_lockfile(
if req.link and req.link.is_vcs:
vcs = req.link.scheme.split("+", 1)[0]
entry["ref"] = determine_vcs_revision_hash(req, vcs, pipfile_entry.get("ref"))
entry[vcs] = original_deps.get(name, req.link.url)

if name in original_deps:
entry[vcs] = original_deps[name]
else:
vcs_url, _ = normalize_vcs_url(req.link.url)
entry[vcs] = vcs_url
if pipfile_entry.get("subdirectory"):
entry["subdirectory"] = pipfile_entry["subdirectory"]
elif req.link.subdirectory_fragment:
entry["subdirectory"] = req.link.subdirectory_fragment
if req.req:
entry["version"] = str(req.specifier)
elif version:
Expand Down
3 changes: 2 additions & 1 deletion tests/integration/test_lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,8 @@ def test_lock_nested_vcs_direct_url(pipenv_instance_pypi):
assert "git" in p.lockfile["default"]["pep508-package"]
assert "sibling-package" in p.lockfile["default"]
assert "git" in p.lockfile["default"]["sibling-package"]
assert "subdirectory" in p.lockfile["default"]["sibling-package"]["git"]
assert "subdirectory" in p.lockfile["default"]["sibling-package"]
assert p.lockfile["default"]["sibling-package"]["subdirectory"] == "parent_folder/sibling_package"
assert "version" not in p.lockfile["default"]["sibling-package"]


Expand Down

0 comments on commit 584e917

Please sign in to comment.