Skip to content

Conversation

@matteius
Copy link
Member

Summary

Fixes #6119

Problem

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 information.

Expected Result:

"namespace-library": {
    "editable": true,
    "file": "../namespace-library-file"
},
"namespace-utils": {
    "editable": true,
    "file": "../namespace-utils"
}

Actual Result (before fix):

"namespace-library": {
    "editable": true,
    "file": "../namespace-library-file"
},
"namespace-utils": {}

Root Cause

The format_requirement_for_lockfile() function in pipenv/utils/locking.py was setting entry["file"] = req.link.url for all file:// URLs. However:

  1. For local directories, we should use path (with a relative path) instead of file (with a URL)
  2. The version and index entries should be removed for file/path dependencies
  3. The editable flag should be preserved

Solution

This fix:

  • Differentiates between local directories (use path) and archive files (use file) for file:// URLs using req.link.is_existing_dir()
  • Converts file:// URLs to relative paths for local directories using ensure_path_is_relative()
  • Removes version and index entries for file/path dependencies
  • Preserves the editable flag if set on the requirement

Testing

To test this fix, you can use the reproduction repository from the issue:

git clone https://github.com/AlexandreArpin/pipenv-repro
cd pipenv-repro/my-app-file-dep
pipenv lock
cat Pipfile.lock  # namespace-utils should now have path info

Pull Request opened by Augment Code with guidance from the PR author

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

File located Dependencies of Packages (sub-dependency) can't be installed with Pipenv

2 participants