apply symlink use case, change variable name

This commit is contained in:
Rene Leveille 2020-08-19 12:11:14 -04:00
parent 455ec80a98
commit 441d7f52b1
2 changed files with 10 additions and 5 deletions

View File

@ -126,7 +126,7 @@ impl CrossCompileConfig {
include_dir: None,
os: env::var("CARGO_CFG_TARGET_OS").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
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() {
bail!(
"Could not find either libpython.so or _sysconfigdata*.py in {}",
@ -378,7 +383,7 @@ fn load_cross_compile_from_sysconfigdata(
let interpreter_config = InterpreterConfig {
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,
ld_version,
base_prefix: "".to_string(),

View File

@ -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_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`):
@ -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:
```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"
cargo build --target armv7-unknown-linux-gnueabihf