Can Arm process load Intel packages? - Packaging - Discussions on Python.org
Can Arm process load Intel packages? Packaging aivarannamaa (Aivar Annamaa) August 27, 2022, 6:02am 1 If universal2 Python is running in arm mode on macOS, will it be able to load binary modules compiled for x86? I don’t have an Arm Mac, so I can’t test it myself… barry-scott (Barry Scott) August 27, 2022, 7:01am 2 I would not expect that to work. The emulation is on a process basis. I recall that you can force the use of a specific arch on macOs.
Cannot recall the command line option to do this of the top of my head. Barry ronaldoussoren (Ronald Oussoren) August 27, 2022, 10:15am 3 No, a proces on Apple Silicon Macs is either running arm64 code or x86_64 code and not both at the same time. Extensions need to support arm64 to be usable in a Python proces that’s running native code on Apple Silicon. That’s pretty easy to accomplish by building the extension (and all libraries used by it) as a Universal 2 binary on a MacOS 11 or later system (using system tooling), even if you cannot test the resulting binary on an Intel Mac.
The macOS installer on python.org supports this out of the box. 1 Like barry-scott (Barry Scott) August 27, 2022, 8:23pm 4 On macOs Yule the arch command like this to run in x86 mode: $ arch -x86_64 python2.10 aivarannamaa (Aivar Annamaa) August 28, 2022, 7:00am 5 That’s pretty easy to accomplish by building the extension (and all libraries used by it) as a Universal 2 binary on a MacOS 11 or later system (using system tooling) Thank you for this tip!
Can you give me a link for more details? Is it possible to instruct pip install build universal2 wheels? barry-scott (Barry Scott) August 28, 2022, 7:16am 6 It’s easy for some code to turn into universal2. But there are extensions where it is complex to re tool the builds to do universal2, for example if the extension needs openssl, building openssl is far from easy. ronaldoussoren (Ronald Oussoren) August 29, 2022, 8:41am 7 On a Universal 2 install of Python setuptools will automatically build Universal 2 wheels (assuming all C dependencies are available as Universal 2 binaries).
There is no way to ask pip to install universal2 wheels in preference of single architecture wheels. Sadly the pip project has chosen to prefer single architecture wheels and does not have an option to control this. IIRC there was a discussion about this on this forum. pf_moore (Paul Moore) August 29, 2022, 11:31am 8 I’m not even sure how to distinguish between single architecture and universal wheels. Presumably they have different wheel tags?
If so, then the list of tags supported on a given platform is generated by the packaging project (which pip uses) - I don’t know if it was a deliberate choice or if it’s something that they would be willing to discuss. Might be worth checking for an existsing issue and/or asking on the packaging tracker. ronaldoussoren (Ronald Oussoren) August 29, 2022, 11:56am 9 The relevant issue in packaging is: Order of architectures in platform tags on macOS · Issue #381 · pypa/packaging · GitHub Anyways… Universal2 wheels use “universal2” as the CPU architecture in the wheel filename.
I’d like to have a way to force installation of universal2 wheels instead of the default in pip (single architecture wheels). My primary use-case for this are tools like py2app, without such an option I’ll end up writing a library or tool that does this outside of pip. I might end up doing that anyway because there are also project that only publish single architecture wheels. 1 Like