19
19
import subprocess , sys , re , os , shutil , stat , os .path , time
20
20
from string import Template
21
21
from argparse import ArgumentParser
22
+ from typing import List , Optional
22
23
23
24
# This is ported from the original macdeployqt with modifications
24
25
@@ -85,7 +86,7 @@ class FrameworkInfo(object):
85
86
bundleBinaryDirectory = "Contents/MacOS"
86
87
87
88
@classmethod
88
- def fromOtoolLibraryLine (cls , line ) :
89
+ def fromOtoolLibraryLine (cls , line : str ) -> Optional [ 'FrameworkInfo' ] :
89
90
# Note: line must be trimmed
90
91
if line == "" :
91
92
return None
@@ -152,7 +153,7 @@ class FrameworkInfo(object):
152
153
return info
153
154
154
155
class ApplicationBundleInfo (object ):
155
- def __init__ (self , path ):
156
+ def __init__ (self , path : str ):
156
157
self .path = path
157
158
appName = "Bitcoin-Qt"
158
159
self .binaryPath = os .path .join (path , "Contents" , "MacOS" , appName )
@@ -167,7 +168,7 @@ class DeploymentInfo(object):
167
168
self .pluginPath = None
168
169
self .deployedFrameworks = []
169
170
170
- def detectQtPath (self , frameworkDirectory ):
171
+ def detectQtPath (self , frameworkDirectory : str ):
171
172
parentDir = os .path .dirname (frameworkDirectory )
172
173
if os .path .exists (os .path .join (parentDir , "translations" )):
173
174
# Classic layout, e.g. "/usr/local/Trolltech/Qt-4.x.x"
@@ -180,7 +181,7 @@ class DeploymentInfo(object):
180
181
if os .path .exists (pluginPath ):
181
182
self .pluginPath = pluginPath
182
183
183
- def usesFramework (self , name ) :
184
+ def usesFramework (self , name : str ) -> bool :
184
185
nameDot = "%s." % name
185
186
libNameDot = "lib%s." % name
186
187
for framework in self .deployedFrameworks :
@@ -192,7 +193,7 @@ class DeploymentInfo(object):
192
193
return True
193
194
return False
194
195
195
- def getFrameworks (binaryPath , verbose ) :
196
+ def getFrameworks (binaryPath : str , verbose : int ) -> List [ FrameworkInfo ] :
196
197
if verbose >= 3 :
197
198
print ("Inspecting with otool: " + binaryPath )
198
199
otoolbin = os .getenv ("OTOOL" , "otool" )
@@ -221,33 +222,33 @@ def getFrameworks(binaryPath, verbose):
221
222
222
223
return libraries
223
224
224
- def runInstallNameTool (action , * args ):
225
+ def runInstallNameTool (action : str , * args ):
225
226
installnametoolbin = os .getenv ("INSTALLNAMETOOL" , "install_name_tool" )
226
227
subprocess .check_call ([installnametoolbin , "-" + action ] + list (args ))
227
228
228
- def changeInstallName (oldName , newName , binaryPath , verbose ):
229
+ def changeInstallName (oldName : str , newName : str , binaryPath : str , verbose : int ):
229
230
if verbose >= 3 :
230
231
print ("Using install_name_tool:" )
231
232
print (" in" , binaryPath )
232
233
print (" change reference" , oldName )
233
234
print (" to" , newName )
234
235
runInstallNameTool ("change" , oldName , newName , binaryPath )
235
236
236
- def changeIdentification (id , binaryPath , verbose ):
237
+ def changeIdentification (id : str , binaryPath : str , verbose : int ):
237
238
if verbose >= 3 :
238
239
print ("Using install_name_tool:" )
239
240
print (" change identification in" , binaryPath )
240
241
print (" to" , id )
241
242
runInstallNameTool ("id" , id , binaryPath )
242
243
243
- def runStrip (binaryPath , verbose ):
244
+ def runStrip (binaryPath : str , verbose : int ):
244
245
stripbin = os .getenv ("STRIP" , "strip" )
245
246
if verbose >= 3 :
246
247
print ("Using strip:" )
247
248
print (" stripped" , binaryPath )
248
249
subprocess .check_call ([stripbin , "-x" , binaryPath ])
249
250
250
- def copyFramework (framework , path , verbose ) :
251
+ def copyFramework (framework : FrameworkInfo , path : str , verbose : int ) -> Optional [ str ] :
251
252
if framework .sourceFilePath .startswith ("Qt" ):
252
253
#standard place for Nokia Qt installer's frameworks
253
254
fromPath = "/Library/Frameworks/" + framework .sourceFilePath
@@ -309,7 +310,7 @@ def copyFramework(framework, path, verbose):
309
310
310
311
return toPath
311
312
312
- def deployFrameworks (frameworks , bundlePath , binaryPath , strip , verbose , deploymentInfo = None ):
313
+ def deployFrameworks (frameworks : List [ FrameworkInfo ] , bundlePath : str , binaryPath : str , strip : bool , verbose : int , deploymentInfo : Optional [ DeploymentInfo ] = None ) -> DeploymentInfo :
313
314
if deploymentInfo is None :
314
315
deploymentInfo = DeploymentInfo ()
315
316
@@ -355,15 +356,15 @@ def deployFrameworks(frameworks, bundlePath, binaryPath, strip, verbose, deploym
355
356
356
357
return deploymentInfo
357
358
358
- def deployFrameworksForAppBundle (applicationBundle , strip , verbose ) :
359
+ def deployFrameworksForAppBundle (applicationBundle : ApplicationBundleInfo , strip : bool , verbose : int ) -> DeploymentInfo :
359
360
frameworks = getFrameworks (applicationBundle .binaryPath , verbose )
360
361
if len (frameworks ) == 0 and verbose >= 1 :
361
362
print ("Warning: Could not find any external frameworks to deploy in %s." % (applicationBundle .path ))
362
363
return DeploymentInfo ()
363
364
else :
364
365
return deployFrameworks (frameworks , applicationBundle .path , applicationBundle .binaryPath , strip , verbose )
365
366
366
- def deployPlugins (appBundleInfo , deploymentInfo , strip , verbose ):
367
+ def deployPlugins (appBundleInfo : ApplicationBundleInfo , deploymentInfo : DeploymentInfo , strip : bool , verbose : int ):
367
368
# Lookup available plugins, exclude unneeded
368
369
plugins = []
369
370
if deploymentInfo .pluginPath is None :
@@ -707,7 +708,7 @@ elif config.sign:
707
708
708
709
if config .dmg is not None :
709
710
710
- def runHDIUtil (verb , image_basename , ** kwargs ):
711
+ def runHDIUtil (verb : str , image_basename : str , ** kwargs ) -> int :
711
712
hdiutil_args = ["hdiutil" , verb , image_basename + ".dmg" ]
712
713
if "capture_stdout" in kwargs :
713
714
del kwargs ["capture_stdout" ]
0 commit comments