# Can Arm process load Intel packages?

**URL:** <https://discuss.python.org/t/can-arm-process-load-intel-packages/18523>\
**Category:** Packaging\
**Created:** [August 27, 2022, 6:02am UTC](https://discuss.python.org/t/can-arm-process-load-intel-packages/18523 "2022-08-27T06:02:08Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![aivarannamaa](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/aivarannamaa/32/4235_2.png) [@aivarannamaa](https://discuss.python.org/u/aivarannamaa)\
**Post date:** [August 27, 2022, 6:02am UTC](https://discuss.python.org/t/can-arm-process-load-intel-packages/18523/1 "2022-08-27T06:02:08Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![barry-scott](https://avatars.discourse-cdn.com/v4/letter/b/e9c0ed/32.png) [@barry-scott](https://discuss.python.org/u/barry-scott)\
**Post date:** [August 27, 2022, 7:01am UTC](https://discuss.python.org/t/can-arm-process-load-intel-packages/18523/2 "2022-08-27T07:01:55Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ronaldoussoren](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/ronaldoussoren/32/61_2.png) [@ronaldoussoren](https://discuss.python.org/u/ronaldoussoren)\
**Post date:** [August 27, 2022, 10:15am UTC](https://discuss.python.org/t/can-arm-process-load-intel-packages/18523/3 "2022-08-27T10:15:49Z")

</div>

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](http://python.org) supports this out of the box.

---

<div class="post-metadata">

**Author:** ![barry-scott](https://avatars.discourse-cdn.com/v4/letter/b/e9c0ed/32.png) [@barry-scott](https://discuss.python.org/u/barry-scott)\
**Post date:** [August 27, 2022, 8:23pm UTC](https://discuss.python.org/t/can-arm-process-load-intel-packages/18523/4 "2022-08-27T20:23:16Z")

</div>

On macOs Yule the arch command like this to run in x86 mode:

$ arch -x86\_64 python2.10

---

<div class="post-metadata">

**Author:** ![aivarannamaa](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/aivarannamaa/32/4235_2.png) [@aivarannamaa](https://discuss.python.org/u/aivarannamaa)\
**Post date:** [August 28, 2022, 7:00am UTC](https://discuss.python.org/t/can-arm-process-load-intel-packages/18523/5 "2022-08-28T07:00:11Z")

</div>

> 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?

---

<div class="post-metadata">

**Author:** ![barry-scott](https://avatars.discourse-cdn.com/v4/letter/b/e9c0ed/32.png) [@barry-scott](https://discuss.python.org/u/barry-scott)\
**Post date:** [August 28, 2022, 7:16am UTC](https://discuss.python.org/t/can-arm-process-load-intel-packages/18523/6 "2022-08-28T07:16:34Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ronaldoussoren](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/ronaldoussoren/32/61_2.png) [@ronaldoussoren](https://discuss.python.org/u/ronaldoussoren)\
**Post date:** [August 29, 2022, 8:41am UTC](https://discuss.python.org/t/can-arm-process-load-intel-packages/18523/7 "2022-08-29T08:41:49Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![pf\_moore](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/pf_moore/32/35_2.png) [@pf\_moore](https://discuss.python.org/u/pf_moore)\
**Post date:** [August 29, 2022, 11:31am UTC](https://discuss.python.org/t/can-arm-process-load-intel-packages/18523/8 "2022-08-29T11:31:53Z")

</div>

> [@ronaldoussoren](#):
>
> Sadly the pip project has chosen to prefer single architecture wheels and does not have an option to control this.

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.

---

<div class="post-metadata">

**Author:** ![ronaldoussoren](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/ronaldoussoren/32/61_2.png) [@ronaldoussoren](https://discuss.python.org/u/ronaldoussoren)\
**Post date:** [August 29, 2022, 11:56am UTC](https://discuss.python.org/t/can-arm-process-load-intel-packages/18523/9 "2022-08-29T11:56:51Z")

</div>

The relevant issue in packaging is: [Order of architectures in platform tags on macOS · Issue #381 · pypa/packaging · GitHub](https://github.com/pypa/packaging/issues/381)

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.
