Skip to content

Commit

Permalink
Add nested vcs dependency subdirectory when locking to Pipfile.lock
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexandreArpin committed Apr 22, 2024
1 parent ba7584d commit 60a7c83
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
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 60a7c83

Please sign in to comment.