00353: Original names for architectures with different names downstream#15
Conversation
|
I wanted to check on armv7hl, but apparently, there is no such wheel in simple-manylinux-demo. Can you please make one, or is there some obstacle? |
|
Oh, there is no manylinux image for armv7hl on https://quay.io/organization/pypa :/ |
|
Exactly. I'd have to find a machine with that architecture and build the wheel manually there. |
|
manylinux2014 itself should support it: https://www.python.org/dev/peps/pep-0599/#the-manylinux2014-policy |
|
And to test it, I'd have to compile my own Python or build the wheel outside RHEL/Centos so the suffix is not configured by us. |
53f5ad5 to
9e83f1f
Compare
|
According to pep8, constants should be defined at the module level. Another speed improvement I can think about is to return from the function immediately when it discovers a platform is a one we don't have an alternative name for. Because it isn't possible to do an import (platform) here, I'd implement it this way: But I don't think it's worth it because running this function thousand times with randomly shuffled suffixes takes only around 0,052 s (interpreter startup time included). |
|
Don't optimize it (yet). What do you measure? I think we need to measure interpreter startup with and without this patch. |
I've measured how long it takes for interpreter to start and call this function thousand times. |
|
Python has a special benchmark for importlib measuring how many times you can do a specific type of import within one second. The results for old (original Python) and new (with this change) are: The numbers show how many times you can do an import within one second. I honestly think that the numbers are so high that the difference is hardly measurable. To be precise here would require a special isolated environment. I've also tried Again, the startup time is so short that it's hard to measure the difference. Also, I've measured those numbers on x86_64 on which the function doesn't end sooner. |
|
The code looks reasonable. For easier backporting (and as a premature optimization), I'd consider having the strings in the dict already in the _ARCH_MAP = {
"-arm-linux-gnueabi.": "-arm-linux-gnueabihf.",For the impact on speed, I'd very much like to hear @vstinner's opinion. |
|
Will I do? |
9e83f1f to
5823489
Compare
|
If you like the code now, I can do one more test on a machine with an affected architecture, and then we can merge this. |
I am afraid I don't understand this question. |
Plese rebase https://src.fedoraproject.org/rpms/python3.9/pull-request/24 to include this patch, so we get a build. You can use importpatches with |
5823489 to
03e858c
Compare
|
Fox a while, the patch included the regenerated header file. Now it doesn't. Note that we need to be able to build Python |
Could you please explain why do you need this feature to be enabled in a python interpreter between a bootstrap build and the first regular one? I thought that we can make this patch nicer and don't include the generated header file and let |
|
What do you mean by "between a bootstrap build and the first regular one"? The package needs to be able to build with bootstrap at any time. It is needed on several occasions (e.g. when the ABI compatibility is broken, or when we import the package to a RHEL module or SCL). |
Pythons in RHEL/Fedora use different names for some architectures than upstream and other distros (for example ppc64 vs. powerpc64). See patch 274. That means that an extension built with the default upstream settings (on other distro or as an manylinux wheel) cannot be found by Python on RHEL/Fedora because it has a different suffix. This patch adds the original names to importlib so Python is able to import extensions with an original architecture name in its file name. WARNING: This patch has no effect on Python built with bootstrap enabled because Python/importlib_external.h is not regenerated and therefore Python during bootstrap contains importlib from upstream without this feature. It's possible to include Python/importlib_external.h to this patch but it'd make rebasing a nightmare because it's basically a binary file.
03e858c to
b27679a
Compare
|
Added a warning about zero effect of this patch during a bootstrap build. |
|
I am going to merge this and add |
|
The tag is there. I see that there are no merge commits, should I remove the last one and force-push the fedora-3.9 branch? Do we want to disable merge commits in pull requests? |
|
The patch applies cleanly down to 3.6 and has a simple conflict on 3.5. May I tag and push all the branches or open pull requests for each one? |
Yes and retag. I have no idea what does the automation do with such commits, it has never been tested and even if it accidentally works, it will break
If you think it will help to prevent this, make it so.
I'd just put the commits in. The purpose of the PR here is to do patch review, not to waste time. |
|
And thanks for looking into the workflow even if it is more complicated for now ❤️ |
Done, force-pushed with the appropriate tag
Somebody did it already.
All branches down to 3.5 updated with appropriate tags. |
Pythons in RHEL/Fedora use different names for some architectures
than upstream and other distros (for example ppc64 vs. powerpc64).
See patch 274.
That means that an extension built with the default upstream settings
(on other distro or as an manylinux wheel) cannot be found by Python
on RHEL/Fedora because it has a different suffix.
This patch adds the original names to importlib so Python is able
to import extensions with an original architecture name in its
file name.
Tested on ppc64le with a wheel from simple-manylinux-demo:
This might be also implemented on C level somewhere around _PyImport_DynLoadFiletab but I think that this version is much clearer and easy to understand.