{"record":{"id":"7b7341ce6840f7f6","repo":"PyO3/pyo3","slug":"cannot-set-a-minimum-python-version-higher-than","errorCode":null,"errorMessage":"cannot set a minimum Python version {} higher than the interpreter version {} (the minimum Python version is implied by the abi3-py3{} feature)","messagePattern":"cannot set a minimum Python version (.+?) higher than the interpreter version (.+?) \\(the minimum Python version is implied by the abi3-py3(.+?) feature\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pyo3-build-config/src/impl_.rs","lineNumber":82,"sourceCode":"    env::var_os(var)\n}\n\n/// Gets the compilation target triple from environment variables set by Cargo.\n///\n/// Must be called from a crate build script.\npub fn target_triple_from_env() -> Triple {\n    env::var(\"TARGET\")\n        .expect(\"target_triple_from_env() must be called from a build script\")\n        .parse()\n        .expect(\"Unrecognized TARGET environment variable value\")\n}\n\nfn sanitize_stable_abi_version(\n    stable_abi_version: Option<PythonVersion>,\n    version: PythonVersion,\n) -> Result<PythonVersion> {\n    if let Some(min_version) = stable_abi_version {\n        ensure!(\n            min_version <= version,\n            \"cannot set a minimum Python version {} higher than the interpreter version {} \\\n             (the minimum Python version is implied by the abi3-py3{} feature)\",\n            min_version,\n            version,\n            min_version.minor\n        );\n        Ok(min_version)\n    } else {\n        Ok(version)\n    }\n}\n\n/// Selects which stable ABI (kind and minimum version) from the `abi3-py3*`\n/// and `abi3t-py3*` features (if any) applies to the given interpreter.\n///\n/// Interpreters which cannot target the requested stable ABI (e.g.\n/// free-threaded CPython before 3.15) get a version-specific build instead.","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/PyO3/pyo3/blob/ac9b6899d348be4d54614d060dea53a645a12e36/pyo3-build-config/src/impl_.rs#L64-L100","documentation":"When the stable ABI is in play, the abi3-py3XX feature implies a minimum supported Python version. sanitize_stable_abi_version rejects a configuration where that implied minimum exceeds the actual interpreter version being built against, because an abi3 extension cannot require a newer Python than the interpreter it links to.","triggerScenarios":"Building against, say, a 3.9 interpreter while the feature set includes abi3-py310 or higher (or a config file / PYO3_CCONFIG declares abi3 version 3.10+); PythonAbiBuilder calls sanitize_stable_abi_version(stable_abi_version, version) and ensure!(min_version <= version) fails.","commonSituations":"Cargo feature unification picks up abi3-py312 from a dependency while your local interpreter is older; CI matrix installs an older Python than the abi3-pyXXX feature declared; a PYO3_CONFIG_FILE pins an older interpreter while features demand a newer minimum.","solutions":["Lower the abi3 feature to abi3-py3XX where XX <= your interpreter's minor version, or drop abi3 features entirely","Upgrade the Python interpreter you build against to at least the abi3 minimum","Find which dependency enables the higher abi3-pyXXX feature (`cargo tree -e features`) and align versions across the workspace"],"exampleFix":"// before (python3.9 on PATH)\npyo3 = { version = \"0.22\", features = [\"abi3-py312\"] }\n// after\npyo3 = { version = \"0.22\", features = [\"abi3-py39\"] }","handlingStrategy":"validation","validationCode":"// shell\nPY=${PYO3_PYTHON:-python3}; MAJ=$($PY -c 'import sys;print(sys.version_info[0])'); MIN=$($PY -c 'import sys;print(sys.version_info[1])'); echo \"interpreter $MAJ.$MIN — ensure abi3-py3${MIN} feature <= this\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep the abi3-py3XX feature at or below the lowest interpreter in your CI matrix","Check cargo tree -e features for abi3-pyXXX leaking in from dependencies","Document the required minimum Python next to the feature declaration"],"tags":["rust","pyo3","abi3","version-mismatch","cargo-features","build-time"],"backgroundTag":"python-version-mismatch","analyzedSha":"ac9b6899d348be4d54614d060dea53a645a12e36","analyzedAt":"2026-09-05T09:20:35.319Z","contentChangedAt":"2026-09-05T09:20:35.319Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}