@@ -53,28 +53,18 @@ class FrameworkInfo(object):
53
53
return False
54
54
55
55
def __str__ (self ):
56
- return """ Framework name: {}
57
- Framework directory: {}
58
- Framework path: {}
59
- Binary name: {}
60
- Binary directory: {}
61
- Binary path: {}
62
- Version: {}
63
- Install name: {}
64
- Deployed install name: {}
65
- Source file Path: {}
66
- Deployed Directory (relative to bundle): {}
67
- """ .format (self .frameworkName ,
68
- self .frameworkDirectory ,
69
- self .frameworkPath ,
70
- self .binaryName ,
71
- self .binaryDirectory ,
72
- self .binaryPath ,
73
- self .version ,
74
- self .installName ,
75
- self .deployedInstallName ,
76
- self .sourceFilePath ,
77
- self .destinationDirectory )
56
+ return f""" Framework name: { frameworkName }
57
+ Framework directory: { self .frameworkDirectory }
58
+ Framework path: { self .frameworkPath }
59
+ Binary name: { self .binaryName }
60
+ Binary directory: { self .binaryDirectory }
61
+ Binary path: { self .binaryPath }
62
+ Version: { self .version }
63
+ Install name: { self .installName }
64
+ Deployed install name: { self .deployedInstallName }
65
+ Source file Path: { self .sourceFilePath }
66
+ Deployed Directory (relative to bundle): { self .destinationDirectory }
67
+ """
78
68
79
69
def isDylib (self ):
80
70
return self .frameworkName .endswith (".dylib" )
@@ -101,7 +91,7 @@ class FrameworkInfo(object):
101
91
102
92
m = cls .reOLine .match (line )
103
93
if m is None :
104
- raise RuntimeError ("otool line could not be parsed: " + line )
94
+ raise RuntimeError (f "otool line could not be parsed: { line } " )
105
95
106
96
path = m .group (1 )
107
97
@@ -121,7 +111,7 @@ class FrameworkInfo(object):
121
111
info .version = "-"
122
112
123
113
info .installName = path
124
- info .deployedInstallName = "@executable_path/../Frameworks/" + info .binaryName
114
+ info .deployedInstallName = f "@executable_path/../Frameworks/{ info .binaryName } "
125
115
info .sourceFilePath = path
126
116
info .destinationDirectory = cls .bundleFrameworkDirectory
127
117
else :
@@ -133,7 +123,7 @@ class FrameworkInfo(object):
133
123
break
134
124
i += 1
135
125
if i == len (parts ):
136
- raise RuntimeError ("Could not find .framework or .dylib in otool line: " + line )
126
+ raise RuntimeError (f "Could not find .framework or .dylib in otool line: { line } " )
137
127
138
128
info .frameworkName = parts [i ]
139
129
info .frameworkDirectory = "/" .join (parts [:i ])
@@ -144,7 +134,7 @@ class FrameworkInfo(object):
144
134
info .binaryPath = os .path .join (info .binaryDirectory , info .binaryName )
145
135
info .version = parts [i + 2 ]
146
136
147
- info .deployedInstallName = "@executable_path/../Frameworks/" + os .path .join (info .frameworkName , info .binaryPath )
137
+ info .deployedInstallName = f "@executable_path/../Frameworks/{ os .path .join (info .frameworkName , info .binaryPath )} "
148
138
info .destinationDirectory = os .path .join (cls .bundleFrameworkDirectory , info .frameworkName , info .binaryDirectory )
149
139
150
140
info .sourceResourcesDirectory = os .path .join (info .frameworkPath , "Resources" )
@@ -158,10 +148,10 @@ class FrameworkInfo(object):
158
148
class ApplicationBundleInfo (object ):
159
149
def __init__ (self , path : str ):
160
150
self .path = path
161
- appName = " Bitcoin-Qt"
162
- self .binaryPath = os .path .join (path , "Contents" , "MacOS" , appName )
151
+ # for backwards compatibility reasons, this must remain as Bitcoin-Qt
152
+ self .binaryPath = os .path .join (path , "Contents" , "MacOS" , "Bitcoin-Qt" )
163
153
if not os .path .exists (self .binaryPath ):
164
- raise RuntimeError ("Could not find bundle binary for " + path )
154
+ raise RuntimeError (f "Could not find bundle binary for { path } " )
165
155
self .resourcesPath = os .path .join (path , "Contents" , "Resources" )
166
156
self .pluginPath = os .path .join (path , "Contents" , "PlugIns" )
167
157
@@ -185,26 +175,24 @@ class DeploymentInfo(object):
185
175
self .pluginPath = pluginPath
186
176
187
177
def usesFramework (self , name : str ) -> bool :
188
- nameDot = "{}." .format (name )
189
- libNameDot = "lib{}." .format (name )
190
178
for framework in self .deployedFrameworks :
191
179
if framework .endswith (".framework" ):
192
- if framework .startswith (nameDot ):
180
+ if framework .startswith (f" { name } ." ):
193
181
return True
194
182
elif framework .endswith (".dylib" ):
195
- if framework .startswith (libNameDot ):
183
+ if framework .startswith (f"lib { name } ." ):
196
184
return True
197
185
return False
198
186
199
187
def getFrameworks (binaryPath : str , verbose : int ) -> List [FrameworkInfo ]:
200
188
if verbose :
201
- print ("Inspecting with otool: " + binaryPath )
189
+ print (f "Inspecting with otool: { binaryPath } " )
202
190
otoolbin = os .getenv ("OTOOL" , "otool" )
203
191
otool = run ([otoolbin , "-L" , binaryPath ], stdout = PIPE , stderr = PIPE , universal_newlines = True )
204
192
if otool .returncode != 0 :
205
193
sys .stderr .write (otool .stderr )
206
194
sys .stderr .flush ()
207
- raise RuntimeError ("otool failed with return code {}" . format ( otool .returncode ) )
195
+ raise RuntimeError (f "otool failed with return code { otool .returncode } " )
208
196
209
197
otoolLines = otool .stdout .split ("\n " )
210
198
otoolLines .pop (0 ) # First line is the inspected binary
@@ -252,14 +240,14 @@ def runStrip(binaryPath: str, verbose: int):
252
240
def copyFramework (framework : FrameworkInfo , path : str , verbose : int ) -> Optional [str ]:
253
241
if framework .sourceFilePath .startswith ("Qt" ):
254
242
#standard place for Nokia Qt installer's frameworks
255
- fromPath = "/Library/Frameworks/" + framework .sourceFilePath
243
+ fromPath = f "/Library/Frameworks/{ framework .sourceFilePath } "
256
244
else :
257
245
fromPath = framework .sourceFilePath
258
246
toDir = os .path .join (path , framework .destinationDirectory )
259
247
toPath = os .path .join (toDir , framework .binaryName )
260
248
261
249
if not os .path .exists (fromPath ):
262
- raise RuntimeError ("No file at " + fromPath )
250
+ raise RuntimeError (f "No file at { fromPath } " )
263
251
264
252
if os .path .exists (toPath ):
265
253
return None # Already there
@@ -357,7 +345,7 @@ def deployFrameworks(frameworks: List[FrameworkInfo], bundlePath: str, binaryPat
357
345
def deployFrameworksForAppBundle (applicationBundle : ApplicationBundleInfo , strip : bool , verbose : int ) -> DeploymentInfo :
358
346
frameworks = getFrameworks (applicationBundle .binaryPath , verbose )
359
347
if len (frameworks ) == 0 :
360
- print ("Warning: Could not find any external frameworks to deploy in {}." . format ( applicationBundle .path ) )
348
+ print (f "Warning: Could not find any external frameworks to deploy in { applicationBundle .path } ." )
361
349
return DeploymentInfo ()
362
350
else :
363
351
return deployFrameworks (frameworks , applicationBundle .path , applicationBundle .binaryPath , strip , verbose )
@@ -526,7 +514,7 @@ app_bundle = config.app_bundle[0]
526
514
appname = config .appname [0 ]
527
515
528
516
if not os .path .exists (app_bundle ):
529
- sys .stderr .write ("Error: Could not find app bundle \" {}\" \n " . format ( app_bundle ) )
517
+ sys .stderr .write (f "Error: Could not find app bundle \" { app_bundle } \" \n " )
530
518
sys .exit (1 )
531
519
532
520
# ------------------------------------------------
564
552
sys .stderr .write ("Warning: Could not detect Qt's path, skipping plugin deployment!\n " )
565
553
config .plugins = False
566
554
except RuntimeError as e :
567
- sys .stderr .write ("Error: {} \n " . format ( str (e )) )
555
+ sys .stderr .write (f "Error: { str (e )} \n " )
568
556
sys .exit (1 )
569
557
570
558
# ------------------------------------------------
@@ -575,14 +563,14 @@ if config.plugins:
575
563
try :
576
564
deployPlugins (applicationBundle , deploymentInfo , config .strip , verbose )
577
565
except RuntimeError as e :
578
- sys .stderr .write ("Error: {} \n " . format ( str (e )) )
566
+ sys .stderr .write (f "Error: { str (e )} \n " )
579
567
sys .exit (1 )
580
568
581
569
# ------------------------------------------------
582
570
583
571
if config .translations_dir :
584
572
if not Path (config .translations_dir [0 ]).exists ():
585
- sys .stderr .write ("Error: Could not find translation dir \" {} \" \n " . format ( config .translations_dir [0 ]) )
573
+ sys .stderr .write (f "Error: Could not find translation dir \" { config .translations_dir [0 ]} \" \n " )
586
574
sys .exit (1 )
587
575
588
576
print ("+ Adding Qt translations +" )
@@ -671,7 +659,7 @@ if config.dmg is not None:
671
659
if verbose :
672
660
print ("Creating temp image for modification..." )
673
661
674
- tempname = appname + ".temp.dmg"
662
+ tempname : str = appname + ".temp.dmg"
675
663
676
664
run (["hdiutil" , "create" , tempname , "-srcfolder" , "dist" , "-format" , "UDRW" , "-size" , str (size ), "-volname" , appname ], check = True , universal_newlines = True )
677
665
@@ -694,7 +682,7 @@ if config.dmg is not None:
694
682
695
683
print ("+ Finalizing .dmg disk image +" )
696
684
697
- run (["hdiutil" , "detach" , "/Volumes/{}" . format ( appname ) ], universal_newlines = True )
685
+ run (["hdiutil" , "detach" , f "/Volumes/{ appname } " ], universal_newlines = True )
698
686
699
687
run (["hdiutil" , "convert" , tempname , "-format" , "UDZO" , "-o" , appname , "-imagekey" , "zlib-level=9" ], check = True , universal_newlines = True )
700
688
0 commit comments