Skip to content

Commit

Permalink
build.rs: if found more than one candidate, filter on arch
Browse files Browse the repository at this point in the history
If we got more then one file, only take those that contain the arch name.
For ubuntu 20.04 with host architecture x86_64 and a foreign architecture of armhf
this reduces the number of candidates to 1:

  $ find /usr/lib/python3.8/ -name '_sysconfigdata*.py' -not -lname '*'
  /usr/lib/python3.8/_sysconfigdata__x86_64-linux-gnu.py
  /usr/lib/python3.8/_sysconfigdata__arm-linux-gnueabihf.py

CHANGELOG.md: add entry for cross-sysconfigdata filter on arch
  • Loading branch information
alonblade authored and davidhewitt committed May 25, 2021
1 parent 9a4e7b5 commit 16e297f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- `BaseType`, `BaseLayout`, `Layout`, `Initializer` [#1596](https://github.com/PyO3/pyo3/pull/1596)
- Remove `__doc__` from module's `__all__`. [#1509](https://github.com/PyO3/pyo3/pull/1509)
- Remove `PYO3_CROSS_INCLUDE_DIR` environment variable and the associated C header parsing functionality.
- Filter sysconfigdata candidates on arch when cross-compiling. [#1626](https://github.com/PyO3/pyo3/pull/1626)

### Fixed
- Remove FFI definition `PyCFunction_ClearFreeList` for Python 3.9 and later. [#1425](https://github.com/PyO3/pyo3/pull/1425)
Expand Down
14 changes: 14 additions & 0 deletions pyo3-build-config/src/impl_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,20 @@ fn search_lib_dir(path: impl AsRef<Path>, cross: &CrossCompileConfig) -> Vec<Pat
};
sysconfig_paths.extend(sysc);
}
// If we got more than one file, only take those that contain the arch name.
// For ubuntu 20.04 with host architecture x86_64 and a foreign architecture of armhf
// this reduces the number of candidates to 1:
//
// $ find /usr/lib/python3.8/ -name '_sysconfigdata*.py' -not -lname '*'
// /usr/lib/python3.8/_sysconfigdata__x86_64-linux-gnu.py
// /usr/lib/python3.8/_sysconfigdata__arm-linux-gnueabihf.py
if sysconfig_paths.len() > 1 {
sysconfig_paths = sysconfig_paths
.iter()
.filter(|p| p.to_string_lossy().contains(&cross.arch))
.map(|p| p.clone())
.collect::<Vec<PathBuf>>();
}
sysconfig_paths
}

Expand Down

0 comments on commit 16e297f

Please sign in to comment.