15
15
16
16
MacOS
17
17
- brew install portaudio
18
+ - if you're using pyenv, you might also need to install tkinter manually.
19
+ I followed this guide https://dev.to/xshapira/using-tkinter-with-pyenv-a-simple-two-step-guide-hh5.
18
20
19
21
NOTES:
20
22
1. For use in future projects, note that pyinstaller will print hundreds of unrelated error messages, but to find
35
37
36
38
import os
37
39
import platform
40
+ import sys
38
41
39
42
import PyInstaller .__main__
40
43
41
44
from app .version import version
42
45
43
46
44
- def build ():
47
+ def build (signing_key = None ):
45
48
input ("Did you remember to increment version.py?" )
49
+ macos = platform .system () == 'Darwin'
46
50
51
+ compile (signing_key )
52
+
53
+ if macos and signing_key : # Codesign
54
+ os .system (
55
+ f'codesign --deep --force --verbose --sign "{ signing_key } " dist/Open\\ Interface.app --options runtime' )
56
+
57
+ # TODO: codesigning is invalid after I zip using this method, but remains valid if I zip using UI Archive.
58
+ zip_name = zip ()
59
+
60
+ if macos and signing_key : # Notarize
61
+ keychain_profile = signing_key .split ('(' )[0 ].strip ()
62
+ os .system (f'xcrun notarytool submit --wait --keychain-profile "{ keychain_profile } " --verbose dist/{ zip_name } ' )
63
+
64
+
65
+ def compile (signing_key = None ):
47
66
# Path to your main application script
48
67
app_script = os .path .join ('app' , 'app.py' )
49
68
@@ -85,7 +104,11 @@ def build():
85
104
]
86
105
87
106
# Platform-specific options
88
- if platform .system () == 'Linux' :
107
+ if platform .system () == 'Darwin' : # MacOS
108
+ pyinstaller_options .extend ([
109
+ f'--codesign-identity={ signing_key } '
110
+ ])
111
+ elif platform .system () == 'Linux' :
89
112
pyinstaller_options .extend ([
90
113
'--hidden-import=PIL._tkinter_finder' ,
91
114
'--hidden-import=openai' ,
@@ -100,26 +123,32 @@ def build():
100
123
PyInstaller .__main__ .run (pyinstaller_options )
101
124
print ('Done. Check dist/ for executables.' )
102
125
126
+
127
+ def zip ():
103
128
# Zip the app
104
129
print ('Zipping the executables' )
105
130
app_name = 'Open\\ Interface'
106
131
132
+ zip_name = 'Open-Interface-v' + str (version )
107
133
if platform .system () == 'Darwin' : # MacOS
108
- zip_name = 'Open-Interface-v' + str ( version ) + '-MacOS' + '.zip'
134
+ zip_name = zip_name + '-MacOS' + '.zip'
109
135
zip_cli_command = 'cd dist/; zip -r9 ' + zip_name + ' ' + app_name + '.app'
110
- input (f'zip_cli_command - { zip_cli_command } \n Execute?' )
111
- os .system (zip_cli_command )
112
136
elif platform .system () == 'Linux' :
113
- zip_name = 'Open-Interface-v' + str ( version ) + '-Linux' + '.zip'
137
+ zip_name = zip_name + '-Linux' + '.zip'
114
138
zip_cli_command = 'cd dist/; zip -r9 ' + zip_name + ' ' + app_name
115
- input (f'zip_cli_command - { zip_cli_command } \n Execute?' )
116
- os .system (zip_cli_command )
117
139
elif platform .system () == 'Windows' :
118
- zip_name = 'Open-Interface-v' + str ( version ) + '-Windows' + '.zip'
140
+ zip_name = zip_name + '-Windows' + '.zip'
119
141
zip_cli_command = 'cd dist & powershell Compress-Archive -Path \' Open Interface.exe\' -DestinationPath ' + zip_name
120
- input (f'zip_cli_command - { zip_cli_command } \n Execute?' )
121
- os .system (zip_cli_command )
142
+
143
+ # input(f'zip_cli_command - {zip_cli_command} \nExecute?')
144
+ os .system (zip_cli_command )
145
+ return zip_name
122
146
123
147
124
148
if __name__ == "__main__" :
125
- build ()
149
+ apple_code_signing_key = None
150
+ if len (sys .argv ) > 1 :
151
+ apple_code_signing_key = sys .argv [1 ] # Developer ID Application: ... (...)
152
+ print ("apple_code_signing_key: " , apple_code_signing_key )
153
+
154
+ build (apple_code_signing_key )
0 commit comments