Fix Mac build (#30)

- Add codesigning and notarizing steps to PyInstaller binary
This commit is contained in:
Chidi Williams 2022-10-09 17:11:03 +01:00 committed by GitHub
parent 053fa0ad73
commit cf99a8a68d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 105 additions and 35 deletions

1
.gitignore vendored
View file

@ -3,3 +3,4 @@ __pycache__/
build/
.pytest_cache/
.coverage
.env

View file

@ -22,8 +22,7 @@ a = Analysis(
pathex=[],
binaries=[],
datas=datas,
hiddenimports=['apiclient', 'sounddevice', 'pytorch', '“sklearn.utils._cython_blas”', '“sklearn.neighbors.typedefs”',
'“sklearn.neighbors.quad_tree”', '“sklearn.tree”', '“sklearn.tree._utils”'],
hiddenimports=[],
hookspath=[],
hooksconfig={},
runtime_hooks=[],
@ -41,7 +40,7 @@ exe = EXE(
[],
exclude_binaries=True,
name='Buzz',
debug=False,
debug=True,
bootloader_ignore_signals=False,
strip=False,
upx=True,
@ -58,7 +57,7 @@ coll = COLLECT(
a.zipfiles,
a.datas,
strip=False,
upx=True,
upx=False,
upx_exclude=[],
name='Buzz',
)
@ -69,6 +68,7 @@ app = BUNDLE(
bundle_identifier=None,
version='0.0.1',
info_plist={
'NSPrincipalClass': 'NSApplication',
'NSMicrophoneUsageDescription': 'Please provide microphone access to continue'
}
)

View file

@ -1,4 +1,5 @@
buzz:
make clean
pyinstaller --noconfirm Buzz.spec
clean:
@ -7,21 +8,8 @@ clean:
test:
pytest --cov --cov-fail-under=73
bundle_mac:
make buzz
tar -czf dist/buzz-${version}-mac.tar.gz dist/Buzz
mkdir -p dist/dmg && cp -r dist/Buzz.app dist/dmg
create-dmg \
--volname "Buzz" \
--volicon "dist/Buzz.app/Contents/Resources/icon-windowed.icns" \
--window-pos 200 120 \
--window-size 600 300 \
--icon-size 100 \
--icon "dist/Buzz.app/Contents/Resources/icon-windowed.icns" 175 120 \
--hide-extension "Buzz.app" \
--app-drop-link 425 120 \
"dist/buzz-${version}-mac.dmg" \
"dist/dmg/"
version:
poetry version ${version}
bundle_linux:
make buzz
@ -31,8 +19,75 @@ bundle_windows:
make buzz
tar -czf dist/buzz-${version}-windows.tar.gz dist/Buzz
release:
make clean
make bundle_mac version=${version}
poetry version ${version}
git tag "v${version}"
# MAC
mac_app_path := ./dist/Buzz.app
mac_zip_path := ./dist/Buzz-$$BUZZ_VERSION-mac.zip
mac_dmg_path := ./dist/Buzz-$$BUZZ_VERSION-mac.dmg
bundle_mac:
make buzz
bundle_mac_local:
source .env
make buzz
make codesign_all_mac
make zip_mac
make notarize_zip
make staple_app_mac
make dmg_mac
staple_app_mac:
xcrun stapler staple ${mac_app_path}
codesign_all_mac:
make codesign_mac path="./dist/Buzz.app"
make codesign_mac path="./dist/Buzz.app/Contents/MacOS/Buzz"
for i in $$(find dist/Buzz.app/Contents/Resources -name "*.dylib" -o -name "*.so" -type f); \
do \
make codesign_mac path="$$i"; \
done
for i in $$(find dist/Buzz.app/Contents/Resources/torch/bin -name "*" -type f); \
do \
make codesign_mac path="$$i"; \
done
make codesign_mac path="./dist/Buzz.app/Contents/MacOS/Buzz"
make codesign_verify
codesign_mac:
codesign --deep --force --options=runtime --entitlements ./entitlements.plist --sign "$$BUZZ_CODESIGN_IDENTITY" --timestamp ${path}
zip_mac:
ditto -c -k --keepParent "${mac_app_path}" "${mac_zip_path}"
# Prints all the Mac developer identities used for code signing
print_identities_mac:
security find-identity -p basic -v
notarize_zip:
xcrun notarytool submit ${mac_zip_path} --keychain-profile "$$BUZZ_KEYCHAIN_NOTARY_PROFILE" --wait
dmg_mac:
ditto -x -k "${mac_zip_path}" dist/dmg
create-dmg \
--volname "Buzz" \
--volicon "dist/Buzz.app/Contents/Resources/icon-windowed.icns" \
--window-pos 200 120 \
--window-size 600 300 \
--icon-size 100 \
--icon "dist/Buzz.app/Contents/Resources/icon-windowed.icns" 175 120 \
--hide-extension "Buzz.app" \
--app-drop-link 425 120 \
--codesign "$$BUZZ_CODESIGN_IDENTITY" \
--notarize "$$BUZZ_KEYCHAIN_NOTARY_PROFILE" \
"${mac_dmg_path}" \
"dist/dmg/"
# HELPERS
# Get the build logs for a notary upload
notarize_log:
xcrun notarytool log ${id} --keychain-profile "$$BUZZ_KEYCHAIN_NOTARY_PROFILE"
codesign_verify:
codesign --verify --deep --strict --verbose=2 dist/Buzz.app

13
entitlements.plist Normal file
View file

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<!-- These are required for binaries built by PyInstaller -->
<key>com.apple.security.cs.allow-jit</key>
<true/>
<key>com.apple.security.cs.allow-unsigned-executable-memory</key>
<true/>
<key>com.apple.security.cs.disable-library-validation</key>
<true/>
</dict>
</plist>

11
main.py
View file

@ -2,9 +2,10 @@ import logging
from gui import Application
logging.basicConfig(
level=logging.DEBUG,
format="[%(asctime)s] %(module)s.%(funcName)s:%(lineno)d %(levelname)s -> %(message)s")
if __name__ == "__main__":
logging.basicConfig(
level=logging.DEBUG,
format="[%(asctime)s] %(module)s.%(funcName)s:%(lineno)d %(levelname)s -> %(message)s")
app = Application()
app.exec()
app = Application()
app.exec()

10
poetry.lock generated
View file

@ -586,7 +586,7 @@ vision = ["Pillow"]
[[package]]
name = "typing-extensions"
version = "4.3.0"
version = "4.4.0"
description = "Backported and Experimental Type Hints for Python 3.7+"
category = "main"
optional = false
@ -633,8 +633,8 @@ resolved_reference = "9e653bd0ea0f1e9493cb4939733e9de249493cfb"
[metadata]
lock-version = "1.1"
python-versions = "~3.9.13"
content-hash = "317773e01f6d9ee6f87008201e2e2a7bf13b9cbd540f5ffdf2539552b40646ed"
python-versions = ">=3.9.13,<3.11"
content-hash = "4d513d8ce53834bf3148561aad6989ee83ec44a54ae41314537dc5224d9515b5"
[metadata.files]
altgraph = [
@ -1168,8 +1168,8 @@ transformers = [
{file = "transformers-4.22.2.tar.gz", hash = "sha256:bbdd0271d86b23e86b4ad83b38e82681105dd6b080e142b16af5f5f3b68fefc4"},
]
typing-extensions = [
{file = "typing_extensions-4.3.0-py3-none-any.whl", hash = "sha256:25642c956049920a5aa49edcdd6ab1e06d7e5d467fc00e0506c44ac86fbfca02"},
{file = "typing_extensions-4.3.0.tar.gz", hash = "sha256:e6d2677a32f47fc7eb2795db1dd15c1f34eff616bcaf2cfb5e997f854fa1c4a6"},
{file = "typing_extensions-4.4.0-py3-none-any.whl", hash = "sha256:16fa4864408f655d35ec496218b85f79b3437c829e93320c7c9215ccfd92489e"},
{file = "typing_extensions-4.4.0.tar.gz", hash = "sha256:1511434bb92bf8dd198c12b1cc812e800d4181cfcb867674e0f8279cc93087aa"},
]
urllib3 = [
{file = "urllib3-1.26.12-py2.py3-none-any.whl", hash = "sha256:b930dd878d5a8afb066a637fbb35144fe7901e3b209d1cd4f524bd0e9deee997"},

View file

@ -7,7 +7,7 @@ license = "MIT"
readme = "README.md"
[tool.poetry.dependencies]
python = "~3.9.13"
python = ">=3.9.13,<3.11"
sounddevice = "^0.4.5"
whisper = {git = "https://github.com/openai/whisper.git"}
PyQt5 = "^5.15.7"