Pyinstaller can set the target arch when working with .spec files by specifying the target architecture in the .spec file via the target_arch=
argument to EXE().
I want to set it to universal2
to build a macho fat file for running on both Intel and arm64 macOS available architectures.
However, some of the dependancies are python system .so
libraries built for current arch only (in my case it's arm64)
This leads to the following error when trying to build the executable:
raise IncompatibleBinaryArchError(f"{display_name} is not a fat binary!")
PyInstaller.utils.osx.IncompatibleBinaryArchError:
/opt/homebrew/Cellar/python@3.10/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/lib-dynload/_struct.cpython-310-darwin.so is not a fat binary!
So apparently _struct.cpython-310-darwin.so
is built for arm64 only... Is there any way to build a FAT version of my project ?
where can I get builtin python framework that compiled as FAT ?
Is there a way to auto-download the right library compiled for the desired arch, upon demand ?
thanks !
rokm says here that it will fail this way when the version of Python being used is from anaconda or Homebrew (which was true in my case) -
See the docs.
In order to build
universal2
application, you need your python and all non-pure python packages to beuniversal2
. So building under single-arch python environments such as anaconda or Homebrew is out of question....
I've solved this by uninstalling my existing python-release of Homebrew and
installing a formal "universal2" release from Python.org -
for example: