How to use the py2exe.build_exe.py2exe function in py2exe

To help you get started, we’ve selected a few py2exe 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 rodrigets / games-in-pygame / executables / build.py View on Github external
def copy_extensions(self, extensions):
        #Get pygame default font
        pygamedir = os.path.split(pygame.base.__file__)[0]
        pygame_default_font = os.path.join(pygamedir, pygame.font.get_default_font())

        #Add font to list of extension to be copied
        extensions.append(Module("pygame.font", pygame_default_font))
        py2exe.build_exe.py2exe.copy_extensions(self, extensions)
github Syncplay / syncplay / buildPy2exe.py View on Github external
def copyQtPlugins(paths):
    import shutil
    from PySide2 import QtCore
    basePath = QtCore.QLibraryInfo.location(QtCore.QLibraryInfo.PluginsPath)
    basePath = basePath.replace('/', '\\')
    destBase = os.getcwd() + '\\' + OUT_DIR
    for elem in paths:
        elemDir, elemName = os.path.split(elem)
        source = basePath + '\\' + elem
        dest = destBase + '\\' + elem
        destDir = destBase + '\\' + elemDir
        os.makedirs(destDir, exist_ok=True)
        shutil.copy(source, dest)

class build_installer(py2exe):
    def run(self):
        py2exe.run(self)
        print('*** deleting unnecessary libraries and modules ***')
        pruneUnneededLibraries()
        print('*** copying qt plugins ***')
        copyQtPlugins(qt_plugins)
        script = NSISScript()
        script.create()
        print("*** compiling the NSIS setup script ***")
        script.compile()
        print("*** DONE ***")

guiIcons = glob('syncplay/resources/*.ico') + glob('syncplay/resources/*.png') +  ['syncplay/resources/spinner.mng']

resources = [
    "syncplay/resources/syncplayintf.lua",
github aarddict / desktop / setup.py View on Github external
import sys

from setuptools import setup, find_packages

import aarddict

try:
    import py2exe
except:
    py2exe_options = {}
else:
    import os
    import glob
    from py2exe.build_exe import py2exe as build_exe

    class Collector(build_exe):
        def copy_extensions(self, extensions):
            build_exe.copy_extensions(self, extensions)

            # Copy the files to the collection dir.
            # Also add the copied file to the list of compiled
            # files so it will be included in zipfile.
            all_files = ([f for f in glob.glob('aarddict/*.tmpl')] +
                         [f for f in glob.glob('aarddict/*.js')] +
                         [f for f in glob.glob('aarddict/*.png')] +
                         [f for f in glob.glob('aarddict/*.css')] +
                         [f for f in glob.glob('aarddict/locale/*/*/*.mo')] +
                         [f for f in glob.glob('aarddict/locale/*.qm')] +
                         [f for f in glob.glob('aarddict/icons/*/*/*/*.png')]
                         )
            for f in all_files:
github FrodeSolheim / fs-uae / launcher / setup_py2exe.py View on Github external
for p in m.__path__[1:]:
            modulefinder.AddPackagePath(extra, p)
except ImportError:
    # no build path setup, no worries.
    pass

options = {}

py2exe_options = {
    "dll_excludes": ["MSVCP90.dll"],
}
options["py2exe"] = py2exe_options

from py2exe.build_exe import py2exe as build_exe

class LauncherBuildExe(build_exe):

    def copy_extensions(self, extensions):
        """Copy the missing extensions."""
        build_exe.copy_extensions(self, extensions)

        res_dir = os.path.join("fs_uae_launcher", "res")
        full = os.path.join(self.collect_dir, res_dir)
        if not os.path.exists(full):
            self.mkpath(full)

        for f in glob.glob(res_dir + '/*.*'):
            name = os.path.basename(f)
            self.copy_file(f, os.path.join(full, name))
            self.compiled_files.append(os.path.join(res_dir, name))

setup(
github umitproject / network-scanner / install_scripts / windows / py2exe_setup.py View on Github external
# win32com changes its __path__ to be able to do imports from
# win32comext (which is not a python package), but the modulefinder
# does not handle such situtation and thus win32com.shell (which is
# really win32comext.shell) cannot be found. Let's fix this here so
# umit.core.BasePaths still works after we run py2exe over it.
try:
    import py2exe.mf as modulefinder
except ImportError:
    # This py2exe is too old, will use the standard modulefinder
    import modulefinder
import win32com
for path in win32com.__path__[1:]:
    modulefinder.AddPackagePath("win32com", path)

class umit_py2exe(build_exe):
    def run(self):
        build_exe.run(self)
        self.finish_banner()

    def finish_banner(self):
        print
        print "%s The compiled version of Umit %s is in ./dist %s" % \
              ("#"*10, VERSION, "#"*10)
        print


py2exe_cmdclass = {"py2exe": umit_py2exe}

py2exe_options = dict(
        zipfile = None,
        service = [{'modules': ['umit_scheduler'], 'cmdline_style': 'custom'}],
github twisted / twisted / sandbox / moonfallen / ntsvc / command.py View on Github external
cftype='python',
                                basecf=config)
        if os.path.dirname(self.twisted['basecf']) != '':
            raise ValueError("Directory names not allowed for "
                             "the application file: %s" % 
                                   (self.twisted['basecf'],))
        attrs['service'] = [{'modules': ['ntsvc.runner'], 
                             'dest_base': '%sctl' % (short_name,),
                             }]
        attrs.setdefault('data_files', []).append(
                ('', [config, 'ntsvc.cfg'])
                         )

        py2exe.Distribution.__init__(self, attrs)

class twistedservice(build_exe):
    """Generate a script from boilerplate that will start the service.
    Read the tac file with modulegraph and build a list of files to include.
    Pass that list along to py2exe's modulefinder.
    """
    def run(self):
        """add tac-imported modules into self.includes"""
        twcfg = self.distribution.twisted

        # create ntsvc.cfg from twcfg's values if it is missing
        if not os.path.isfile('ntsvc.cfg'):
            cp = ConfigParser.ConfigParser()
            cp.add_section('service')
            for o, v in twcfg.items():
                cp.set('service', o, v)
            cp.write(file('ntsvc.cfg', 'w'))
github fcwu / desktop-mirror / windows / builder_win7.py View on Github external
outfile.write(contents)

    def compile(self):
        subproc = subprocess.Popen(
            # "/P5" uses realtime priority for the LZMA compression stage.
            # This can get annoying though.
            [self.NSIS_COMPILE, self.pathname, "/P5"], env=os.environ)
        subproc.communicate()

        retcode = subproc.returncode

        if retcode:
            raise RuntimeError("NSIS compilation return code: %d" % retcode)


class build_installer(py2exe):
    # This class first builds the exe file(s), then creates an NSIS installer
    # that runs your program from a temporary directory.
    def run(self):
        # First, let py2exe do it's work.
        py2exe.run(self)

        lib_dir = self.lib_dir
        dist_dir = self.dist_dir

        # Create the installer, using the files py2exe has created.
        script = NSISScript('desktop-mirror',
                            'A tools to stream screen(video and audio) out',
                            'dist',
                            os.path.join('share', 'icon.ico'))
        print "*** creating the NSIS setup script***"
        script.create()