-
Notifications
You must be signed in to change notification settings - Fork 760
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
build.rs: if found more than one candidate, filter on arch #1626
Conversation
aeb578f
to
ee492ca
Compare
ee492ca
to
16e297f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @alonblade, thanks for the PR!
We literally just merged a change to the build infrastructure, so I had to rebase and force-push your PR. Hope that's ok.
Let's see how CI does with this branch, also I have one thought...
pyo3-build-config/src/impl_.rs
Outdated
// 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>>(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only potential issue I see is that if the arch
doesn't match any sysconfig file (e.g. maybe the arch is spelt differently for some reason?) then this could reduce the number of candidates to zero.
In that case, it might be worth keeping the original full set of paths instead of listing zero paths and failing?
16e297f
to
ba19e7c
Compare
ok, I made a mess by accidentally pushing with force my updated change, so
now I'm redoing the rebase you did for me.
…On Tue, May 25, 2021 at 9:23 AM David Hewitt ***@***.***> wrote:
***@***.**** commented on this pull request.
Hi @alonblade <https://github.com/alonblade>, thanks for the PR!
We literally just merged a change to the build infrastructure, so I had to
rebase and force-push your PR. Hope that's ok.
Let's see how CI does with this branch, also I have one thought...
------------------------------
In pyo3-build-config/src/impl_.rs
<#1626 (comment)>:
> + // 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>>();
+ }
The only potential issue I see is that if the arch doesn't match *any*
sysconfig file (e.g. maybe the arch is spelt differently for some reason?)
then this could reduce the number of candidates to zero.
In that case, it might be worth keeping the original full set of paths
instead of listing zero paths and failing?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1626 (review)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ASHRLMN5LNDHBWJO3TDWOLLTPM67VANCNFSM45NEBKDQ>
.
|
ba19e7c
to
95cb323
Compare
@davidhewitt hmm, now that I rebased on latest I get a different error from my use case (pi armhf target, x86_64 host) - Trying to debug it.
|
@alonblade yikes, I'm pretty sure this is my fault; I have a guess at what's going on. I'll try to open a PR to fix tonight. |
@davidhewitt ok, I think I found the problem: the new refactoring of pyo3-build-config out of build.rs means that when I am not sure how to proceed - one option would be to pass the real target variables to pyo3-build-config in a different set of environment variables (i.e. CARGO_CFG_TARGET_ARCH becomes PYO3_CARGO_CFG_TARGET_ARCH) What do you think? |
Thanks! |
95cb323
to
96a6739
Compare
(Apologies, I've run out of time to try to fix this tonight. I'm going to attempt to find time again soon, hopefully on Thursday evening.) |
Sweet. No worries.
…On Wed, May 26, 2021 at 1:34 AM David Hewitt ***@***.***> wrote:
(Apologies, I've run out of time to try to fix this tonight. I'm going to
attempt to find time again soon, hopefully on Thursday evening.)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1626 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ASHRLMORTYEDPDLJ6VE3YILTPQQZBANCNFSM45NEBKDQ>
.
|
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 commit changelog: 1. initial 2. if filtered list is empty, use pre filtered. 3. clippy is_empty and cloned
96a6739
to
e5542f2
Compare
I'm going to merge this and rebase my cross-compilation fix on it. Thanks for implementing this! |
Super, thanks!
…On Sat, Jun 5, 2021 at 11:29 AM David Hewitt ***@***.***> wrote:
Merged #1626 <#1626> into main.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1626 (comment)>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ASHRLMNCRDDVAJLVD6FZCQDTRHN5XANCNFSM45NEBKDQ>
.
|
Hi,
This is my first RP on pyo3. Thanks for the great work, I'm using this right now to convert a library from python to rust for a raspberry pi running in 32 bit mode, that is armhf architecture, using ubuntu 20.04 as the target distribution. I have both the host x86_64 python3.8 sysconfigdata and the foreign architecture armhf in /usr/lib/python3.8, which results in more than one candidate during search_lib_dir, and an error of "Detected multiple possible python versions".
I've conservatively added a filter in that case to keep only the paths with cross.arch in their name (to_lossy_string.contains(&config.arch))
There is already an existing filter on config.arch but only in another branch, so I didn't want to pull it in to the first branch (Ok(f) if starts_with(f, "_sysconfigdata") && ends_with(f, "py")).
I added a line in CHANGELOG, I think this is a bug so it should not change the documentation.
I've run clippy (no errors), run fmt (no changes), "cargo test" fails but on unrelated code (I can attach, fails in examples).
Alon