def run(self):
self.run_command('build')
build = self.get_finalized_command('build')
# define the paths within the application bundle
self.bundleDir = os.path.join(build.build_base, self.bundle_name + ".app")
self.contentsDir = os.path.join(self.bundleDir, 'Contents')
self.resourcesDir = os.path.join(self.contentsDir, 'Resources')
self.binDir = os.path.join(self.contentsDir, 'MacOS')
self.frameworksDir = os.path.join(self.contentsDir, 'Frameworks')
# find the executable name
executable = self.distribution.executables[0].targetName
_, self.bundle_executable = os.path.split(executable)
# build the app directory structure
self.mkpath(self.resourcesDir)
self.mkpath(self.binDir)
self.mkpath(self.frameworksDir)
self.copy_tree(BUILD_PATH, self.binDir)
# copy the icon
if self.iconfile:
self.copy_file(self.iconfile, os.path.join(self.resourcesDir, 'icon.icns'))
# copy in Frameworks
for framework in self.include_frameworks:
self.copy_tree(framework, self.frameworksDir + '/' + os.path.basename(framework))
# create the Info.plist file
self.execute(self.create_plist, ())
# make all references to libraries relative
self.execute(self.setRelativeReferencePaths, ())
# for a Qt application, run some tweaks
self.execute(self.prepare_qt_app, ())
# sign the app bundle if a key is specified
if self.codesign_identity:
signargs = ['codesign', '-s', self.codesign_identity]
if self.codesign_entitlements:
signargs.append('--entitlements')
signargs.append(self.codesign_entitlements)
if self.codesign_deep:
signargs.insert(1, '--deep')
if self.codesign_resource_rules:
signargs.insert(1, '--resource-rules=' + self.codesign_resource_rules)
signargs.append(self.bundleDir)
if os.spawnvp(os.P_WAIT, 'codesign', signargs) != 0:
raise OSError('Code signing of app bundle failed')
评论列表
文章目录