Skip to content

Read package metadata from pyproject.toml when statically defined#2676

Merged
charliermarsh merged 1 commit intomainfrom
charlie/pyproject
Mar 27, 2024
Merged

Read package metadata from pyproject.toml when statically defined#2676
charliermarsh merged 1 commit intomainfrom
charlie/pyproject

Conversation

@charliermarsh
Copy link
Copy Markdown
Member

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.

@charliermarsh charliermarsh added the performance Potential performance improvement label Mar 26, 2024
@charliermarsh charliermarsh force-pushed the charlie/pyproject branch 4 times, most recently from c2fed4c to adeb3e7 Compare March 26, 2024 20:57
@charliermarsh charliermarsh marked this pull request as ready for review March 26, 2024 20:57
@charliermarsh charliermarsh requested review from konstin and zanieb March 26, 2024 21:05
----- stderr -----
Resolved 8 packages in [TIME]
Downloaded 7 packages in [TIME]
Downloaded 8 packages in [TIME]
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is correct, because we no longer download flit-core during the resolution phase.

/// PEP 621 project metadata.
///
/// This is a subset of the full metadata specification, and only includes the fields that are
/// relevant for dependency resolution.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
/// relevant for dependency resolution.
/// relevant for dependency resolution.
/// See <https://packaging.python.org/en/latest/specifications/pyproject-toml>.

Comment on lines +440 to +447
let s = r#"
[project]
name = "asdf"
"#;
let meta = Metadata23::parse_pyproject_toml(s);
assert!(matches!(meta, Err(Error::FieldNotFound("version"))));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

That is even an invalid pyproject.toml ("The keys which are required but may be specified either statically or listed as dynamic are: version")

assert!(meta.provides_extras.is_empty());

let s = r#"
[project]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm pretty sure most users don't get that eliding the dependencies key means declaring that you have no deps, but that's the spec.

@charliermarsh charliermarsh enabled auto-merge (squash) March 27, 2024 14:24
@charliermarsh charliermarsh merged commit 365c292 into main Mar 27, 2024
@charliermarsh charliermarsh deleted the charlie/pyproject branch March 27, 2024 14:34
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 this pull request may close these issues.

Consider reading pyproject.toml metadata directly

2 participants