Closed machawk1 closed 1 year ago
This same behavior occurs with a dummy program:
machawk1@Mats-M1-Mac /tmp % echo "print('hello world')" > hello.py
machawk1@Mats-M1-Mac /tmp % pyinstaller --onefile --target-arch universal2 hello.py
41 INFO: PyInstaller: 5.0.dev0
41 INFO: Python: 3.9.5
47 INFO: Platform: macOS-11.4-arm64-arm-64bit
47 INFO: wrote /private/tmp/hello.spec
49 INFO: UPX is not available.
49 INFO: Extending PYTHONPATH with paths
['/private/tmp', '/private/tmp']
55 INFO: checking Analysis
61 INFO: checking PYZ
62 INFO: EXE target arch: universal2
62 INFO: Code signing identity: None
62 INFO: checking PKG
62 INFO: Building PKG because PKG-00.toc is non existent
62 INFO: Building PKG (CArchive) PKG-00.pkg
Traceback (most recent call last):
File "/opt/homebrew/bin/pyinstaller", line 8, in <module>
sys.exit(run())
File "/opt/homebrew/lib/python3.9/site-packages/PyInstaller/__main__.py", line 126, in run
run_build(pyi_config, spec_file, **vars(args))
File "/opt/homebrew/lib/python3.9/site-packages/PyInstaller/__main__.py", line 65, in run_build
PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
File "/opt/homebrew/lib/python3.9/site-packages/PyInstaller/building/build_main.py", line 758, in main
build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
File "/opt/homebrew/lib/python3.9/site-packages/PyInstaller/building/build_main.py", line 705, in build
exec(code, spec_namespace)
File "/private/tmp/hello.spec", line 23, in <module>
exe = EXE(pyz,
File "/opt/homebrew/lib/python3.9/site-packages/PyInstaller/building/api.py", line 509, in __init__
self.pkg = PKG(self.toc, cdict=kwargs.get('cdict', None),
File "/opt/homebrew/lib/python3.9/site-packages/PyInstaller/building/api.py", line 208, in __init__
self.__postinit__()
File "/opt/homebrew/lib/python3.9/site-packages/PyInstaller/building/datastruct.py", line 159, in __postinit__
self.assemble()
File "/opt/homebrew/lib/python3.9/site-packages/PyInstaller/building/api.py", line 274, in assemble
fnm = checkCache(fnm, strip=self.strip_binaries,
File "/opt/homebrew/lib/python3.9/site-packages/PyInstaller/building/utils.py", line 386, in checkCache
osxutils.binary_to_target_arch(cachedfile, target_arch,
File "/opt/homebrew/lib/python3.9/site-packages/PyInstaller/utils/osx.py", line 332, in binary_to_target_arch
assert target_arch != 'universal2', \
AssertionError: /opt/homebrew/Cellar/python@3.9/3.9.5/Frameworks/Python.framework/Versions/3.9/lib/python3.9/lib-dynload/zlib.cpython-39-darwin.so is not a fat binary!
machawk1@Mats-M1-Mac /tmp %
Watch https://github.com/pyinstaller/pyinstaller/pull/5883
I think the support for universal2 is just in the develop
branch and has not yet been merged into master.
I pulled from the current HEAD of the develop branch of the pyinstaller repo ( 000275e409640320cdd995a7f077abfdece86749 ), rebuilt the bootloaders per the WAIL MAKEFILE script, installed pyinstaller, tried to rebuild the above hello.py and the same error resulted.
The commit that enables this in Pyinstaller is c67a0d7f465e5c14f8a85d53efaeddfc37eb774d , which is not yet part of their master branch's history but is present in their develop branch. When this is merged to master and a new version of Pyinstaller is presumably released, universal2 binaries of WAIL can be created without having to rely on the dependency's develop branch.
Pyinstaller 4.4 provides support for Apple Silicon: https://pyinstaller.readthedocs.io/en/stable/CHANGES.html#id1
A hello world program with PyInstaller 4.4 using pyinstaller --onefile --noconsole --target-architecture universal2 hello.py
fails to build. We might need to manually build the universal bootloader, despite the release.
Re-compiling the bootloader per #494 with the commit aligning with Pyinstaller 4.4 then installing causes the same issue to be reported, i.e., ....so is not a fat binary!
and nothing to be generated in ./dist
Pyinstaller 4.5 released on August 1, 2021 purports to fix issues with architecture detection: https://pyinstaller.readthedocs.io/en/stable/CHANGES.html#id1
I am still unable to build a universal2 binary with the latest release, Pyinstaller 4.5.1.
/tmp % echo "print('hello world')" > hello.py
/tmp % pyinstaller --onefile --target-arch universal2 hello.py
24 INFO: PyInstaller: 4.5.1
24 INFO: Python: 3.9.6
29 INFO: Platform: macOS-11.5.2-arm64-arm-64bit
29 INFO: wrote /private/tmp/hello.spec
30 INFO: UPX is not available.
31 INFO: Extending PYTHONPATH with paths
['/private/tmp', '/private/tmp']
119 INFO: checking Analysis
121 INFO: Building because /private/tmp/hello.py changed
121 INFO: Initializing module dependency graph...
121 INFO: Caching module graph hooks...
124 INFO: Analyzing base_library.zip ...
1312 INFO: Processing pre-find module path hook distutils from '/opt/homebrew/lib/python3.9/site-packages/PyInstaller/hooks/pre_find_module_path/hook-distutils.py'.
1312 INFO: distutils: retargeting to non-venv dir '/opt/homebrew/Cellar/python@3.9/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9'
2285 INFO: Caching module dependency graph...
2351 INFO: running Analysis Analysis-00.toc
2353 INFO: Analyzing /private/tmp/hello.py
2353 INFO: Processing module hooks...
2353 INFO: Loading module hook 'hook-xml.etree.cElementTree.py' from '/opt/homebrew/lib/python3.9/site-packages/PyInstaller/hooks'...
2354 INFO: Loading module hook 'hook-lib2to3.py' from '/opt/homebrew/lib/python3.9/site-packages/PyInstaller/hooks'...
2360 INFO: Loading module hook 'hook-encodings.py' from '/opt/homebrew/lib/python3.9/site-packages/PyInstaller/hooks'...
2388 INFO: Loading module hook 'hook-distutils.util.py' from '/opt/homebrew/lib/python3.9/site-packages/PyInstaller/hooks'...
2389 INFO: Loading module hook 'hook-pickle.py' from '/opt/homebrew/lib/python3.9/site-packages/PyInstaller/hooks'...
2390 INFO: Loading module hook 'hook-heapq.py' from '/opt/homebrew/lib/python3.9/site-packages/PyInstaller/hooks'...
2390 INFO: Loading module hook 'hook-difflib.py' from '/opt/homebrew/lib/python3.9/site-packages/PyInstaller/hooks'...
2391 INFO: Loading module hook 'hook-multiprocessing.util.py' from '/opt/homebrew/lib/python3.9/site-packages/PyInstaller/hooks'...
2391 INFO: Loading module hook 'hook-sysconfig.py' from '/opt/homebrew/lib/python3.9/site-packages/PyInstaller/hooks'...
2394 INFO: Loading module hook 'hook-xml.py' from '/opt/homebrew/lib/python3.9/site-packages/PyInstaller/hooks'...
2418 INFO: Loading module hook 'hook-distutils.py' from '/opt/homebrew/lib/python3.9/site-packages/PyInstaller/hooks'...
2426 INFO: Looking for ctypes DLLs
2433 INFO: Analyzing run-time hooks ...
2434 INFO: Including run-time hook '/opt/homebrew/lib/python3.9/site-packages/PyInstaller/hooks/rthooks/pyi_rth_pkgutil.py'
2435 INFO: Including run-time hook '/opt/homebrew/lib/python3.9/site-packages/PyInstaller/hooks/rthooks/pyi_rth_multiprocessing.py'
2436 INFO: Including run-time hook '/opt/homebrew/lib/python3.9/site-packages/PyInstaller/hooks/rthooks/pyi_rth_inspect.py'
2439 INFO: Looking for dynamic libraries
2465 INFO: Looking for eggs
2465 INFO: Using Python library /opt/homebrew/Cellar/python@3.9/3.9.6/Frameworks/Python.framework/Versions/3.9/Python
2466 INFO: Warnings written to /private/tmp/build/hello/warn-hello.txt
2478 INFO: Graph cross-reference written to /private/tmp/build/hello/xref-hello.html
2482 INFO: checking PYZ
2483 INFO: Building because toc changed
2483 INFO: Building PYZ (ZlibArchive) /private/tmp/build/hello/PYZ-00.pyz
2688 INFO: Building PYZ (ZlibArchive) /private/tmp/build/hello/PYZ-00.pyz completed successfully.
2691 INFO: EXE target arch: universal2
2691 INFO: Code signing identity: None
2691 INFO: checking PKG
2691 INFO: Building PKG because PKG-00.toc is non existent
2691 INFO: Building PKG (CArchive) PKG-00.pkg
Traceback (most recent call last):
File "/opt/homebrew/bin/pyinstaller", line 8, in <module>
sys.exit(run())
File "/opt/homebrew/lib/python3.9/site-packages/PyInstaller/__main__.py", line 126, in run
run_build(pyi_config, spec_file, **vars(args))
File "/opt/homebrew/lib/python3.9/site-packages/PyInstaller/__main__.py", line 65, in run_build
PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
File "/opt/homebrew/lib/python3.9/site-packages/PyInstaller/building/build_main.py", line 815, in main
build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
File "/opt/homebrew/lib/python3.9/site-packages/PyInstaller/building/build_main.py", line 762, in build
exec(code, spec_namespace)
File "/private/tmp/hello.spec", line 23, in <module>
exe = EXE(pyz,
File "/opt/homebrew/lib/python3.9/site-packages/PyInstaller/building/api.py", line 509, in __init__
self.pkg = PKG(self.toc, cdict=kwargs.get('cdict', None),
File "/opt/homebrew/lib/python3.9/site-packages/PyInstaller/building/api.py", line 208, in __init__
self.__postinit__()
File "/opt/homebrew/lib/python3.9/site-packages/PyInstaller/building/datastruct.py", line 159, in __postinit__
self.assemble()
File "/opt/homebrew/lib/python3.9/site-packages/PyInstaller/building/api.py", line 274, in assemble
fnm = checkCache(fnm, strip=self.strip_binaries,
File "/opt/homebrew/lib/python3.9/site-packages/PyInstaller/building/utils.py", line 387, in checkCache
osxutils.binary_to_target_arch(cachedfile, target_arch,
File "/opt/homebrew/lib/python3.9/site-packages/PyInstaller/utils/osx.py", line 334, in binary_to_target_arch
assert target_arch != 'universal2', \
AssertionError: /opt/homebrew/Cellar/python@3.9/3.9.6/Frameworks/Python.framework/Versions/3.9/Python is not a fat binary!
EDIT: Removing --onefile
has no effect.
EDIT2: Pulling from the latest main branch and building the bootloaders using ./waf all
then installing pyinstaller and repeating the above produces the same result (_datetime.cpython-39-darwin.so is not a fat binary!
)
I am starting to wonder if perhaps my installed version of Python is either Intel or not tailored to Apple Silicon. platform.machine()
states arm64
.
In the pyinstaller source, the issue exhibited of the complaint in the end of the above can be viewed via:
from macholib.MachO import MachO
filename = '/opt/homebrew/Cellar/python@3.9/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/lib-dynload/math.cpython-39-darwin.so'
executable = MachO(filename)
print(bool(executable.fat))
...which states that the imported math
module is not "fat".
Per https://github.com/pyinstaller/pyinstaller/issues/5886#issuecomment-854177236
Homebrew python is single-arch, so trying to build universal2 application should give you a build error.
I uninstalled the homebrew version of Python3 and installed the universal2 version from the Python site directly. Repeating the above:
/tmp % pyinstaller --onefile --target-arch universal2 hello.py
22 INFO: PyInstaller: 4.5.1
22 INFO: Python: 3.9.6
27 INFO: Platform: macOS-11.5.2-arm64-arm-64bit
28 INFO: wrote /private/tmp/hello.spec
30 INFO: UPX is not available.
30 INFO: Extending PYTHONPATH with paths
['/private/tmp', '/private/tmp']
92 INFO: checking Analysis
96 INFO: checking PYZ
98 INFO: EXE target arch: universal2
98 INFO: Code signing identity: None
98 INFO: checking PKG
99 INFO: Bootloader /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/PyInstaller/bootloader/Darwin-64bit/run
99 INFO: checking EXE
99 INFO: Building because name changed
99 INFO: Building EXE from EXE-00.toc
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.9/bin/pyinstaller", line 8, in <module>
sys.exit(run())
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/PyInstaller/__main__.py", line 126, in run
run_build(pyi_config, spec_file, **vars(args))
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/PyInstaller/__main__.py", line 65, in run_build
PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/PyInstaller/building/build_main.py", line 815, in main
build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/PyInstaller/building/build_main.py", line 762, in build
exec(code, spec_namespace)
File "/private/tmp/hello.spec", line 23, in <module>
exe = EXE(pyz,
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/PyInstaller/building/api.py", line 524, in __init__
self.__postinit__()
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/PyInstaller/building/datastruct.py", line 159, in __postinit__
self.assemble()
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/PyInstaller/building/api.py", line 604, in assemble
os.remove(self.name)
PermissionError: [Errno 1] Operation not permitted: '/private/tmp/dist/hello'
This looks a bit more hopeful.
universal2
architecture.With the cross-archtecture version of Python installed, attempting to compile still results in errors of dependencies not being available for the universal2
platform.
Requirement already satisfied: wxPython in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (4.1.1)
Requirement already satisfied: six in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (from wxPython) (1.16.0)
Requirement already satisfied: numpy in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (from wxPython) (1.21.1)
Requirement already satisfied: pillow in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (from wxPython) (8.3.1)
WARNING: You are using pip version 21.1.3; however, version 21.2.3 is available.
You should consider upgrading via the '/Library/Frameworks/Python.framework/Versions/3.9/bin/python3 -m pip install --upgrade pip' command.
Requirement already satisfied: biplist in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (from -r requirements.txt (line 1)) (1.0.3)
Requirement already satisfied: black in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (from -r requirements.txt (line 2)) (21.7b0)
Requirement already satisfied: dmgbuild in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (from -r requirements.txt (line 3)) (1.5.2)
Requirement already satisfied: ds-store in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (from -r requirements.txt (line 4)) (1.3.0)
Requirement already satisfied: mac-alias in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (from -r requirements.txt (line 5)) (2.2.0)
Requirement already satisfied: pathlib2 in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (from -r requirements.txt (line 6)) (2.3.6)
Requirement already satisfied: pyinstaller>=4.4 in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (from -r requirements.txt (line 7)) (4.5.1)
Requirement already satisfied: pypubsub in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (from -r requirements.txt (line 8)) (4.0.3)
Requirement already satisfied: pystache in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (from -r requirements.txt (line 9)) (0.5.4)
Requirement already satisfied: requests in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (from -r requirements.txt (line 10)) (2.26.0)
Requirement already satisfied: schedule in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (from -r requirements.txt (line 11)) (1.1.0)
Requirement already satisfied: six in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (from -r requirements.txt (line 12)) (1.16.0)
Requirement already satisfied: wheel in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (from -r requirements.txt (line 13)) (0.37.0)
Requirement already satisfied: wxPython in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (from -r requirements.txt (line 14)) (4.1.1)
Requirement already satisfied: altgraph in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (from pyinstaller>=4.4->-r requirements.txt (line 7)) (0.17)
Requirement already satisfied: macholib>=1.8 in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (from pyinstaller>=4.4->-r requirements.txt (line 7)) (1.14)
Requirement already satisfied: setuptools in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (from pyinstaller>=4.4->-r requirements.txt (line 7)) (56.0.0)
Requirement already satisfied: pyinstaller-hooks-contrib>=2020.6 in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (from pyinstaller>=4.4->-r requirements.txt (line 7)) (2021.2)
Requirement already satisfied: mypy-extensions>=0.4.3 in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (from black->-r requirements.txt (line 2)) (0.4.3)
Requirement already satisfied: pathspec<1,>=0.8.1 in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (from black->-r requirements.txt (line 2)) (0.9.0)
Requirement already satisfied: appdirs in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (from black->-r requirements.txt (line 2)) (1.4.4)
Requirement already satisfied: regex>=2020.1.8 in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (from black->-r requirements.txt (line 2)) (2021.8.3)
Requirement already satisfied: tomli<2.0.0,>=0.2.6 in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (from black->-r requirements.txt (line 2)) (1.2.1)
Requirement already satisfied: click>=7.1.2 in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (from black->-r requirements.txt (line 2)) (8.0.1)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (from requests->-r requirements.txt (line 10)) (1.26.6)
Requirement already satisfied: certifi>=2017.4.17 in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (from requests->-r requirements.txt (line 10)) (2021.5.30)
Requirement already satisfied: idna<4,>=2.5 in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (from requests->-r requirements.txt (line 10)) (3.2)
Requirement already satisfied: charset-normalizer~=2.0.0 in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (from requests->-r requirements.txt (line 10)) (2.0.4)
Requirement already satisfied: pillow in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (from wxPython->-r requirements.txt (line 14)) (8.3.1)
Requirement already satisfied: numpy in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (from wxPython->-r requirements.txt (line 14)) (1.21.1)
WARNING: You are using pip version 21.1.3; however, version 21.2.3 is available.
You should consider upgrading via the '/Library/Frameworks/Python.framework/Versions/3.9/bin/python3 -m pip install --upgrade pip' command.
Creating binary
/Library/Frameworks/Python.framework/Versions/3.9/bin/pyinstaller
/Library/Frameworks/Python.framework/Versions/3.9/bin/python3
23 INFO: PyInstaller: 4.5.1
23 INFO: Python: 3.9.6
30 INFO: Platform: macOS-11.5.2-arm64-arm-64bit
30 INFO: wrote /private/tmp/wail/WAIL.spec
32 INFO: UPX is not available.
33 INFO: Removing temporary files and cleaning cache in /Users/machawk1/Library/Application Support/pyinstaller
36 INFO: Extending PYTHONPATH with paths
['/private/tmp/wail', '/private/tmp/wail/bundledApps', '/private/tmp/wail']
104 INFO: checking Analysis
104 INFO: Building Analysis because Analysis-00.toc is non existent
104 INFO: Initializing module dependency graph...
105 INFO: Caching module graph hooks...
108 INFO: Analyzing base_library.zip ...
1365 INFO: Processing pre-find module path hook distutils from '/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/PyInstaller/hooks/pre_find_module_path/hook-distutils.py'.
1366 INFO: distutils: retargeting to non-venv dir '/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9'
2324 INFO: Caching module dependency graph...
2387 INFO: running Analysis Analysis-00.toc
2391 INFO: Analyzing /private/tmp/wail/bundledApps/WAIL.py
2491 INFO: Processing pre-safe import module hook urllib3.packages.six.moves from '/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/PyInstaller/hooks/pre_safe_import_module/hook-urllib3.packages.six.moves.py'.
2940 INFO: Processing pre-safe import module hook win32com from '/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/_pyinstaller_hooks_contrib/hooks/pre_safe_import_module/hook-win32com.py'.
2989 INFO: Processing module hooks...
2989 INFO: Loading module hook 'hook-certifi.py' from '/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/_pyinstaller_hooks_contrib/hooks/stdhooks'...
2991 INFO: Loading module hook 'hook-pubsub.core.py' from '/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/_pyinstaller_hooks_contrib/hooks/stdhooks'...
2992 INFO: Loading module hook 'hook-xml.etree.cElementTree.py' from '/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/PyInstaller/hooks'...
2992 INFO: Loading module hook 'hook-lib2to3.py' from '/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/PyInstaller/hooks'...
3004 INFO: Loading module hook 'hook-_tkinter.py' from '/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/PyInstaller/hooks'...
3053 INFO: checking Tree
3053 INFO: Building Tree because Tree-00.toc is non existent
3053 INFO: Building Tree Tree-00.toc
3057 INFO: checking Tree
3057 INFO: Building Tree because Tree-01.toc is non existent
3057 INFO: Building Tree Tree-01.toc
3086 INFO: checking Tree
3087 INFO: Building Tree because Tree-02.toc is non existent
3087 INFO: Building Tree Tree-02.toc
3088 INFO: Loading module hook 'hook-encodings.py' from '/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/PyInstaller/hooks'...
3116 INFO: Loading module hook 'hook-distutils.util.py' from '/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/PyInstaller/hooks'...
3117 INFO: Loading module hook 'hook-pickle.py' from '/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/PyInstaller/hooks'...
3118 INFO: Loading module hook 'hook-heapq.py' from '/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/PyInstaller/hooks'...
3118 INFO: Loading module hook 'hook-difflib.py' from '/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/PyInstaller/hooks'...
3119 INFO: Loading module hook 'hook-multiprocessing.util.py' from '/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/PyInstaller/hooks'...
3119 INFO: Loading module hook 'hook-sysconfig.py' from '/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/PyInstaller/hooks'...
3123 INFO: Loading module hook 'hook-xml.py' from '/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/PyInstaller/hooks'...
3144 INFO: Loading module hook 'hook-distutils.py' from '/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/PyInstaller/hooks'...
3152 INFO: Looking for ctypes DLLs
3159 INFO: Analyzing run-time hooks ...
3161 INFO: Including run-time hook '/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/PyInstaller/hooks/rthooks/pyi_rth_pkgutil.py'
3162 INFO: Including run-time hook '/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/PyInstaller/hooks/rthooks/pyi_rth_multiprocessing.py'
3163 INFO: Including run-time hook '/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/PyInstaller/hooks/rthooks/pyi_rth_inspect.py'
3163 INFO: Including run-time hook '/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/_pyinstaller_hooks_contrib/hooks/rthooks/pyi_rth_certifi.py'
3166 INFO: Looking for dynamic libraries
3236 INFO: Looking for eggs
3236 INFO: Using Python library /Library/Frameworks/Python.framework/Versions/3.9/Python
3238 INFO: Warnings written to /private/tmp/wail/build/WAIL/warn-WAIL.txt
3252 INFO: Graph cross-reference written to /private/tmp/wail/build/WAIL/xref-WAIL.html
3257 INFO: checking PYZ
3257 INFO: Building PYZ because PYZ-00.toc is non existent
3257 INFO: Building PYZ (ZlibArchive) /private/tmp/wail/build/WAIL/PYZ-00.pyz
3534 INFO: Building PYZ (ZlibArchive) /private/tmp/wail/build/WAIL/PYZ-00.pyz completed successfully.
3538 INFO: EXE target arch: universal2
3538 INFO: Code signing identity: None
3538 INFO: checking PKG
3538 INFO: Building PKG because PKG-00.toc is non existent
3538 INFO: Building PKG (CArchive) PKG-00.pkg
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.9/bin/pyinstaller", line 8, in <module>
sys.exit(run())
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/PyInstaller/__main__.py", line 126, in run
run_build(pyi_config, spec_file, **vars(args))
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/PyInstaller/__main__.py", line 65, in run_build
PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/PyInstaller/building/build_main.py", line 815, in main
build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/PyInstaller/building/build_main.py", line 762, in build
exec(code, spec_namespace)
File "/private/tmp/wail/WAIL.spec", line 23, in <module>
exe = EXE(pyz,
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/PyInstaller/building/api.py", line 509, in __init__
self.pkg = PKG(self.toc, cdict=kwargs.get('cdict', None),
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/PyInstaller/building/api.py", line 208, in __init__
self.__postinit__()
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/PyInstaller/building/datastruct.py", line 159, in __postinit__
self.assemble()
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/PyInstaller/building/api.py", line 274, in assemble
fnm = checkCache(fnm, strip=self.strip_binaries,
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/PyInstaller/building/utils.py", line 387, in checkCache
osxutils.binary_to_target_arch(cachedfile, target_arch,
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/PyInstaller/utils/osx.py", line 334, in binary_to_target_arch
assert target_arch != 'universal2', \
AssertionError: /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/wx/_adv.cpython-39-darwin.so is not a fat binary!
EDIT: Using the file
command can help to determine which architectures are supported by python (or any binary):
% file /usr/local/bin/python3
/usr/local/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]
/usr/local/bin/python3 (for architecture x86_64): Mach-O 64-bit executable x86_64
/usr/local/bin/python3 (for architecture arm64): Mach-O 64-bit executable arm64
echo "import wx\n\nprint('hello')" > hello.py
% pyinstaller --onefile --windowed --target-arch universal2 hello.py
24 INFO: PyInstaller: 4.5.1
24 INFO: Python: 3.9.6
31 INFO: Platform: macOS-11.5.2-arm64-arm-64bit
32 INFO: wrote /private/tmp/hello.spec
34 INFO: UPX is not available.
35 INFO: Extending PYTHONPATH with paths
['/private/tmp', '/private/tmp']
102 INFO: checking Analysis
107 INFO: checking PYZ
109 INFO: EXE target arch: universal2
109 INFO: Code signing identity: None
109 INFO: checking PKG
110 INFO: Building because toc changed
110 INFO: Building PKG (CArchive) PKG-00.pkg
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.9/bin/pyinstaller", line 8, in <module>
sys.exit(run())
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/PyInstaller/__main__.py", line 126, in run
run_build(pyi_config, spec_file, **vars(args))
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/PyInstaller/__main__.py", line 65, in run_build
PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/PyInstaller/building/build_main.py", line 815, in main
build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/PyInstaller/building/build_main.py", line 762, in build
exec(code, spec_namespace)
File "/private/tmp/hello.spec", line 23, in <module>
exe = EXE(pyz,
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/PyInstaller/building/api.py", line 509, in __init__
self.pkg = PKG(self.toc, cdict=kwargs.get('cdict', None),
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/PyInstaller/building/api.py", line 208, in __init__
self.__postinit__()
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/PyInstaller/building/datastruct.py", line 159, in __postinit__
self.assemble()
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/PyInstaller/building/api.py", line 274, in assemble
fnm = checkCache(fnm, strip=self.strip_binaries,
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/PyInstaller/building/utils.py", line 387, in checkCache
osxutils.binary_to_target_arch(cachedfile, target_arch,
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/PyInstaller/utils/osx.py", line 334, in binary_to_target_arch
assert target_arch != 'universal2', \
AssertionError: /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/wx/_core.cpython-39-darwin.so is not a fat binary!
The 2021-12-31 build now has “universal2” for cp39
wxPython-4.1.2a1.dev5268+fcf49322-cp39-cp39-macosx_10_10_universal2.whl
https://discuss.wxpython.org/t/mac-os-x-universal-arm-intel/35732/5
ARM support: https://github.com/wxWidgets/Phoenix/issues/1999
An update using the HEAD of wxPython from April 12, 2021 above:
% pyinstaller --onefile --windowed --target-arch universal2 hello.py
58 INFO: PyInstaller: 5.0.dev0
58 INFO: Python: 3.10.0
68 INFO: Platform: macOS-12.2.1-arm64-arm-64bit
69 INFO: wrote /private/tmp/hello.spec
71 INFO: UPX is not available.
71 INFO: Extending PYTHONPATH with paths
['/private/tmp']
163 INFO: checking Analysis
167 INFO: checking PYZ
168 INFO: EXE target arch: universal2
168 INFO: Code signing identity: None
168 INFO: checking PKG
169 INFO: Bootloader /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/PyInstaller/bootloader/Darwin-64bit/runw
169 INFO: checking EXE
169 INFO: checking BUNDLE
WARNING: The output directory "/private/tmp/dist/hello.app" and ALL ITS CONTENTS will be REMOVED! Continue? (y/N)y
On your own risk, you can use the option `--noconfirm` to get rid of this question.
20149 INFO: Removing dir /private/tmp/dist/hello.app
20151 INFO: Building BUNDLE BUNDLE-00.toc
20165 INFO: Moving BUNDLE data files to Resource directory
20165 INFO: Signing the BUNDLE...
20214 INFO: Building BUNDLE BUNDLE-00.toc completed successfully.
machawk1@Mat-mini /tmp % open ./
machawk1@Mat-mini /tmp % pyinstaller --onefile --windowed --target-arch universal2 hello.py
37 INFO: PyInstaller: 5.0.dev0
37 INFO: Python: 3.10.0
43 INFO: Platform: macOS-12.2.1-arm64-arm-64bit
44 INFO: wrote /private/tmp/hello.spec
46 INFO: UPX is not available.
46 INFO: Extending PYTHONPATH with paths
['/private/tmp']
129 INFO: checking Analysis
129 INFO: Building Analysis because Analysis-00.toc is non existent
129 INFO: Initializing module dependency graph...
130 INFO: Caching module graph hooks...
133 INFO: Analyzing base_library.zip ...
1780 INFO: Processing pre-find module path hook distutils from '/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/PyInstaller/hooks/pre_find_module_path/hook-distutils.py'.
1781 INFO: distutils: retargeting to non-venv dir '/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10'
2399 INFO: Caching module dependency graph...
2448 INFO: running Analysis Analysis-00.toc
2454 INFO: Analyzing /private/tmp/hello.py
2455 INFO: Processing module hooks...
2455 INFO: Loading module hook 'hook-xml.etree.cElementTree.py' from '/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/PyInstaller/hooks'...
2455 INFO: Loading module hook 'hook-lib2to3.py' from '/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/PyInstaller/hooks'...
2467 INFO: Loading module hook 'hook-_tkinter.py' from '/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/PyInstaller/hooks'...
2521 INFO: checking Tree
2521 INFO: Building Tree because Tree-00.toc is non existent
2521 INFO: Building Tree Tree-00.toc
2525 INFO: checking Tree
2525 INFO: Building Tree because Tree-01.toc is non existent
2525 INFO: Building Tree Tree-01.toc
2553 INFO: checking Tree
2553 INFO: Building Tree because Tree-02.toc is non existent
2553 INFO: Building Tree Tree-02.toc
2554 INFO: Loading module hook 'hook-encodings.py' from '/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/PyInstaller/hooks'...
2580 INFO: Loading module hook 'hook-distutils.util.py' from '/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/PyInstaller/hooks'...
2582 INFO: Loading module hook 'hook-pickle.py' from '/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/PyInstaller/hooks'...
2582 INFO: Loading module hook 'hook-heapq.py' from '/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/PyInstaller/hooks'...
2583 INFO: Loading module hook 'hook-difflib.py' from '/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/PyInstaller/hooks'...
2583 INFO: Loading module hook 'hook-multiprocessing.util.py' from '/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/PyInstaller/hooks'...
2584 INFO: Loading module hook 'hook-sysconfig.py' from '/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/PyInstaller/hooks'...
2590 INFO: Loading module hook 'hook-xml.py' from '/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/PyInstaller/hooks'...
2613 INFO: Loading module hook 'hook-distutils.py' from '/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/PyInstaller/hooks'...
2619 INFO: Looking for ctypes DLLs
2624 INFO: Analyzing run-time hooks ...
2625 INFO: Including run-time hook '/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/PyInstaller/hooks/rthooks/pyi_rth_inspect.py'
2626 INFO: Including run-time hook '/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/PyInstaller/hooks/rthooks/pyi_rth_subprocess.py'
2627 INFO: Including run-time hook '/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/PyInstaller/hooks/rthooks/pyi_rth_pkgutil.py'
2627 INFO: Including run-time hook '/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/PyInstaller/hooks/rthooks/pyi_rth_multiprocessing.py'
2630 INFO: Looking for dynamic libraries
2819 INFO: Looking for eggs
2819 INFO: Using Python library /Library/Frameworks/Python.framework/Versions/3.10/Python
2822 INFO: Warnings written to /private/tmp/build/hello/warn-hello.txt
2831 INFO: Graph cross-reference written to /private/tmp/build/hello/xref-hello.html
2835 INFO: checking PYZ
2835 INFO: Building PYZ because PYZ-00.toc is non existent
2835 INFO: Building PYZ (ZlibArchive) /private/tmp/build/hello/PYZ-00.pyz
3024 INFO: Building PYZ (ZlibArchive) /private/tmp/build/hello/PYZ-00.pyz completed successfully.
3026 INFO: EXE target arch: universal2
3026 INFO: Code signing identity: None
3026 INFO: checking PKG
3026 INFO: Building PKG because PKG-00.toc is non existent
3026 INFO: Building PKG (CArchive) hello.pkg
6366 INFO: Building PKG (CArchive) hello.pkg completed successfully.
6367 INFO: Bootloader /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/PyInstaller/bootloader/Darwin-64bit/runw
6367 INFO: checking EXE
6367 INFO: Building EXE because EXE-00.toc is non existent
6367 INFO: Building EXE from EXE-00.toc
6367 INFO: Copying bootloader EXE to /private/tmp/dist/hello
6368 INFO: Converting EXE to target arch (universal2)
6369 INFO: Removing signature(s) from EXE
6378 INFO: Appending PKG archive to EXE
6386 INFO: Fixing EXE headers for code signing
6392 INFO: Rewriting the executable's macOS SDK version (12.1.0) to match the SDK version of the Python library (11.3.0) in order to avoid inconsistent behavior and potential UI issues in the frozen application.
6393 INFO: Re-signing the EXE
6419 INFO: Building EXE from EXE-00.toc completed successfully.
6420 INFO: checking BUNDLE
6420 INFO: Building BUNDLE because BUNDLE-00.toc is non existent
6420 INFO: Building BUNDLE BUNDLE-00.toc
6425 INFO: Moving BUNDLE data files to Resource directory
6425 INFO: Signing the BUNDLE...
6451 INFO: Building BUNDLE BUNDLE-00.toc completed successfully.
%
Pyinstaller 4.10 has been released.
% pyinstaller --onefile --windowed --target-arch universal2 hello.py
26 INFO: PyInstaller: 4.10
26 INFO: Python: 3.10.0
33 INFO: Platform: macOS-12.2.1-arm64-arm-64bit
33 INFO: wrote /private/tmp/hello.spec
36 INFO: UPX is not available.
36 INFO: Extending PYTHONPATH with paths
['/private/tmp']
110 INFO: checking Analysis
113 INFO: checking PYZ
114 INFO: EXE target arch: universal2
114 INFO: Code signing identity: None
114 INFO: checking PKG
115 INFO: Bootloader /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/PyInstaller/bootloader/Darwin-64bit/runw
115 INFO: checking EXE
115 INFO: Rebuilding EXE-00.toc because hello missing
115 INFO: Building EXE from EXE-00.toc
115 INFO: Copying bootloader EXE to /private/tmp/dist/hello
116 INFO: Converting EXE to target arch (universal2)
117 INFO: Removing signature(s) from EXE
127 INFO: Appending PKG archive to EXE
130 INFO: Fixing EXE headers for code signing
137 INFO: Re-signing the EXE
159 INFO: Building EXE from EXE-00.toc completed successfully.
161 INFO: checking BUNDLE
161 INFO: Building BUNDLE BUNDLE-00.toc
165 INFO: Moving BUNDLE data files to Resource directory
165 INFO: Signing the BUNDLE...
192 INFO: Building BUNDLE BUNDLE-00.toc completed successfully.
Any update on this issue? I'm attempting to (automatically) compile my project using Github CI. However, it fails similarly as here. Same error.
It compiles fine using the x86_64
flag for --target-arch
, but I cannot say the same for the arm64
flag - it fails there. However, I can compile with both flags (haven't tested universal2
yet) on my x86_64 OSX machine, running latest Monterey.
Hi @kernelBPD, if you are trying to create a universal binary using pyinstaller, this is now supported in the latest version of pyinstaller. I have tested this on an M1 (arm64) and would like to see if you get the same result on x86_64.
% pyinstaller --version
5.0.1
% python3 --version
Python 3.10.4
% uname -m
arm64
% echo "import wx\n\nprint('hello')" > hello.py
% pyinstaller --onefile --windowed --target-arch universal2 hello.py
This GitHub issue is still in the context of this project (WAIL) because another library (wxPython) has limited arm64/universal support.
Hi, @machawk1, apologies for it taking me so long to respond. I was busy with other tasks and IRL stuff.
I’ve tested the following:
kernel@kernels-iMac ~ % pyinstaller --version
5.0.1
kernel@kernels-iMac ~ % python3.10 --version
Python 3.10.4
kernel@kernels-iMac ~ % uname -m
x86_64
kernel@kernels-iMac ~ % echo "import wx\n\nprint('hello')" > hello.py
kernel@kernels-iMac ~ % pyinstaller --onefile --windowed --target-arch universal2 hello.py
I’ve also been unable to install wxPython
, so there’s that.
Ran on Big Sur:
Hi @kernelBPD, if you are trying to create a universal binary using pyinstaller, this is now supported in the latest version of pyinstaller. I have tested this on an M1 (arm64) and would like to see if you get the same result on x86_64.
% pyinstaller --version 5.0.1 % python3 --version Python 3.10.4 % uname -m arm64 % echo "import wx\n\nprint('hello')" > hello.py % pyinstaller --onefile --windowed --target-arch universal2 hello.py
MacOS Monterey: 12.3.1 / Apple M1 Air
pyinstaller --version
5.1
Can't seem to get universal2 to work. arm64 works fine, though. This is the error I keep getting:
PyInstaller.utils.osx.IncompatibleBinaryArchError:
/opt/homebrew/Cellar/python@3.9/3.9.12/Frameworks/Python.framework/Versions/3.9/
lib/python3.9/lib-dynload/_posixshmem.cpython-39-darwin.so is not a fat binary!
Am I missing something? Is it a library issue?
EDIT: Alas so it was. Here's the reason why it's happening:
https://github.com/orgs/pyinstaller/discussions/6650#discussioncomment-2300963
PyInstaller by default makes single-arch builds that target the running architecture. You can try making a universal2 build, but it requires universal2 python build as well as all python packages that you use to be either pure-python or provide universal2 builds of their extensions (i.e., a single single-arch wheel, such as numpy, will make it impossible to create universal2 application).
So if you cannot make a universal2 build (due to dependencies), you can still make an x86_64 build on M1 by running a x86_64-only python environment under rosetta2.
Hi, @need4swede
That quote you specified about universal2
binaries not available due to arch-specific wheels has confused me a bit.
I am unable to build universal2
binaries on my x86_64 VM/Venv (via Github CI) for my project – however, I do not know if my issue is in correlation with what you had mentioned.
The dependencies that are designated for macOS are as follows:
plistlib
os
platform
requests
pyobjc
json
sys
shutil
queue
threading
And, as far as I'm aware, all of these should be available on Apple ARM64
and x86_64
.
I could be wrong of course! Please do correct me if I am.
Per ☝️ August 11, 2021:
Homebrew python is single-arch, so trying to build universal2 application should give you a build error."
Beyond the included packages supporting the target architecture(s), try using the official distribution of Python rather than the homebrew version.
% which python3
/Library/Frameworks/Python.framework/Versions/3.10/bin/python3
% file /Library/Frameworks/Python.framework/Versions/3.10/bin/python3
/Library/Frameworks/Python.framework/Versions/3.10/bin/python3: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit executable x86_64
- Mach-O 64-bit executable x86_64] [arm64:Mach-O 64-bit executable arm64
- Mach-O 64-bit executable arm64]
/Library/Frameworks/Python.framework/Versions/3.10/bin/python3 (for architecture x86_64): Mach-O 64-bit executable x86_64
/Library/Frameworks/Python.framework/Versions/3.10/bin/python3 (for architecture arm64): Mach-O 64-bit executable arm64
@machawk1
Interesting! A bit worried about installing a different version of Python alongside my homebrew version - I've messed up my environment doing so in the past. What's the best practice of installing the non-homebrew version without messing up my existing libraries? Thanks!
Hi, @machawk1
You are correct. It would appear that the Python version that actions/setup-python
installs is that for only the x86_64
architecture, as per this^1:
I suspect it's installing it via homebrew. It is in fact, not installing via homebrew—rather, they have their own releases page for binaries, which are arch-specific. No universal2
/arm64
support though for the Darwin kernel, as far as I can tell.
I wonder if I could manually install Python's official binaries via Github's CI?
Thanks once again!
Here's the code for the workflow itself:
Edit:
It would appear that this should available in python-versions
, which action/setup-python
uses to build binaries, as per this comment which references a PR^2 that should resolve it.
However, as you can probably tell - my workflow does not have this. I am most likely not adding a necessary YAML property, or it's just not available on the stable release yet—I will try with a prerelease and keep you updated.
Edit #2:
It does not seem to work, even with a Python release of 3.11.0-alpha.1
and actions/setup-python
version of v3
. The workflow^3 yields that the Python interpreter is for x86_64
architectures only – no sign of arm64
/universal2
support.
Edit #3:
The following comment^4 confirms that they do have universal2
support - they just haven't provided it to production builds yet, it seems. So... yay!
This remains an issue of dependencies support multi-architecture. With the --target-arch universal2
flags set in the pyinstaller command in MAKEFILE.sh
...
% which python3
/Library/Frameworks/Python.framework/Versions/3.11/bin/python3
% file /Library/Frameworks/Python.framework/Versions/3.11/bin/python3
/Library/Frameworks/Python.framework/Versions/3.11/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]
/Library/Frameworks/Python.framework/Versions/3.11/bin/python3 (for architecture x86_64): Mach-O 64-bit executable x86_64
/Library/Frameworks/Python.framework/Versions/3.11/bin/python3 (for architecture arm64): Mach-O 64-bit executable arm64
% sh bundledApps/MAKEFILE.sh
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.11/bin/pyinstaller", line 8, in <module>
sys.exit(_console_script_run())
^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/PyInstaller/__main__.py", line 194, in _console_script_run
run()
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/PyInstaller/__main__.py", line 180, in run
run_build(pyi_config, spec_file, **vars(args))
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/PyInstaller/__main__.py", line 61, in run_build
PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/PyInstaller/building/build_main.py", line 979, in main
build(specfile, distpath, workpath, clean_build)
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/PyInstaller/building/build_main.py", line 901, in build
exec(code, spec_namespace)
File "/private/tmp/wail/WAIL.spec", line 24, in <module>
exe = EXE(
^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/PyInstaller/building/api.py", line 576, in __init__
self.pkg = PKG(
^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/PyInstaller/building/api.py", line 233, in __init__
self.__postinit__()
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/PyInstaller/building/datastruct.py", line 173, in __postinit__
self.assemble()
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/PyInstaller/building/api.py", line 284, in assemble
src_name = checkCache(
^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/PyInstaller/building/utils.py", line 368, in checkCache
osxutils.binary_to_target_arch(cachedfile, target_arch, display_name=fnm)
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/PyInstaller/utils/osx.py", line 312, in binary_to_target_arch
raise IncompatibleBinaryArchError(f"{display_name} is not a fat binary!")
PyInstaller.utils.osx.IncompatibleBinaryArchError: /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/charset_normalizer/md__mypyc.cpython-311-darwin.so is not a fat binary!
pyinstaller==5.9.0
pyinstaller-hooks-contrib==2023.1
Relevant discussion in the charset_normalizer repo at https://github.com/Ousret/charset_normalizer/issues/277 .
https://github.com/Ousret/charset_normalizer/issues/253 also recommends:
Just sticking a from . import md__mypyc anywhere in a .py file where PyInstaller can see it would solve this.
Insisting that a version of charset_normalizer<3.0
is used allows the universal binary to compile. Let's go with this solution for now until something more comes from the charset_normalizer
maintainers.
Does anyone have a universal version of PyQt5?
With Macs available with either the x86_64 and arm64 platforms (Related:#494), Apple has a separate binary type (called
universal2
) that provides a binary that will work on both platforms.This should be usable on Pyinstaller with the flag
--target-arch universal2
but does not seem to work with Pyinstaller 5.0.dev0 (from source) with the bootloader built for arm64 (see https://github.com/machawk1/wail/issues/494#issuecomment-865257873 )The complaint is as follows but might stem on some dependencies also supporting this hybrid binary format: