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

Consider reading pyproject.toml metadata directly #2629

Closed
charliermarsh opened this issue Mar 22, 2024 · 5 comments · Fixed by #2676
Closed

Consider reading pyproject.toml metadata directly #2629

charliermarsh opened this issue Mar 22, 2024 · 5 comments · Fixed by #2676
Assignees
Labels
performance Potential performance improvement

Comments

@charliermarsh
Copy link
Member

According to the spec:

A build back-end MUST honour statically-specified metadata (which means the metadata did not list the key in dynamic).

In other words, if a field is defined in the [project] section, and not declared as dynamic, the spec suggests it must be used... verbatim? I think? So in theory we could read the metadata directly without executing any PEP 517 hooks.

This would not work for Hatch projects that rely on context formatting: pypa/hatch#1331

@charliermarsh
Copy link
Member Author

Yes, I believe this should work per Paul Moore's comment here: pypa/pip#11440 (comment)

@charliermarsh charliermarsh added the performance Potential performance improvement label Mar 22, 2024
@charliermarsh
Copy link
Member Author

This could be a nice optimization for resolution.

@hauntsaninja
Copy link
Contributor

I've had a similar PR lying around for pip-compile for a while: jazzband/pip-tools#1964

@charliermarsh charliermarsh self-assigned this Mar 23, 2024
@bluss
Copy link
Contributor

bluss commented Mar 23, 2024

Sorry if this is too tangential, but in my reading environment variables are not part of dependency specs (only requirements files) - thus ${PROJECT_ROOT} usage could also be a problem here, which is another case?

Example https://pdm-project.org/latest/usage/dependency/#local-dependencies

@charliermarsh
Copy link
Member Author

My impression is that those usages are not spec compliant. But they do exist in the wild, so we'll have to detect them and skip the optimization in that case.

charliermarsh added a commit that referenced this issue Mar 27, 2024
…2676)

## Summary

Now that we're resolving metadata more aggressively for local sources,
it's worth doing this. We now pull metadata from the `pyproject.toml`
directly if it's statically-defined.

Closes #2629.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Potential performance improvement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants