Skip to content

Commit 4a3df46

Browse files
authored
fix: fall back to placeholder for abi3 when found interpreters are too old (#3126)
When the only Python interpreter on PATH is older than the abi3 minimum version and the user didn't explicitly specify interpreters via -i, fall back to a placeholder interpreter instead of erroring. This fixes builds in manylinux containers where the system Python is older than the abi3 minimum (e.g. cp38 with abi3-py39).
1 parent e8ebb2f commit 4a3df46

1 file changed

Lines changed: 20 additions & 2 deletions

File tree

src/python_interpreter/resolver.rs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -628,8 +628,26 @@ impl<'a> InterpreterResolver<'a> {
628628
}
629629

630630
if !candidates.is_empty() {
631-
Self::print_found_candidates(&candidates);
632-
Ok(Self::candidates_to_interpreters(candidates))
631+
// Check if any candidate meets the abi3 minimum version.
632+
// If none do and the user didn't explicitly request interpreters,
633+
// fall back to a placeholder so the build can proceed without a
634+
// compatible interpreter on PATH (e.g. manylinux containers where
635+
// the system Python is older than the abi3 minimum).
636+
let has_compatible = candidates.iter().any(|c| {
637+
c.interpreter.has_stable_api()
638+
&& (c.interpreter.major as u8, c.interpreter.minor as u8) >= (major, minor)
639+
});
640+
if has_compatible || !self.user_interpreters.is_empty() {
641+
Self::print_found_candidates(&candidates);
642+
Ok(Self::candidates_to_interpreters(candidates))
643+
} else {
644+
eprintln!("🐍 Not using a specific python interpreter");
645+
Ok(vec![PythonInterpreter::placeholder(
646+
major as usize,
647+
minor as usize,
648+
self.target,
649+
)])
650+
}
633651
} else if self.user_interpreters.is_empty() {
634652
eprintln!("🐍 Not using a specific python interpreter");
635653
Ok(vec![PythonInterpreter::placeholder(

0 commit comments

Comments
 (0)