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 a way to override the resultant Python package version #2163

Open
DavidAntliff opened this issue Jul 26, 2024 · 1 comment
Open

Add a way to override the resultant Python package version #2163

DavidAntliff opened this issue Jul 26, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@DavidAntliff
Copy link

DavidAntliff commented Jul 26, 2024

Currently, maturin build uses the project.version field from Cargo.toml to version the resultant Python package.

Using this version is not recommended by the Cargo team, as it has a specific crates.io purpose, and allegedly should not be overloaded as a general "version" number for a project: rust-lang/cargo#6583

I suggest a feature to enable override of the version number that maturin build (and maturin develop) assigns to the resultant Python package, so that alternative versioning schemes can be used.

As of today, the only way I can find to influence the Python package version seems to be to modify project.version prior to build, such as via sed in a CI script, but this does not work well for local workflows such as developer builds where a CI version number is not available. It also marks Cargo.toml as modified which can have side-effects for source control. Modifying source files is not considered proper in reproducible build environments like "yocto" or Debian package system, either, where upstream source files need to be considered authoritative.

So I suggest that there could be a new way for the environment (e.g. shell environment, or script that invokes maturin) to modify the resultant version number without modifying source files.

@DavidAntliff DavidAntliff added the enhancement New feature or request label Jul 26, 2024
@ia0
Copy link

ia0 commented Sep 20, 2024

Note also that if cargo build reads its own version (which is the case when writing a CLI with clap for the --version flag), then the workaround of editing the Cargo.toml doesn't work, because we want the crate version for the CLI but the Python library version for the Python package.

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

No branches or pull requests

2 participants