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

Build should error if pyproject.toml does not contain (dynamic) version #2390

Closed
2 tasks done
stinodego opened this issue Dec 18, 2024 · 0 comments · Fixed by #2391
Closed
2 tasks done

Build should error if pyproject.toml does not contain (dynamic) version #2390

stinodego opened this issue Dec 18, 2024 · 0 comments · Fixed by #2391
Labels
bug Something isn't working

Comments

@stinodego
Copy link

stinodego commented Dec 18, 2024

Bug Description

Currently, maturin will fill in the version specifier if it is missing from pyproject.toml (it is available in Cargo.toml). However, this is prohibited in the official spec:
https://packaging.python.org/en/latest/specifications/pyproject-toml/#dynamic

If the metadata does not list a key in dynamic, then a build back-end CANNOT fill in the requisite metadata on behalf of the user

So rather than filling in the version, maturin should error and tell the user to add dynamic = ["version"] to their pyproject.toml.

This came up because uv is now enforcing this, and won't install any packages with a missing version specifier in the metadata: astral-sh/uv#9989

Your maturin version (maturin --version)

maturin 1.7.4

Your Python version (python -V)

Python 3.12.2

Your pip version (pip -V)

pip 24.3.1

What bindings you're using

pyo3

Does cargo build work?

  • Yes, it works

If on windows, have you checked that you aren't accidentally using unix path (those with the forward slash /)?

  • Yes

Steps to Reproduce

You can just go to the official docs:
https://www.maturin.rs/metadata

If you remove the version specifier in the pyproject.toml metadata, it will take the version from the Cargo.toml. This works, but it shouldn't!

@stinodego stinodego added the bug Something isn't working label Dec 18, 2024
exg added a commit to exg/ormsgpack that referenced this issue Dec 26, 2024
See PyO3/maturin#2390

Signed-off-by: Emanuele Giaquinta <[email protected]>
exg added a commit to aviramha/ormsgpack that referenced this issue Dec 26, 2024
See PyO3/maturin#2390

Signed-off-by: Emanuele Giaquinta <[email protected]>
heirecka added a commit to heirecka/jellyfish that referenced this issue Dec 28, 2024
maturin >= 1.8.0 stopped filling the version from Cargo.toml, because
the spec only allows this, when the metadata key is listed in
`dynamic` [1][2].

Fixes jamesturk#224.

[1] https://packaging.python.org/en/latest/specifications/pyproject-toml/#dynamic
[2] PyO3/maturin#2390
warthog9 added a commit to warthog9/luwen that referenced this issue Dec 30, 2024
Maturin made a change to come inline more specifically with
pyproject.toml spec, unfortunately it's not a "backwards compatible"
change and was done with little fanfare or warning, and immediately
caused breakage outside distro's more plodding versions.

Maturin Issue: PyO3/maturin#2390
pyproject.toml spec: https://packaging.python.org/en/latest/specifications/pyproject-toml/#dynamic

change in Maturin committed here:

PyO3/maturin#2391

This commit superceeds the luwen PR here:

tenstorrent#11

as that sets an explicit version, and we don't want that as it adds more
sources of truth on the version (seriously there should be 1, and only
1).

Signed-off-by: John 'Warthog9' Hawley <[email protected]>
simu added a commit to projectsyn/reclass-rs that referenced this issue Dec 30, 2024
We need to set `dynamic = ["version"]` in `pyproject.toml`, since the
spec requires that required fields must be listed in `dynamic` if
they're to be provided by the build backend (maturin for us).

See PyO3/maturin#2390 for the maturin issue
to adhere to the spec.
warthog9 added a commit to warthog9/luwen that referenced this issue Dec 30, 2024
Maturin made a change to come inline more specifically with
pyproject.toml spec, unfortunately it's not a "backwards compatible"
change and was done with little fanfare or warning, and immediately
caused breakage outside distro's more plodding versions.

Maturin Issue: PyO3/maturin#2390
pyproject.toml spec: https://packaging.python.org/en/latest/specifications/pyproject-toml/#dynamic

change in Maturin committed here:

PyO3/maturin#2391

This commit superceeds the luwen PR here:

tenstorrent#11

as that sets an explicit version, and we don't want that as it adds more
sources of truth on the version (seriously there should be 1, and only
1).

Reported-by: Dongjin Na <[email protected]>
Signed-off-by: John 'Warthog9' Hawley <[email protected]>
Dr-Emann added a commit to Dr-Emann/rbloom that referenced this issue Dec 31, 2024
Maturin will populate the project version, but we should mark that in the
pyproject.toml as a dynamic field.

See PyO3/maturin#2390
jamesturk pushed a commit to jamesturk/jellyfish that referenced this issue Dec 31, 2024
maturin >= 1.8.0 stopped filling the version from Cargo.toml, because
the spec only allows this, when the metadata key is listed in
`dynamic` [1][2].

Fixes #224.

[1] https://packaging.python.org/en/latest/specifications/pyproject-toml/#dynamic
[2] PyO3/maturin#2390
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant