Skip to content

Fix derivation of local package names in Pipfile #6411

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

stewartmiles
Copy link
Contributor

Fixes #6409

Thank you for contributing to Pipenv!

The issue

Fixes #6409

The fix

Iterates parent directories searching for package metadata files (e.g setup.py etc.) before leaf directories within a package.

@stewartmiles
Copy link
Contributor Author

It looks like a load of tests failed in https://github.com/pypa/pipenv/actions/runs/15193270143/job/42735598641 . I wasn't able to run all tests successfully locally either with or without this patch. Is this expected?

@matteius
Copy link
Member

Thank you @stewartmiles for taking a look at this issue -- the determine package name logic was some one off stuff that was partly my work around and partly early Claude/Chat GPT help when I was working the conversion off requirementslib -- the prior code in requirements lib was very hard to follow how it arrived at the package name for these local file cases. There has to be a better way.

@stewartmiles
Copy link
Contributor Author

@matteius AFAIK when installing a local package from a folder it's possible to get the name using the same approach as pip / requirementslib, i.e using the new PEP-517 equivalent of the egg_info setuptools command to build the package metadata and the read the name from that but unfortunately the hook to get package metadata is optional.

A more expensive, though simple alternative is to build a wheel with pip and extract the package information using the build wheel hook in PEP-517. Here's an example using pip's command line interface, using the package attached to #6409 doing something like this:

# Build a wheel into mypackage_build
pip wheel --no-deps ./mypackage -w mypackage_build
# Read the name from the package metadata.
unzip -p mypackage_build/* *METADATA | awk '$1 ~ /Name:/ { print $2 }'

which prints mypackage

@matteius
Copy link
Member

@stewartmiles Can you take a look at: https://github.com/pypa/pipenv/pull/6413/files

I basically fed the patch file of this PR, the issue report and comments, and the test failures into Augment to correct for the edge cases, and I appear to be getting a passing build.

@stewartmiles stewartmiles deleted the fix_local_package_name_derivation branch June 4, 2025 21:43
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.

Installing an editable package can result in using the wrong canonical package name in Pipfile
2 participants