Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove PYO3_NO_PYTHON hack #847

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 0 additions & 29 deletions src/compile.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -176,23 +175,6 @@ fn compile_target(
rustc_args.extend(&["-C", "link-arg=-s"]);
}

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
// 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
Expand Down Expand Up @@ -233,17 +215,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 {
Expand Down