Questions about using "--target-architecture"

40 views
Skip to first unread message

Han

unread,
Jul 18, 2025, 9:18:39 PMJul 18
to PyInstaller
Hi,

I want to use "--target-architecture universal2" to create a build for both Apple silicon and Intel platforms for MacOS. However, when I tried to use "--target-architecture" with a spec file, I got the following error.
```
ERROR: option(s) not allowed:
  --target-architecture/--target-arch
makespec options not valid when a .spec file is given
```
I have quite a few specs that I need to put into that .spec file. Is there a way to work around this issue?

Best,

Han

bwoodsend

unread,
Jul 19, 2025, 5:45:37 PMJul 19
to PyInstaller

The spec file equivalent of --target-arch is a target_arch="universal2" parameter to the EXE() block. See docs.

Message has been deleted

Han

unread,
Jul 21, 2025, 2:26:04 PMJul 21
to PyInstaller
Hi bwoodsend,

Thanks! I updated the .spec file and ran PyInstaller to create a universal2 app. But I encountered the following error.

 `PyInstaller.utils.osx.IncompatibleBinaryArchError: path_to_my_app/.venv/lib/python3.12/site-packages/numpy/linalg/_umath_linalg.cpython-312-darwin.so is not a fat binary! For details about this error message, see: https://pyinstaller.org/en/stable/feature-notes.html#macos-multi-arch-support`

The following is what I understand now. Please correct me if something is wrong.
To create a fat binary, I can use `delocate-merge` to to merge two single-arch wheels for a package (here the numpy), which will be the fat binary I need. Am I on the right path? Once I create this fat binary, how can I import it into my current project? I am using Poetry to manage dependencies now. In other words, how can I integrate the generated fat binary with Poetry?

Please let me know. Thanks!

Best,

Han

Han

unread,
Jul 21, 2025, 3:03:12 PMJul 21
to PyInstaller
When I checked my Python Interpreter, it support both architectures.
```
file $(which python3)
path_to_my_app/.venv/bin/python3: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit executable x86_64] [arm64:Mach-O 64-bit executable arm64]
path_to_my_app/.venv/bin/python3 (for architecture x86_64):  Mach-O 64-bit executable x86_64
path_to_my_app/.venv/bin/python3 (for architecture arm64):   Mach-O 64-bit executable arm64
```
When I set target_arch="universal2" , it still fails. Was it related with PyInstaller Bootloader?


On Saturday, July 19, 2025 at 5:45:37 PM UTC-4 bwoodsend wrote:

bwoodsend

unread,
Jul 21, 2025, 8:58:53 PMJul 21
to PyInstaller

To create a fat binary, I can use delocate-merge to to merge two single-arch wheels for a package (here the numpy), which will be the fat binary I need. Am I on the right path?

Yes.

Once I create this fat binary, how can I import it into my current project? I am using Poetry to manage dependencies now. In other words, how can I integrate the generated fat binary with Poetry?

Does this work?

[tool.poetry.dependencies] numpy = { file = "path/to/wheel.whl" }

To be honest, I’d avoid using a workflow manager like poetry for something like this that’s well outside of what they’re expected to be used for. If you stick to barebones pip+venv then it’s just pip install ./numpy-xxx-universal2.whl.

Han

unread,
Jul 22, 2025, 2:23:41 PMJul 22
to PyInstaller
Thanks for the reply!
Reply all
Reply to author
Forward
0 new messages