Skip to content

Commit be16846

Browse files
committed
Fix local file sub-dependencies not being recorded in lockfile
When a package (A) installed from a local path depends on another package (B) also installed from a local path, the sub-dependency (B) was not being properly recorded in Pipfile.lock. The lockfile entry for B would be empty ({}) instead of containing the file/path info. This fix: - Differentiates between local directories (use 'path') and archive files (use 'file') for file:// URLs - Converts file:// URLs to relative paths for local directories - Removes version and index entries for file/path dependencies - Preserves the editable flag if set Fixes #6119
1 parent 9411b68 commit be16846

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

pipenv/utils/locking.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,24 @@ def format_requirement_for_lockfile(
8686
elif req.specifier:
8787
entry["version"] = str(req.specifier)
8888
if req.link and req.link.is_file:
89-
entry["file"] = req.link.url
89+
# For local file/directory dependencies, use 'path' for directories
90+
# and 'file' for archives. Convert file:// URLs to relative paths.
91+
# This handles sub-dependencies that are local packages.
92+
# See: https://github.com/pypa/pipenv/issues/6119
93+
if req.link.is_existing_dir():
94+
# Local directory - use 'path' with relative path
95+
from pipenv.utils.dependencies import ensure_path_is_relative
96+
97+
entry["path"] = ensure_path_is_relative(req.link.file_path)
98+
else:
99+
# Archive file - use 'file' with URL
100+
entry["file"] = req.link.url
101+
# For file/path dependencies, remove version and index
102+
entry.pop("version", None)
103+
entry.pop("index", None)
104+
# Preserve editable flag if set
105+
if req.editable:
106+
entry["editable"] = True
90107
# Add index information
91108
if name in index_lookup:
92109
entry["index"] = index_lookup[name]

0 commit comments

Comments
 (0)