Skip to content
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

Add support for unnamed local directory requirements #2571

Merged
merged 1 commit into from
Mar 21, 2024

Conversation

charliermarsh
Copy link
Member

@charliermarsh charliermarsh commented Mar 20, 2024

Summary

For example: cargo run pip install .

The strategy taken here is to attempt to extract the package name from the distribution without executing the PEP 517 build steps. We could choose to do that in the future if this proves lacking, but it adds complexity.

Part of: #313.

@charliermarsh charliermarsh force-pushed the charlie/bare-iii branch 4 times, most recently from 77611ea to 81e1ded Compare March 20, 2024 20:15
// Attempt to read a `setup.py` from the directory.
if let Ok(setup_py) = fs_err::read_to_string(path.join("setup.py")) {
static SETUP_PY_NAME: Lazy<Regex> =
Lazy::new(|| Regex::new(r#"name\s*[=:]\s*['"](?P<name>[^'"]+)['"]"#).unwrap());
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

\cc @BurntSushi - Here I want to match setup(name="foo")-like calls.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not think frontends are supposed to use build backend–specific heuristics to retrieve metadata.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with it. These are just heuristics to support non-spec compliant requirement definitions.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not run prepare_metadata_for_build_wheel() and use the metadata from there like pip does?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't want to pay that cost here when all we need is the project name (which is far less to ask than the project metadata). I'll consider it though.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll look into how challenging it would be.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The project name is part of the Core metadata spec just like Requires-Dist or anything else, but I understand. Thanks for looking into it.

Copy link

@gotmax23 gotmax23 Mar 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, it's possible for a build backend to exist that isn't setuptools or poetry and doesn't use PEP 621 metadata.

@charliermarsh charliermarsh added the enhancement New feature or request label Mar 20, 2024
@charliermarsh charliermarsh marked this pull request as ready for review March 20, 2024 23:39
@charliermarsh charliermarsh enabled auto-merge (squash) March 21, 2024 03:40
@charliermarsh charliermarsh merged commit e5b0cf7 into main Mar 21, 2024
31 checks passed
@charliermarsh charliermarsh deleted the charlie/bare-iii branch March 21, 2024 03:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants