-
Notifications
You must be signed in to change notification settings - Fork 770
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
Specifying the minimum supported python version #1195
Comments
Is it possible to use metadata from the package itself in pyo3's build.rs? Even if it is I'm not enthusiastic about doing that. OTOH Maturin could definitely check the cargo metadata, and setuptools-rust the I wonder if we can add macros like rustversion ? |
I think the combination of feature flags (for build scripts) + toml config (for maturin or setuptools) is good, though we have to invert
We already have |
|
I checked that only setting the cfg's in build.rs works nicely with abi3. I've just checked with this hacky snippet: fn main() -> Result<()> {
if env::var_os("CARGO_FEATURE_ABI3").is_some() {
let msg = r#"cargo:rustc-cfg=Py_3_5
cargo:rustc-cfg=Py_3_6
cargo:rustc-cfg=Py_3_7
cargo:rustc-cfg=Py_3
cargo:rustc-cfg=py_sys_config="WITH_THREAD"
cargo:python_flags=FLAG_WITH_THREAD=1,CFG_Py_3_5,CFG_Py_3_6,CFG_Py_3_7"#;
println!("{}", msg);
return Ok(());
} The really cool part about this is that the targeted python version doesn't need to be installed on the build machine anymore, which means e.g. faster and easier CI. I also realized that one big disadvantage of the toml solutions would be that we would need to add a toml parser as build dependency. |
I'm not sure I understand the question. Can you try rephrasing it? |
Ah, sorrry, but I noticed that my original question meant nothing so please ignore it. |
You mean we can build |
Being able to build an ABI3 wheel which targets a lower ABI than the Python you're building with would be cool. (e.g. Using Python 3.8 to build an abi3 wheel with 3.5 as the minimum version) However, it's not a hard requirement for me. Not sure what the best API for it would be. |
Even better, with abi3 you should be able to build without any python version present! That's what I tried to do with the snippet I posted above, where I only set rust config and don't read or link any python. |
Thank you @kngwyu and @davidhewitt for all the help and work!
As a follow-up, on linux/mac you can build now without any python version, while on windows you need a python interpreter for linking with its python3.lib, where the python version shouldn't matter. |
Currently, there is no way to specify minimal supported python version, and compiling against a too low version or fail with an error about missing symbols (or worse, at runtime due to some failed import). With maturin, I'd like to build abi3 wheels for the lowest supported python version, so there's only one wheel and that supports all versions. I'm currently thinking about how to best specify this. Ideally, pyo3's build script or at least setuptools-rust should also check for this version and exit with an understandable error message about the wrong python version (I can write the pull request).
I currently have three different ideas:
python-requires
when PEP 621 is accepted.py36-abi3
,py37-abi3
, etc. features@kngwyu @davidhewitt What do you think?
The text was updated successfully, but these errors were encountered: