From b580a3e07dc26c613bf10b64e947f09d12d7e266 Mon Sep 17 00:00:00 2001 From: messense Date: Sun, 13 Mar 2022 19:11:25 +0800 Subject: [PATCH 1/2] Remove `PYO3_NO_PYTHON` hack --- src/compile.rs | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/src/compile.rs b/src/compile.rs index bc77b0722..33924fff5 100644 --- a/src/compile.rs +++ b/src/compile.rs @@ -1,5 +1,4 @@ use crate::build_context::BridgeModel; -use crate::python_interpreter::InterpreterKind; use crate::{BuildContext, PlatformTag, PythonInterpreter}; use anyhow::{anyhow, bail, Context, Result}; use fat_macho::FatWriter; @@ -178,7 +177,6 @@ fn compile_target( let pythonxy_lib_folder; if let BridgeModel::BindingsAbi3(_, _) = bindings_crate { - // NB: We set PYO3_NO_PYTHON further below. // On linux, we can build a shared library without the python // providing these symbols being present, on mac we can do it with // the `-undefined dynamic_lookup` we use above anyway. On windows @@ -233,17 +231,6 @@ fn compile_target( // but forwarding stderr is still useful in case there some non-json error .stderr(Stdio::inherit()); - if let BridgeModel::BindingsAbi3(_, _) = bindings_crate { - let is_pypy = python_interpreter - .map(|p| p.interpreter_kind == InterpreterKind::PyPy) - .unwrap_or(false); - if !is_pypy { - // This will make pyo3's build script only set some predefined linker - // arguments without trying to read any python configuration - build_command.env("PYO3_NO_PYTHON", "1"); - } - } - if let Some(python_interpreter) = python_interpreter { // Target python interpreter isn't runnable when cross compiling if python_interpreter.runnable { From 1313c614d845590406e9f19817cb84e73fea7b5f Mon Sep 17 00:00:00 2001 From: messense Date: Sun, 13 Mar 2022 19:16:29 +0800 Subject: [PATCH 2/2] Remove Windows abi3 linker python lib hack --- src/compile.rs | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/src/compile.rs b/src/compile.rs index 33924fff5..a3f400dcf 100644 --- a/src/compile.rs +++ b/src/compile.rs @@ -175,22 +175,6 @@ fn compile_target( rustc_args.extend(&["-C", "link-arg=-s"]); } - let pythonxy_lib_folder; - if let BridgeModel::BindingsAbi3(_, _) = bindings_crate { - // On linux, we can build a shared library without the python - // providing these symbols being present, on mac we can do it with - // the `-undefined dynamic_lookup` we use above anyway. On windows - // however, we get an exit code 0xc0000005 if we try the same with - // `/FORCE:UNDEFINED`, so we still look up the python interpreter - // and pass the location of the lib with the definitions. - if target.is_windows() { - let python_interpreter = python_interpreter - .expect("Must have a python interpreter for building abi3 on windows"); - pythonxy_lib_folder = format!("native={}", python_interpreter.libs_dir.display()); - rustc_args.extend(&["-L", &pythonxy_lib_folder]); - } - } - let cargo_args = vec!["--message-format", "json"]; let build_args: Vec<_> = cargo_args