How to use the py2app.util.byte_compile 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
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')
        configdir = get_config_var('LIBPL')


        if includedir is None:
github metachris / py2app / py2app / build_app.py View on Github external
if pkgdirs:
            py_files = list(filter(packagefilter, py_files))
        for ext in extensions:
            fn = packagefilter(ext)
            if fn is None:
                fn = os.path.realpath(getattr(ext, 'filename', None))
                pkgexts.append(ext)
            else:
                if '.' in ext.identifier:
                    py_files.append(self.create_loader(ext))
                copyexts.append(ext)
            extmap[fn] = ext

        # byte compile the python modules into the target directory
        print("*** byte compile python files ***")
        byte_compile(py_files,
                     target_dir=self.collect_dir,
                     optimize=self.optimize,
                     force=self.force,
                     verbose=self.verbose,
                     dry_run=self.dry_run)

        for item in py_files:
            if not isinstance(item, Package): continue
            self.copy_package_data(item, self.collect_dir)

        self.lib_files = []
        self.app_files = []

        # create the shared zipfile containing all Python modules
        archive_name = os.path.join(self.lib_dir,
                                    get_zipfile(dist, self.semi_standalone))