Skip to content

Commit 5d2cbdf

Browse files
committed
macdeploy: use Python 3.6
1 parent a42aa94 commit 5d2cbdf

File tree

1 file changed

+32
-44
lines changed

1 file changed

+32
-44
lines changed

contrib/macdeploy/macdeployqtplus

Lines changed: 32 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -53,28 +53,18 @@ class FrameworkInfo(object):
5353
return False
5454

5555
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+
"""
7868

7969
def isDylib(self):
8070
return self.frameworkName.endswith(".dylib")
@@ -101,7 +91,7 @@ class FrameworkInfo(object):
10191

10292
m = cls.reOLine.match(line)
10393
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}")
10595

10696
path = m.group(1)
10797

@@ -121,7 +111,7 @@ class FrameworkInfo(object):
121111
info.version = "-"
122112

123113
info.installName = path
124-
info.deployedInstallName = "@executable_path/../Frameworks/" + info.binaryName
114+
info.deployedInstallName = f"@executable_path/../Frameworks/{info.binaryName}"
125115
info.sourceFilePath = path
126116
info.destinationDirectory = cls.bundleFrameworkDirectory
127117
else:
@@ -133,7 +123,7 @@ class FrameworkInfo(object):
133123
break
134124
i += 1
135125
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}")
137127

138128
info.frameworkName = parts[i]
139129
info.frameworkDirectory = "/".join(parts[:i])
@@ -144,7 +134,7 @@ class FrameworkInfo(object):
144134
info.binaryPath = os.path.join(info.binaryDirectory, info.binaryName)
145135
info.version = parts[i+2]
146136

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)}"
148138
info.destinationDirectory = os.path.join(cls.bundleFrameworkDirectory, info.frameworkName, info.binaryDirectory)
149139

150140
info.sourceResourcesDirectory = os.path.join(info.frameworkPath, "Resources")
@@ -158,10 +148,10 @@ class FrameworkInfo(object):
158148
class ApplicationBundleInfo(object):
159149
def __init__(self, path: str):
160150
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")
163153
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}")
165155
self.resourcesPath = os.path.join(path, "Contents", "Resources")
166156
self.pluginPath = os.path.join(path, "Contents", "PlugIns")
167157

@@ -185,26 +175,24 @@ class DeploymentInfo(object):
185175
self.pluginPath = pluginPath
186176

187177
def usesFramework(self, name: str) -> bool:
188-
nameDot = "{}.".format(name)
189-
libNameDot = "lib{}.".format(name)
190178
for framework in self.deployedFrameworks:
191179
if framework.endswith(".framework"):
192-
if framework.startswith(nameDot):
180+
if framework.startswith(f"{name}."):
193181
return True
194182
elif framework.endswith(".dylib"):
195-
if framework.startswith(libNameDot):
183+
if framework.startswith(f"lib{name}."):
196184
return True
197185
return False
198186

199187
def getFrameworks(binaryPath: str, verbose: int) -> List[FrameworkInfo]:
200188
if verbose:
201-
print("Inspecting with otool: " + binaryPath)
189+
print(f"Inspecting with otool: {binaryPath}")
202190
otoolbin=os.getenv("OTOOL", "otool")
203191
otool = run([otoolbin, "-L", binaryPath], stdout=PIPE, stderr=PIPE, universal_newlines=True)
204192
if otool.returncode != 0:
205193
sys.stderr.write(otool.stderr)
206194
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}")
208196

209197
otoolLines = otool.stdout.split("\n")
210198
otoolLines.pop(0) # First line is the inspected binary
@@ -252,14 +240,14 @@ def runStrip(binaryPath: str, verbose: int):
252240
def copyFramework(framework: FrameworkInfo, path: str, verbose: int) -> Optional[str]:
253241
if framework.sourceFilePath.startswith("Qt"):
254242
#standard place for Nokia Qt installer's frameworks
255-
fromPath = "/Library/Frameworks/" + framework.sourceFilePath
243+
fromPath = f"/Library/Frameworks/{framework.sourceFilePath}"
256244
else:
257245
fromPath = framework.sourceFilePath
258246
toDir = os.path.join(path, framework.destinationDirectory)
259247
toPath = os.path.join(toDir, framework.binaryName)
260248

261249
if not os.path.exists(fromPath):
262-
raise RuntimeError("No file at " + fromPath)
250+
raise RuntimeError(f"No file at {fromPath}")
263251

264252
if os.path.exists(toPath):
265253
return None # Already there
@@ -357,7 +345,7 @@ def deployFrameworks(frameworks: List[FrameworkInfo], bundlePath: str, binaryPat
357345
def deployFrameworksForAppBundle(applicationBundle: ApplicationBundleInfo, strip: bool, verbose: int) -> DeploymentInfo:
358346
frameworks = getFrameworks(applicationBundle.binaryPath, verbose)
359347
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}.")
361349
return DeploymentInfo()
362350
else:
363351
return deployFrameworks(frameworks, applicationBundle.path, applicationBundle.binaryPath, strip, verbose)
@@ -526,7 +514,7 @@ app_bundle = config.app_bundle[0]
526514
appname = config.appname[0]
527515

528516
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")
530518
sys.exit(1)
531519

532520
# ------------------------------------------------
@@ -564,7 +552,7 @@ try:
564552
sys.stderr.write("Warning: Could not detect Qt's path, skipping plugin deployment!\n")
565553
config.plugins = False
566554
except RuntimeError as e:
567-
sys.stderr.write("Error: {}\n".format(str(e)))
555+
sys.stderr.write(f"Error: {str(e)}\n")
568556
sys.exit(1)
569557

570558
# ------------------------------------------------
@@ -575,14 +563,14 @@ if config.plugins:
575563
try:
576564
deployPlugins(applicationBundle, deploymentInfo, config.strip, verbose)
577565
except RuntimeError as e:
578-
sys.stderr.write("Error: {}\n".format(str(e)))
566+
sys.stderr.write(f"Error: {str(e)}\n")
579567
sys.exit(1)
580568

581569
# ------------------------------------------------
582570

583571
if config.translations_dir:
584572
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")
586574
sys.exit(1)
587575

588576
print("+ Adding Qt translations +")
@@ -671,7 +659,7 @@ if config.dmg is not None:
671659
if verbose:
672660
print("Creating temp image for modification...")
673661

674-
tempname = appname + ".temp.dmg"
662+
tempname: str = appname + ".temp.dmg"
675663

676664
run(["hdiutil", "create", tempname, "-srcfolder", "dist", "-format", "UDRW", "-size", str(size), "-volname", appname], check=True, universal_newlines=True)
677665

@@ -694,7 +682,7 @@ if config.dmg is not None:
694682

695683
print("+ Finalizing .dmg disk image +")
696684

697-
run(["hdiutil", "detach", "/Volumes/{}".format(appname)], universal_newlines=True)
685+
run(["hdiutil", "detach", f"/Volumes/{appname}"], universal_newlines=True)
698686

699687
run(["hdiutil", "convert", tempname, "-format", "UDZO", "-o", appname, "-imagekey", "zlib-level=9"], check=True, universal_newlines=True)
700688

0 commit comments

Comments
 (0)