Skip to content

Commit

Permalink
Compare minimum python version requirement between requires-python
Browse files Browse the repository at this point in the history
…and bindings crate
  • Loading branch information
messense committed Jun 6, 2022
1 parent af0252b commit 5f8edc2
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
26 changes: 22 additions & 4 deletions src/python_interpreter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -626,10 +626,28 @@ impl PythonInterpreter {
bridge: &BridgeModel,
min_python_minor: Option<usize>,
) -> Result<Vec<PythonInterpreter>> {
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 {
Expand Down
2 changes: 1 addition & 1 deletion src/templates/Cargo.toml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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 -%}
Expand Down
2 changes: 1 addition & 1 deletion src/templates/pyproject.toml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 5f8edc2

Please sign in to comment.