OpenAdapt
OpenAdapt copied to clipboard
[Bug]: build fails on M2
Describe the bug
Building on MacOS running on Apple Silicon fails:
python openadapt/build.py
...
136272 INFO: Converting EXE to target arch (arm64) 09:37:57 [256/80932]
136496 INFO: Removing signature(s) from EXE
136569 INFO: Appending PKG archive to EXE
136682 INFO: Fixing EXE headers for code signing
136684 INFO: Re-signing the EXE
137030 INFO: Building EXE from EXE-00.toc completed successfully.
137265 INFO: checking COLLECT
137265 INFO: Building COLLECT because COLLECT-00.toc is non existent
137265 INFO: Building COLLECT COLLECT-00.toc
Traceback (most recent call last):
File "/Users/abrichr/Library/Caches/pypoetry/virtualenvs/openadapt-VBXg4jpm-py3.10/bin/pyinstaller", line 8, in <module>
sys.exit(_console_script_run())
File "/Users/abrichr/Library/Caches/pypoetry/virtualenvs/openadapt-VBXg4jpm-py3.10/lib/python3.10/site-packages/PyInstaller/__main__.py", line 228, in _console_script_run
run()
File "/Users/abrichr/Library/Caches/pypoetry/virtualenvs/openadapt-VBXg4jpm-py3.10/lib/python3.10/site-packages/PyInstaller/__main__.py", line 212, in run
run_build(pyi_config, spec_file, **vars(args))
File "/Users/abrichr/Library/Caches/pypoetry/virtualenvs/openadapt-VBXg4jpm-py3.10/lib/python3.10/site-packages/PyInstaller/__main__.py", line 69, in run_build
PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
File "/Users/abrichr/Library/Caches/pypoetry/virtualenvs/openadapt-VBXg4jpm-py3.10/lib/python3.10/site-packages/PyInstaller/building/build_main.py", line 1139, in main
build(specfile, distpath, workpath, clean_build)
File "/Users/abrichr/Library/Caches/pypoetry/virtualenvs/openadapt-VBXg4jpm-py3.10/lib/python3.10/site-packages/PyInstaller/building/build_main.py", line 1079, in build
exec(code, spec_namespace)
File "OpenAdapt.spec", line 40, in <module>
coll = COLLECT(
File "/Users/abrichr/Library/Caches/pypoetry/virtualenvs/openadapt-VBXg4jpm-py3.10/lib/python3.10/site-packages/PyInstaller/building/api.py", line 1092, in __init__
self.__postinit__()
File "/Users/abrichr/Library/Caches/pypoetry/virtualenvs/openadapt-VBXg4jpm-py3.10/lib/python3.10/site-packages/PyInstaller/building/datastruct.py", line 184, in __postinit__
self.assemble()
File "/Users/abrichr/Library/Caches/pypoetry/virtualenvs/openadapt-VBXg4jpm-py3.10/lib/python3.10/site-packages/PyInstaller/building/api.py", line 1138, in assemble
src_name = process_collected_binary(
File "/Users/abrichr/Library/Caches/pypoetry/virtualenvs/openadapt-VBXg4jpm-py3.10/lib/python3.10/site-packages/PyInstaller/building/utils.py", line 309, in process_collected_binary
osxutils.binary_to_target_arch(cached_name, target_arch, display_name=src_name)
File "/Users/abrichr/Library/Caches/pypoetry/virtualenvs/openadapt-VBXg4jpm-py3.10/lib/python3.10/site-packages/PyInstaller/utils/osx.py", line 351, in binary_to_target_arch
raise IncompatibleBinaryArchError(
PyInstaller.utils.osx.IncompatibleBinaryArchError: /Users/abrichr/Library/Caches/pypoetry/virtualenvs/openadapt-VBXg4jpm-py3.10/lib/python3.10/site-packages/sqlalchemy/cresultproxy.cpython-310-darwin.so is incompatible with target arch arm64 (has arch: x86_64)!
Traceback (most recent call last):
File "/opt/homebrew/Cellar/[email protected]/3.10.14/Frameworks/Python.framework/Versions/3.10/lib/python3.10/shutil.py", line 816, in move
os.rename(src, real_dst)
FileNotFoundError: [Errno 2] No such file or directory: '/Users/abrichr/oa/OpenAdapt/dist/OpenAdapt.app/Contents/MacOS/OpenAdapt' -> '/Users/abrichr/oa/OpenAdapt/dist/OpenAdapt.app/Contents/MacOS/OpenAdapt.app'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/abrichr/oa/OpenAdapt/openadapt/build.py", line 180, in <module>
main()
File "/Users/abrichr/oa/OpenAdapt/openadapt/build.py", line 164, in main
shutil.move(
File "/opt/homebrew/Cellar/[email protected]/3.10.14/Frameworks/Python.framework/Versions/3.10/lib/python3.10/shutil.py", line 836, in move
copy_function(src, real_dst)
File "/opt/homebrew/Cellar/[email protected]/3.10.14/Frameworks/Python.framework/Versions/3.10/lib/python3.10/shutil.py", line 434, in copy2
copyfile(src, dst, follow_symlinks=follow_symlinks)
File "/opt/homebrew/Cellar/[email protected]/3.10.14/Frameworks/Python.framework/Versions/3.10/lib/python3.10/shutil.py", line 254, in copyfile
with open(src, 'rb') as fsrc:
FileNotFoundError: [Errno 2] No such file or directory: '/Users/abrichr/oa/OpenAdapt/dist/OpenAdapt.app/Contents/MacOS/OpenAdapt'
As per https://pyinstaller.org/en/latest/feature-notes.html#macos-multi-arch-support, I tried replacing this line in build.py:
proc = subprocess.Popen("pyinstaller OpenAdapt.spec --noconfirm", shell=True)
With this:
proc = subprocess.Popen("pyinstaller OpenAdapt.spec --noconfirm —-target-arch x86_64", shell=True)
Which caused this error:
Wrote /Users/abrichr/oa/OpenAdapt/OpenAdapt.spec.
Now run pyinstaller.py to build the executable.
usage: pyinstaller [-h] [-v] [-D] [-F] [--specpath DIR] [-n NAME] [--contents-directory CONTENTS_DIRECTORY] [--add-data SOURCE:DEST] [--add-binary SOURCE:DEST] [-p DIR] [--hidden-import MODULENAME] [--collect-submodules MODULENAME] [--collect-data MODULENAME] [--collect-binaries MODULENAME]
[--collect-all MODULENAME] [--copy-metadata PACKAGENAME] [--recursive-copy-metadata PACKAGENAME] [--additional-hooks-dir HOOKSPATH] [--runtime-hook RUNTIME_HOOKS] [--exclude-module EXCLUDES] [--splash IMAGE_FILE] [-d {all,imports,bootloader,noarchive}]
[--python-option PYTHON_OPTION] [-s] [--noupx] [--upx-exclude FILE] [-c] [-w] [--hide-console {minimize-late,minimize-early,hide-early,hide-late}] [-i <FILE.ico or FILE.exe,ID or FILE.icns or Image or "NONE">] [--disable-windowed-traceback] [--version-file FILE]
[-m <FILE or XML>] [-r RESOURCE] [--uac-admin] [--uac-uiaccess] [--argv-emulation] [--osx-bundle-identifier BUNDLE_IDENTIFIER] [--target-architecture ARCH] [--codesign-identity IDENTITY] [--osx-entitlements-file FILENAME] [--runtime-tmpdir PATH] [--bootloader-ignore-signals]
[--distpath DIR] [--workpath WORKPATH] [-y] [--upx-dir UPX_DIR] [--clean] [--log-level LEVEL]
scriptname [scriptname ...]
pyinstaller: error: unrecognized arguments: —-target-arch x86_64
Traceback (most recent call last):
File "/opt/homebrew/Cellar/[email protected]/3.10.14/Frameworks/Python.framework/Versions/3.10/lib/python3.10/shutil.py", line 816, in move
os.rename(src, real_dst)
FileNotFoundError: [Errno 2] No such file or directory: '/Users/abrichr/oa/OpenAdapt/dist/OpenAdapt.app/Contents/MacOS/OpenAdapt' -> '/Users/abrichr/oa/OpenAdapt/dist/OpenAdapt.app/Contents/MacOS/OpenAdapt.app'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/abrichr/oa/OpenAdapt/openadapt/build.py", line 180, in <module>
main()
File "/Users/abrichr/oa/OpenAdapt/openadapt/build.py", line 164, in main
shutil.move(
File "/opt/homebrew/Cellar/[email protected]/3.10.14/Frameworks/Python.framework/Versions/3.10/lib/python3.10/shutil.py", line 836, in move
copy_function(src, real_dst)
File "/opt/homebrew/Cellar/[email protected]/3.10.14/Frameworks/Python.framework/Versions/3.10/lib/python3.10/shutil.py", line 434, in copy2
copyfile(src, dst, follow_symlinks=follow_symlinks)
File "/opt/homebrew/Cellar/[email protected]/3.10.14/Frameworks/Python.framework/Versions/3.10/lib/python3.10/shutil.py", line 254, in copyfile
with open(src, 'rb') as fsrc:
FileNotFoundError: [Errno 2] No such file or directory: '/Users/abrichr/oa/OpenAdapt/dist/OpenAdapt.app/Contents/MacOS/OpenAdapt'
To Reproduce
On Apple silicon:
python openadapt/build.py