Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# Build an executable for the target
appdir, resdir, plist = self.create_bundle(target, script)
self.appdir = appdir
self.resdir = resdir
self.plist = plist
for fn in extra_scripts:
if fn.endswith('.py'):
fn = fn[:-3]
elif fn.endswith('.pyw'):
fn = fn[:-4]
src_fn = script_executable(arch=self.arch, secondary=True)
tgt_fn = os.path.join(self.appdir, 'Contents', 'MacOS', os.path.basename(fn))
mergecopy(src_fn, tgt_fn)
make_exec(tgt_fn)
site_path = os.path.join(resdir, 'site.py')
byte_compile([
SourceModule('site', site_path),
],
target_dir=resdir,
optimize=self.optimize,
force=self.force,
verbose=self.verbose,
dry_run=self.dry_run)
if not self.dry_run:
os.unlink(site_path)
includedir = get_config_var('CONFINCLUDEPY')
for d in dirs:
shutil.rmtree(d, ignore_errors=True)
for d in dirs:
makedirs(d)
plist.write(plistPath)
srcmain = module.setup.main(arch=arch)
if sys.version_info[0] == 2 and isinstance(kw['CFBundleExecutable'], unicode):
destmain = os.path.join(platdir, kw['CFBundleExecutable'].encode('utf-8'))
else:
destmain = os.path.join(platdir, kw['CFBundleExecutable'])
with open(os.path.join(contents, 'PkgInfo'), 'w') as fp:
fp.write(
kw['CFBundlePackageType'] + kw['CFBundleSignature']
)
copy(srcmain, destmain)
make_exec(destmain)
mergetree(
resource_filename(module.__name__, 'lib'),
resources,
condition=condition,
copyfn=copy,
)
return plugin, plist
if hasattr(target, 'extra_scripts'):
extra_scripts.update(extra_scripts)
dst = self.build_alias_executable(target, target.script, extra_scripts)
self.app_files.append(dst)
for fn in extra_scripts:
if fn.endswith('.py'):
fn = fn[:-3]
elif fn.endswith('.pyw'):
fn = fn[:-4]
src_fn = script_executable(arch=self.arch, secondary=True)
tgt_fn = os.path.join(target.appdir, 'Contents', 'MacOS', os.path.basename(fn))
mergecopy(src_fn, tgt_fn)
make_exec(tgt_fn)
shutil.rmtree(d, ignore_errors=True)
for d in dirs:
makedirs(d)
plist.write(plistPath)
srcmain = module.setup.main(arch=arch)
if sys.version_info[0] == 2 and isinstance(kw['CFBundleExecutable'], unicode):
destmain = os.path.join(platdir, kw['CFBundleExecutable'].encode('utf-8'))
else:
destmain = os.path.join(platdir, kw['CFBundleExecutable'])
with open(os.path.join(contents, 'PkgInfo'), 'w') as fp:
fp.write(
kw['CFBundlePackageType'] + kw['CFBundleSignature']
)
copy(srcmain, destmain)
make_exec(destmain)
mergetree(
resource_filename(module.__name__, 'lib'),
resources,
condition=condition,
copyfn=copy,
)
return app, plist