Skip to content

Commit 05e3f93

Browse files
committed
Added macos codesigning and notarization in the build script, fixed microphone permission bug
1 parent e3a8ff8 commit 05e3f93

File tree

3 files changed

+32
-11
lines changed

3 files changed

+32
-11
lines changed

app/ui.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ def voice_input(self) -> None:
273273
recognizer = sr.Recognizer()
274274
with sr.Microphone() as source:
275275
self.update_message('Listening...')
276+
recognizer.adjust_for_ambient_noise(source) # This might also help with asking for mic permissions on Macs
276277
try:
277278
audio = recognizer.listen(source, timeout=4)
278279
try:

app/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
from packaging.version import Version
22

3-
version = Version('0.5.0')
3+
version = Version('0.5.1')

build.py

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,21 +45,31 @@
4545

4646

4747
def build(signing_key=None):
48-
input("Did you remember to increment version.py?")
49-
macos = platform.system() == 'Darwin'
48+
input("Did you remember to increment version.py? " + str(version))
49+
app_name = "Open\\ Interface"
5050

5151
compile(signing_key)
5252

53-
if macos and signing_key: # Codesign
53+
macos = platform.system() == 'Darwin'
54+
if macos and signing_key:
55+
# Codesign
5456
os.system(
55-
f'codesign --deep --force --verbose --sign "{signing_key}" dist/Open\\ Interface.app --options runtime')
57+
f'codesign --deep --force --verbose --sign "{signing_key}" dist/{app_name}.app --options runtime')
5658

57-
# TODO: codesigning is invalid after I zip using this method, but remains valid if I zip using UI Archive.
5859
zip_name = zip()
5960

60-
if macos and signing_key: # Notarize
61+
if macos and signing_key:
6162
keychain_profile = signing_key.split('(')[0].strip()
63+
64+
# Notarize
6265
os.system(f'xcrun notarytool submit --wait --keychain-profile "{keychain_profile}" --verbose dist/{zip_name}')
66+
input(f'Check whether notarization was successful. You can check further logs using "xcrun notarytool log --keychain-profile {keychain_profile} <run-id>"')
67+
68+
# Staple
69+
os.system(f'xcrun stapler staple dist/{app_name}.app')
70+
71+
# Zip the signed, stapled file
72+
zip_name = zip()
6373

6474

6575
def compile(signing_key=None):
@@ -108,6 +118,11 @@ def compile(signing_key=None):
108118
pyinstaller_options.extend([
109119
f'--codesign-identity={signing_key}'
110120
])
121+
122+
# Apple Notarization has a problem because this binary used in speech_recognition is signed with too old an SDK
123+
from PyInstaller.utils.osx import set_macos_sdk_version
124+
set_macos_sdk_version('env/lib/python3.12/site-packages/speech_recognition/flac-mac', 10, 9, 0) # NOTE: Change the path according to where your binary is located
125+
111126
elif platform.system() == 'Linux':
112127
pyinstaller_options.extend([
113128
'--hidden-import=PIL._tkinter_finder',
@@ -131,13 +146,18 @@ def zip():
131146

132147
zip_name = 'Open-Interface-v' + str(version)
133148
if platform.system() == 'Darwin': # MacOS
134-
zip_name = zip_name + '-MacOS' + '.zip'
135-
zip_cli_command = 'cd dist/; zip -r9 ' + zip_name + ' ' + app_name + '.app'
149+
if platform.processor() == 'arm':
150+
zip_name = zip_name + '-MacOS-M-Series' + '.zip'
151+
else:
152+
zip_name = zip_name + '-MacOS-Intel' + '.zip'
153+
154+
# Special zip command for macos to keep the complex directory metadata intact to keep the codesigning valid
155+
zip_cli_command = 'cd dist/; ditto -c -k --sequesterRsrc --keepParent ' + app_name + '.app ' + zip_name
136156
elif platform.system() == 'Linux':
137-
zip_name = zip_name + '-Linux' + '.zip'
157+
zip_name = zip_name + '-Linux.zip'
138158
zip_cli_command = 'cd dist/; zip -r9 ' + zip_name + ' ' + app_name
139159
elif platform.system() == 'Windows':
140-
zip_name = zip_name + '-Windows' + '.zip'
160+
zip_name = zip_name + '-Windows.zip'
141161
zip_cli_command = 'cd dist & powershell Compress-Archive -Path \'Open Interface.exe\' -DestinationPath ' + zip_name
142162

143163
# input(f'zip_cli_command - {zip_cli_command} \nExecute?')

0 commit comments

Comments
 (0)