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 committed May 24, 2021
1 parent cfdd535 commit aeb578f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Update `num-complex` optional dependency to 0.4. [#1482](https://github.com/PyO3/pyo3/pull/1482)
- Extend `hashbrown` optional dependency supported versions to include 0.11. [#1496](https://github.com/PyO3/pyo3/pull/1496)
- Support PyPy 3.7. [#1538](https://github.com/PyO3/pyo3/pull/1538)
- Try harder to filter sysconfigdata candidates on arch.config

### Added
- Add conversions for `[T; N]` for all `N` on Rust 1.51 and up. [#1128](https://github.com/PyO3/pyo3/pull/1128)
Expand Down
15 changes: 15 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,21 @@ fn search_lib_dir(path: impl AsRef<Path>, cross: &CrossCompileConfig) -> Vec<Pat
};
sysconfig_paths.extend(sysc);
}
// 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
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 aeb578f

Please sign in to comment.