diff --git a/Changelog.md b/Changelog.md index 121e5fb43..157bbae23 100644 --- a/Changelog.md +++ b/Changelog.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * **Breaking Change**: Drop support for python 3.6, which is end of life * Fix incompatibility with cibuildwheel for 32-bit Windows in [#951](https://github.com/PyO3/maturin/pull/951) * Don't require `pip` error messages to be utf-8 encoding in [#953](https://github.com/PyO3/maturin/pull/953) +* Compare minimum python version requirement between `requires-python` and bindings crate in [#954](https://github.com/PyO3/maturin/pull/954) ## [0.12.19] - 2022-06-05 diff --git a/src/python_interpreter/mod.rs b/src/python_interpreter/mod.rs index 0bd0916a1..e772a9fa1 100644 --- a/src/python_interpreter/mod.rs +++ b/src/python_interpreter/mod.rs @@ -626,10 +626,28 @@ impl PythonInterpreter { bridge: &BridgeModel, min_python_minor: Option, ) -> Result> { - let min_python_minor = min_python_minor.unwrap_or(match bridge { - BridgeModel::Bindings(_, minor) => *minor, - _ => MINIMUM_PYTHON_MINOR, - }); + let min_python_minor = match min_python_minor { + Some(requires_python_minor) => match bridge { + BridgeModel::Bindings(bridge_name, minor) + | BridgeModel::Bin(Some((bridge_name, minor))) => { + // requires-python minor version might be lower than bridge crate required minor version + if requires_python_minor >= *minor { + requires_python_minor + } else { + eprintln!( + "⚠️ Warning: 'requires-python' (3.{}) is lower than the requirement of {} crate (3.{}).", + requires_python_minor, bridge_name, *minor + ); + *minor + } + } + _ => requires_python_minor, + }, + None => match bridge { + BridgeModel::Bindings(_, minor) | BridgeModel::Bin(Some((_, minor))) => *minor, + _ => MINIMUM_PYTHON_MINOR, + }, + }; let executables = if target.is_windows() { find_all_windows(target, min_python_minor)? } else { diff --git a/src/templates/Cargo.toml.j2 b/src/templates/Cargo.toml.j2 index 369be4c16..86c240aef 100644 --- a/src/templates/Cargo.toml.j2 +++ b/src/templates/Cargo.toml.j2 @@ -13,7 +13,7 @@ crate-type = ["cdylib"] [dependencies] {%- if bindings == "pyo3" -%} -pyo3 = { version = "0.16.3", features = ["extension-module"] } +pyo3 = { version = "0.16.5", features = ["extension-module"] } {%- elif bindings == "rust-cpython" -%} cpython = { version = "0.7.0", features = ["extension-module"] } {%- endif -%} diff --git a/src/templates/pyproject.toml.j2 b/src/templates/pyproject.toml.j2 index d955a5e0d..4664e50eb 100644 --- a/src/templates/pyproject.toml.j2 +++ b/src/templates/pyproject.toml.j2 @@ -4,7 +4,7 @@ build-backend = "maturin" [project] name = "{{ name }}" -requires-python = ">=3.6" +requires-python = ">=3.7" classifiers = [ "Programming Language :: Rust", "Programming Language :: Python :: Implementation :: CPython",