apply symlink use case, change variable name
This commit is contained in:
parent
455ec80a98
commit
441d7f52b1
11
build.rs
11
build.rs
|
@ -126,7 +126,7 @@ impl CrossCompileConfig {
|
||||||
include_dir: None,
|
include_dir: None,
|
||||||
os: env::var("CARGO_CFG_TARGET_OS").unwrap(),
|
os: env::var("CARGO_CFG_TARGET_OS").unwrap(),
|
||||||
arch: env::var("CARGO_CFG_TARGET_ARCH").unwrap(),
|
arch: env::var("CARGO_CFG_TARGET_ARCH").unwrap(),
|
||||||
version: env::var_os("PYO3_PYTHON_VERSION").map(|s| s.into_string().unwrap()),
|
version: env::var_os("PYO3_CROSS_PYTHON_VERSION").map(|s| s.into_string().unwrap()),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -296,7 +296,12 @@ fn ends_with(entry: &DirEntry, pat: &str) -> bool {
|
||||||
///
|
///
|
||||||
/// [1]: https://github.com/python/cpython/blob/3.5/Lib/sysconfig.py#L389
|
/// [1]: https://github.com/python/cpython/blob/3.5/Lib/sysconfig.py#L389
|
||||||
fn find_sysconfigdata(cross: &CrossCompileConfig) -> Result<PathBuf> {
|
fn find_sysconfigdata(cross: &CrossCompileConfig) -> Result<PathBuf> {
|
||||||
let mut sysconfig_paths = search_lib_dir(&cross.lib_dir, &cross);
|
let sysconfig_paths = search_lib_dir(&cross.lib_dir, &cross);
|
||||||
|
let mut sysconfig_paths = sysconfig_paths
|
||||||
|
.iter()
|
||||||
|
.filter_map(|p| fs::canonicalize(p).ok())
|
||||||
|
.collect::<Vec<PathBuf>>();
|
||||||
|
sysconfig_paths.dedup();
|
||||||
if sysconfig_paths.is_empty() {
|
if sysconfig_paths.is_empty() {
|
||||||
bail!(
|
bail!(
|
||||||
"Could not find either libpython.so or _sysconfigdata*.py in {}",
|
"Could not find either libpython.so or _sysconfigdata*.py in {}",
|
||||||
|
@ -378,7 +383,7 @@ fn load_cross_compile_from_sysconfigdata(
|
||||||
|
|
||||||
let interpreter_config = InterpreterConfig {
|
let interpreter_config = InterpreterConfig {
|
||||||
version: python_version,
|
version: python_version,
|
||||||
libdir: python_paths.lib_dir.to_str().map(String::from), //libpython_path.to_str().map(String::from),
|
libdir: python_paths.lib_dir.to_str().map(String::from),
|
||||||
shared,
|
shared,
|
||||||
ld_version,
|
ld_version,
|
||||||
base_prefix: "".to_string(),
|
base_prefix: "".to_string(),
|
||||||
|
|
|
@ -54,7 +54,7 @@ After you've obtained the above, you can build a cross compiled PyO3 module by s
|
||||||
|
|
||||||
* `PYO3_CROSS_INCLUDE_DIR`: This variable must be set to the directory containing the headers for the target's Python interpreter. **It is only necessary if targeting Windows platforms**
|
* `PYO3_CROSS_INCLUDE_DIR`: This variable must be set to the directory containing the headers for the target's Python interpreter. **It is only necessary if targeting Windows platforms**
|
||||||
* `PYO3_CROSS_LIB_DIR`: This variable must be set to the directory containing the target's libpython DSO and the associated `_sysconfigdata*.py` file.
|
* `PYO3_CROSS_LIB_DIR`: This variable must be set to the directory containing the target's libpython DSO and the associated `_sysconfigdata*.py` file.
|
||||||
* `PYO3_PYTHON_VERSION`: This variable must be set if there are multiple versions of python compiled for a unix machine.
|
* `PYO3_CROSS_PYTHON_VERSION`: This variable must be set if there are multiple versions of python compiled for a unix machine.
|
||||||
|
|
||||||
An example might look like the following (assuming your target's sysroot is at `/home/pyo3/cross/sysroot` and that your target is `armv7`):
|
An example might look like the following (assuming your target's sysroot is at `/home/pyo3/cross/sysroot` and that your target is `armv7`):
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ cargo build --target armv7-unknown-linux-gnueabihf
|
||||||
|
|
||||||
If there are multiple python versions at the cross lib directory and you cannot set a more precise location to include both the `libpython` DSO and `_sysconfigdata*.py` files, you can set the required version:
|
If there are multiple python versions at the cross lib directory and you cannot set a more precise location to include both the `libpython` DSO and `_sysconfigdata*.py` files, you can set the required version:
|
||||||
```sh
|
```sh
|
||||||
export PYO3_PYTHON_VERSION=3.8
|
export PYO3_CROSS_PYTHON_VERSION=3.8
|
||||||
export PYO3_CROSS_LIB_DIR="/home/pyo3/cross/sysroot/usr/lib"
|
export PYO3_CROSS_LIB_DIR="/home/pyo3/cross/sysroot/usr/lib"
|
||||||
|
|
||||||
cargo build --target armv7-unknown-linux-gnueabihf
|
cargo build --target armv7-unknown-linux-gnueabihf
|
||||||
|
|
Loading…
Reference in New Issue