Skip to content

Commit

Permalink
Use PYO3_CROSS_LIB_DIR as libs dir for #375
Browse files Browse the repository at this point in the history
  • Loading branch information
konstin committed Jan 15, 2021
1 parent cbf3c93 commit 5dce1cb
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ There are three main commands:

`pyo3` and `rust-cpython` bindings are automatically detected, for cffi or binaries you need to pass `-b cffi` or `-b bin`. maturin doesn't need extra configuration files and doesn't clash with an existing setuptools-rust or milksnake configuration. You can even integrate it with testing tools such as [tox](https://tox.readthedocs.io/en/latest/). There are examples for the different bindings in the `test-crates` folder.

The name of the package will be the name of the cargo project, i.e. the name field in the `[package]` section of Cargo.toml. The name of the module, which you are using when importing, will be the `name` value in the `[lib]` section (which defaults to the name of the package). For binaries it's simply the name of the binary generated by cargo.
The name of the package will be the name of the cargo project, i.e. the name field in the `[package]` section of Cargo.toml. The name of the module, which you are using when importing, will be the `name` value in the `[lib]` section (which defaults to the name of the package). For binaries, it's simply the name of the binary generated by cargo.

## Python packaging basics

Expand Down
6 changes: 3 additions & 3 deletions src/build_options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -391,8 +391,8 @@ pub fn find_interpreter(
// argument.
if target.is_windows() {
if let Some(manual_base_prefix) = std::env::var_os("PYO3_CROSS_LIB_DIR") {
// PYO3_CROSS_LIB_DIR equals base_prefix when cross compiling,
// so we fake a python interpreter matching it
// PYO3_CROSS_LIB_DIR should point to the `libs` directory inside base_prefix
// when cross compiling, so we fake a python interpreter matching it
println!("⚠ Cross-compiling is poorly supported");
Ok(vec![PythonInterpreter {
major: *major as usize,
Expand All @@ -403,7 +403,7 @@ pub fn find_interpreter(
ext_suffix: Some(".pyd".to_string()),
interpreter_kind: InterpreterKind::CPython,
abi_tag: None,
base_prefix: PathBuf::from(manual_base_prefix),
libs_dir: PathBuf::from(manual_base_prefix),
}])
} else {
let interpreter = find_single_python_interpreter(
Expand Down
3 changes: 1 addition & 2 deletions src/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ pub fn compile(
if context.target.is_windows() {
let python_interpreter = python_interpreter
.expect("Must have a python interpreter for building abi3 on windows");
pythonxy_lib_folder =
format!("native={}\\libs", python_interpreter.base_prefix.display());
pythonxy_lib_folder = format!("native={}", python_interpreter.libs_dir.display());
rustc_args.extend(&["-L", &pythonxy_lib_folder]);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/python_interpreter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ pub struct PythonInterpreter {
/// Note that this always `None` on windows
pub abi_tag: Option<String>,
/// We need this value for windows abi3 linking
pub base_prefix: PathBuf,
pub libs_dir: PathBuf,
}

/// Returns the abiflags that are assembled through the message, with some
Expand Down Expand Up @@ -535,7 +535,7 @@ impl PythonInterpreter {
ext_suffix: message.ext_suffix,
interpreter_kind: interpreter,
abi_tag: message.abi_tag,
base_prefix: PathBuf::from(message.base_prefix),
libs_dir: PathBuf::from(message.base_prefix).join("libs"),
}))
}

Expand Down
2 changes: 1 addition & 1 deletion test-crates/pyo3-pure/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ edition = "2018"
get_42 = "pyo3_pure:DummyClass.get_42"

[dependencies]
pyo3 = { version ="0.13.1", features = ["abi3-py36", "extension-module"] }
pyo3 = { version = "0.13.1", features = ["abi3-py36", "extension-module"] }

[lib]
name = "pyo3_pure"
Expand Down

0 comments on commit 5dce1cb

Please sign in to comment.