@@ -42,13 +42,13 @@ class FrameworkInfo(object):
4242 self .sourceContentsDirectory = ""
4343 self .destinationResourcesDirectory = ""
4444 self .destinationVersionContentsDirectory = ""
45-
45+
4646 def __eq__ (self , other ):
4747 if self .__class__ == other .__class__ :
4848 return self .__dict__ == other .__dict__
4949 else :
5050 return False
51-
51+
5252 def __str__ (self ):
5353 return f""" Framework name: { self .frameworkName }
5454 Framework directory: { self .frameworkDirectory }
@@ -62,51 +62,51 @@ class FrameworkInfo(object):
6262 Source file Path: { self .sourceFilePath }
6363 Deployed Directory (relative to bundle): { self .destinationDirectory }
6464"""
65-
65+
6666 def isDylib (self ):
6767 return self .frameworkName .endswith (".dylib" )
68-
68+
6969 def isQtFramework (self ):
7070 if self .isDylib ():
7171 return self .frameworkName .startswith ("libQt" )
7272 else :
7373 return self .frameworkName .startswith ("Qt" )
74-
74+
7575 reOLine = re .compile (r'^(.+) \(compatibility version [0-9.]+, current version [0-9.]+\)$' )
7676 bundleFrameworkDirectory = "Contents/Frameworks"
7777 bundleBinaryDirectory = "Contents/MacOS"
78-
78+
7979 @classmethod
8080 def fromLibraryLine (cls , line : str ) -> Optional ['FrameworkInfo' ]:
8181 # Note: line must be trimmed
8282 if line == "" :
8383 return None
84-
84+
8585 # Don't deploy system libraries
8686 if line .startswith ("/System/Library/" ) or line .startswith ("@executable_path" ) or line .startswith ("/usr/lib/" ):
8787 return None
88-
88+
8989 m = cls .reOLine .match (line )
9090 if m is None :
9191 raise RuntimeError (f"Line could not be parsed: { line } " )
92-
92+
9393 path = m .group (1 )
94-
94+
9595 info = cls ()
9696 info .sourceFilePath = path
9797 info .installName = path
98-
98+
9999 if path .endswith (".dylib" ):
100100 dirname , filename = os .path .split (path )
101101 info .frameworkName = filename
102102 info .frameworkDirectory = dirname
103103 info .frameworkPath = path
104-
104+
105105 info .binaryDirectory = dirname
106106 info .binaryName = filename
107107 info .binaryPath = path
108108 info .version = "-"
109-
109+
110110 info .installName = path
111111 info .deployedInstallName = f"@executable_path/../Frameworks/{ info .binaryName } "
112112 info .sourceFilePath = path
@@ -121,25 +121,25 @@ class FrameworkInfo(object):
121121 i += 1
122122 if i == len (parts ):
123123 raise RuntimeError (f"Could not find .framework or .dylib in line: { line } " )
124-
124+
125125 info .frameworkName = parts [i ]
126126 info .frameworkDirectory = "/" .join (parts [:i ])
127127 info .frameworkPath = os .path .join (info .frameworkDirectory , info .frameworkName )
128-
128+
129129 info .binaryName = parts [i + 3 ]
130130 info .binaryDirectory = "/" .join (parts [i + 1 :i + 3 ])
131131 info .binaryPath = os .path .join (info .binaryDirectory , info .binaryName )
132132 info .version = parts [i + 2 ]
133-
133+
134134 info .deployedInstallName = f"@executable_path/../Frameworks/{ os .path .join (info .frameworkName , info .binaryPath )} "
135135 info .destinationDirectory = os .path .join (cls .bundleFrameworkDirectory , info .frameworkName , info .binaryDirectory )
136-
136+
137137 info .sourceResourcesDirectory = os .path .join (info .frameworkPath , "Resources" )
138138 info .sourceContentsDirectory = os .path .join (info .frameworkPath , "Contents" )
139139 info .sourceVersionContentsDirectory = os .path .join (info .frameworkPath , "Versions" , info .version , "Contents" )
140140 info .destinationResourcesDirectory = os .path .join (cls .bundleFrameworkDirectory , info .frameworkName , "Resources" )
141141 info .destinationVersionContentsDirectory = os .path .join (cls .bundleFrameworkDirectory , info .frameworkName , "Versions" , info .version , "Contents" )
142-
142+
143143 return info
144144
145145class ApplicationBundleInfo (object ):
@@ -289,45 +289,45 @@ def copyFramework(framework: FrameworkInfo, path: str, verbose: int) -> Optional
289289def deployFrameworks (frameworks : list [FrameworkInfo ], bundlePath : str , binaryPath : str , strip : bool , verbose : int , deploymentInfo : Optional [DeploymentInfo ] = None ) -> DeploymentInfo :
290290 if deploymentInfo is None :
291291 deploymentInfo = DeploymentInfo ()
292-
292+
293293 while len (frameworks ) > 0 :
294294 framework = frameworks .pop (0 )
295295 deploymentInfo .deployedFrameworks .append (framework .frameworkName )
296-
296+
297297 print ("Processing" , framework .frameworkName , "..." )
298-
298+
299299 # Get the Qt path from one of the Qt frameworks
300300 if deploymentInfo .qtPath is None and framework .isQtFramework ():
301301 deploymentInfo .detectQtPath (framework .frameworkDirectory )
302-
302+
303303 if framework .installName .startswith ("@executable_path" ) or framework .installName .startswith (bundlePath ):
304304 print (framework .frameworkName , "already deployed, skipping." )
305305 continue
306-
306+
307307 # install_name_tool the new id into the binary
308308 changeInstallName (framework .installName , framework .deployedInstallName , binaryPath , verbose )
309-
309+
310310 # Copy framework to app bundle.
311311 deployedBinaryPath = copyFramework (framework , bundlePath , verbose )
312312 # Skip the rest if already was deployed.
313313 if deployedBinaryPath is None :
314314 continue
315-
315+
316316 if strip :
317317 runStrip (deployedBinaryPath , verbose )
318-
318+
319319 # install_name_tool it a new id.
320320 changeIdentification (framework .deployedInstallName , deployedBinaryPath , verbose )
321321 # Check for framework dependencies
322322 dependencies = getFrameworks (deployedBinaryPath , verbose , rpath = framework .frameworkDirectory )
323-
323+
324324 for dependency in dependencies :
325325 changeInstallName (dependency .installName , dependency .deployedInstallName , deployedBinaryPath , verbose )
326-
326+
327327 # Deploy framework if necessary.
328328 if dependency .frameworkName not in deploymentInfo .deployedFrameworks and dependency not in frameworks :
329329 frameworks .append (dependency )
330-
330+
331331 return deploymentInfo
332332
333333def deployFrameworksForAppBundle (applicationBundle : ApplicationBundleInfo , strip : bool , verbose : int ) -> DeploymentInfo :
@@ -355,29 +355,29 @@ def deployPlugins(appBundleInfo: ApplicationBundleInfo, deploymentInfo: Deployme
355355 continue
356356
357357 plugins .append ((pluginDirectory , pluginName ))
358-
358+
359359 for pluginDirectory , pluginName in plugins :
360360 print ("Processing plugin" , os .path .join (pluginDirectory , pluginName ), "..." )
361-
361+
362362 sourcePath = os .path .join (deploymentInfo .pluginPath , pluginDirectory , pluginName )
363363 destinationDirectory = os .path .join (appBundleInfo .pluginPath , pluginDirectory )
364364 if not os .path .exists (destinationDirectory ):
365365 os .makedirs (destinationDirectory )
366-
366+
367367 destinationPath = os .path .join (destinationDirectory , pluginName )
368368 shutil .copy2 (sourcePath , destinationPath )
369369 if verbose :
370370 print ("Copied:" , sourcePath )
371371 print (" to:" , destinationPath )
372-
372+
373373 if strip :
374374 runStrip (destinationPath , verbose )
375-
375+
376376 dependencies = getFrameworks (destinationPath , verbose )
377-
377+
378378 for dependency in dependencies :
379379 changeInstallName (dependency .installName , dependency .deployedInstallName , destinationPath , verbose )
380-
380+
381381 # Deploy framework if necessary.
382382 if dependency .frameworkName not in deploymentInfo .deployedFrameworks :
383383 deployFrameworks ([dependency ], appBundleInfo .path , destinationPath , strip , verbose , deploymentInfo )
@@ -446,7 +446,7 @@ except RuntimeError as e:
446446
447447if config .plugins :
448448 print ("+ Deploying plugins +" )
449-
449+
450450 try :
451451 deployPlugins (applicationBundle , deploymentInfo , config .strip , verbose )
452452 except RuntimeError as e :
0 commit comments