How to use the py2app.util.mergecopy function in py2app

To help you get started, we’ve selected a few py2app examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github metachris / py2app / py2app / build_app.py View on Github external
def build_executable(self, target, arcname, pkgexts, copyexts, script, extra_scripts):
        # 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)
github metachris / py2app / py2app / create_appbundle.py View on Github external
def create_appbundle(destdir, name, extension='.app', module=py2app.apptemplate,
        platform='MacOS', copy=mergecopy, mergetree=mergetree,
        condition=skipscm, plist={}, arch=None):
    kw = module.plist_template.infoPlistDict(
        plist.get('CFBundleExecutable', name), plist)
    app = os.path.join(destdir, kw['CFBundleName'] + extension)
    if os.path.exists(app):
        # Remove any existing build artifacts to ensure that
        # we're getting a clean build
        shutil.rmtree(app)
    contents = os.path.join(app, 'Contents')
    resources = os.path.join(contents, 'Resources')
    platdir = os.path.join(contents, platform)
    dirs = [contents, resources, platdir]
    plist = plistlib.Plist()
    plist.update(kw)
    plistPath = os.path.join(contents, 'Info.plist')
    if os.path.exists(plistPath):
github metachris / py2app / py2app / build_app.py View on Github external
extra_scripts = list(self.extra_scripts)
            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)
github metachris / py2app / py2app / create_pluginbundle.py View on Github external
def create_pluginbundle(destdir, name, extension='.plugin', module=py2app.bundletemplate,
        platform='MacOS', copy=mergecopy, mergetree=mergetree,
        condition=skipscm, plist={}, arch=None):
    kw = module.plist_template.infoPlistDict(
        plist.get('CFBundleExecutable', name), plist)
    plugin = os.path.join(destdir, kw['CFBundleName'] + extension)
    if os.path.exists(plugin):
        # Remove any existing build artifacts to ensure
        # we're getting a clean build
        shutil.rmtree(plugin)
    contents = os.path.join(plugin, 'Contents')
    resources = os.path.join(contents, 'Resources')
    platdir = os.path.join(contents, platform)
    dirs = [contents, resources, platdir]
    plist = plistlib.Plist()
    plist.update(kw)
    plistPath = os.path.join(contents, 'Info.plist')
    if os.path.exists(plistPath):