|
1 | 1 | use crate::build_context::{BridgeModel, ProjectLayout};
|
| 2 | +use crate::python_interpreter::InterpreterKind; |
2 | 3 | use crate::BuildContext;
|
3 | 4 | use crate::CargoToml;
|
4 | 5 | use crate::Manylinux;
|
@@ -384,15 +385,36 @@ pub fn find_interpreter(
|
384 | 385 | Ok(vec![interpreter])
|
385 | 386 | }
|
386 | 387 | BridgeModel::Bin => Ok(vec![]),
|
387 |
| - BridgeModel::BindingsAbi3(_, _) => { |
| 388 | + BridgeModel::BindingsAbi3(major, minor) => { |
388 | 389 | // Ideally, we wouldn't want to use any python interpreter without abi3 at all.
|
389 | 390 | // Unfortunately, on windows we need one to figure out base_prefix for a linker
|
390 | 391 | // argument.
|
391 | 392 | if target.is_windows() {
|
392 |
| - let interpreter = |
393 |
| - find_single_python_interpreter(bridge, interpreter, target, "abi3 on windows")?; |
394 |
| - println!("🐍 Using {} to generate to link bindings (With abi3, an interpreter is only required on windows)", interpreter); |
395 |
| - Ok(vec![interpreter]) |
| 393 | + if let Some(manual_base_prefix) = std::env::var_os("PYO3_CROSS_LIB_DIR") { |
| 394 | + // PYO3_CROSS_LIB_DIR equals base_prefix when cross compiling, |
| 395 | + // so we fake a python interpreter matching it |
| 396 | + println!("⚠ Cross-compiling is poorly supported"); |
| 397 | + Ok(vec![PythonInterpreter { |
| 398 | + major: *major as usize, |
| 399 | + minor: *minor as usize, |
| 400 | + abiflags: "".to_string(), |
| 401 | + target: target.clone(), |
| 402 | + executable: PathBuf::new(), |
| 403 | + ext_suffix: Some(".pyd".to_string()), |
| 404 | + interpreter_kind: InterpreterKind::CPython, |
| 405 | + abi_tag: None, |
| 406 | + base_prefix: PathBuf::from(manual_base_prefix), |
| 407 | + }]) |
| 408 | + } else { |
| 409 | + let interpreter = find_single_python_interpreter( |
| 410 | + bridge, |
| 411 | + interpreter, |
| 412 | + target, |
| 413 | + "abi3 on windows", |
| 414 | + )?; |
| 415 | + println!("🐍 Using {} to generate to link bindings (With abi3, an interpreter is only required on windows)", interpreter); |
| 416 | + Ok(vec![interpreter]) |
| 417 | + } |
396 | 418 | } else {
|
397 | 419 | println!("🐍 Not using a specific python interpreter (With abi3, an interpreter is only required on windows)");
|
398 | 420 | Ok(vec![])
|
|
0 commit comments