コード例 #1
0
ファイル: dist.py プロジェクト: transformaps/Roam
 def run(self):
     metadata = self.distribution.metadata
     constantsModule = cx_Freeze.ConstantsModule(metadata.version)
     for constant in self.constants:
         parts = constant.split("=")
         if len(parts) == 1:
             name = constant
             value = None
         else:
             name, stringValue = parts
             value = eval(stringValue)
         constantsModule.values[name] = value
     freezer = cx_Freeze.Freezer(self.distribution.executables,
             [constantsModule], self.includes, self.excludes, self.packages,
             self.replace_paths, (not self.no_compress), self.optimize,
             self.path, self.build_exe,
             includeMSVCR = self.include_msvcr,
             includeFiles = self.include_files,
             binIncludes = self.bin_includes,
             binExcludes = self.bin_excludes,
             zipIncludes = self.zip_includes,
             silent = self.silent,
             namespacePackages = self.namespace_packages,
             binPathIncludes = self.bin_path_includes,
             binPathExcludes = self.bin_path_excludes,
             metadata = metadata,
             zipIncludePackages = self.zip_include_packages,
             zipExcludePackages = self.zip_exclude_packages)
     freezer.Freeze()
コード例 #2
0
ファイル: dist.py プロジェクト: mikro45/noviny_povstanie
 def run(self):
     metadata = self.distribution.metadata
     constantsModule = cx_Freeze.ConstantsModule(metadata.version)
     for constant in self.constants:
         parts = constant.split("=")
         if len(parts) == 1:
             name = constant
             value = None
         else:
             name, stringValue = parts
             value = eval(stringValue)
         constantsModule.values[name] = value
     freezer = cx_Freeze.Freezer(self.distribution.executables,
             [constantsModule], self.includes, self.excludes, self.packages,
             self.replace_paths, self.compressed, self.optimize,
             self.copy_dependent_files, self.init_script, self.base,
             self.path, self.create_shared_zip, self.append_script_to_exe,
             self.include_in_shared_zip, self.build_exe, icon = self.icon,
             includeMSVCR = self.include_msvcr,
             includeFiles = self.include_files,
             binIncludes = self.bin_includes,
             binExcludes = self.bin_excludes,
             zipIncludes = self.zip_includes,
             silent = self.silent,
             namespacePackages = self.namespace_packages,
             binPathIncludes = self.bin_path_includes,
             binPathExcludes = self.bin_path_excludes,
             metadata = metadata)
     freezer.Freeze()
コード例 #3
0
    def run(self):
        metadata = self.distribution.metadata
        constants_module = cx_Freeze.ConstantsModule(metadata.version,
                                                     constants=self.constants)
        if self.namespace_packages:
            warnings.warn(
                "namespace-packages is obsolete and will be removed in the next version"
            )
        freezer = cx_Freeze.Freezer(
            self.distribution.executables,
            constants_module,
            self.includes,
            self.excludes,
            self.packages,
            self.replace_paths,
            (not self.no_compress),
            self.optimize,
            self.path,
            self.build_exe,
            includeMSVCR=self.include_msvcr,
            includeFiles=self.include_files,
            binIncludes=self.bin_includes,
            binExcludes=self.bin_excludes,
            zipIncludes=self.zip_includes,
            silent=self.silent,
            binPathIncludes=self.bin_path_includes,
            binPathExcludes=self.bin_path_excludes,
            metadata=metadata,
            zipIncludePackages=self.zip_include_packages,
            zipExcludePackages=self.zip_exclude_packages,
        )

        # keep freezer around so that its data case be used in bdist_mac phase
        self.freezer = freezer
        freezer.Freeze()
コード例 #4
0
ファイル: main.py プロジェクト: SagarChauhan-net/SilencePad
def main():
    args = parse_command_line(prepare_parser())
    executables = [
        cx_Freeze.Executable(
            args.script,
            args.init_script,
            args.base_name,
            args.target_name,
            args.icon,
        )
    ]
    freezer = cx_Freeze.Freezer(
        executables,
        includes=args.includes,
        excludes=args.excludes,
        packages=args.packages,
        replacePaths=args.replace_paths,
        compress=args.compress,
        optimizeFlag=args.optimize_flag,
        path=None,
        targetDir=args.target_dir,
        includeFiles=args.include_files,
        zipIncludes=args.zip_includes,
        silent=args.silent,
        zipIncludePackages=args.zip_include_packages,
        zipExcludePackages=args.zip_exclude_packages,
    )
    freezer.Freeze()
コード例 #5
0
ファイル: build.py プロジェクト: a100q100/liac-chess
def main():
    executables = [
        cx_Freeze.Executable(
            "main.py",
            targetName=target_name,
            base=base,
        )
    ]

    freezer = cx_Freeze.Freezer(executables,
                                includes=[],
                                excludes=[
                                    '_gtkagg', '_tkagg', 'bsddb', 'curses',
                                    'email', 'pywin.debugger',
                                    'pywin.debugger.dbgcon', 'pywin.dialogs',
                                    'tcl', 'Tkconstants', 'Tkinter'
                                ],
                                replacePaths=[],
                                compress=True,
                                optimizeFlag=1,
                                copyDependentFiles=True,
                                initScript=None,
                                base=None,
                                path=None,
                                createLibraryZip=False,
                                appendScriptToExe=True,
                                targetDir=None,
                                zipIncludes=[],
                                includeFiles=['assets/', 'docs/', 'data/'],
                                icon='assets/ico/liac_chess.ico',
                                silent=None)
    freezer.Freeze()
コード例 #6
0
 def run(self):
     metadata = self.distribution.metadata
     constants_module = cx_Freeze.ConstantsModule(metadata.version,
                                                  constants=self.constants)
     freezer = cx_Freeze.Freezer(
         self.distribution.executables,
         constants_module,
         self.includes,
         self.excludes,
         self.packages,
         self.replace_paths, (not self.no_compress),
         self.optimize,
         self.path,
         self.build_exe,
         includeMSVCR=self.include_msvcr,
         includeFiles=self.include_files,
         binIncludes=self.bin_includes,
         binExcludes=self.bin_excludes,
         zipIncludes=self.zip_includes,
         silent=self.silent,
         namespacePackages=self.namespace_packages,
         binPathIncludes=self.bin_path_includes,
         binPathExcludes=self.bin_path_excludes,
         metadata=metadata,
         zipIncludePackages=self.zip_include_packages,
         zipExcludePackages=self.zip_exclude_packages)
     freezer.Freeze()
コード例 #7
0
 def setUp(self):
     self.tdir = tempfile.mkdtemp()
     scriptfile = os.path.join(self.tdir, "script.py")
     self.distdir = distdir = os.path.join(self.tdir, "dist")
     with open(scriptfile, "w") as f:
         f.write("import signedimp.crypto.rsa\n")
     f = cx_Freeze.Freezer([cx_Freeze.Executable(scriptfile)],
                           targetDir=self.distdir)
     f.Freeze()
     if sys.platform == "win32":
         self.scriptexe = os.path.join(self.distdir, "script.exe")
     else:
         self.scriptexe = os.path.join(self.distdir, "script")
コード例 #8
0
def main():
    """
  Package the model runner. Warning: This assumes that this script is in the 
  same directory as model_runner.py.
  """
    # Initial cleanup.
    modelRunnerDir = os.path.dirname(os.path.realpath(__file__))
    buildDir = os.path.join(modelRunnerDir, "build")
    distDir = os.path.join(modelRunnerDir, "dist")
    nupicDir = os.path.join(modelRunnerDir, "nupic")
    os.system("rm -rf build %s %s %s" % (buildDir, distDir, nupicDir))

    # Install nupic locally, using the version listed in requirements.txt, and
    # include it in the library.zip generated by cx_freeze.
    requirementsPath = os.path.join(os.path.join(modelRunnerDir, os.pardir),
                                    "requirements.txt")
    requirements = getRequirements(requirementsPath)
    nupicPackage = "nupic"  # if nupic req is not listed, get the latest version.
    for requirement in requirements:
        if "nupic" in requirement:
            nupicPackage = requirement
            break
    nupicInstall = ("pip install --target %s %s" %
                    (os.path.join(modelRunnerDir, "nupic"), nupicPackage))
    os.system(nupicInstall)
    zipIncludes = generate_zip_includes(
        os.path.join(modelRunnerDir, "nupic", "nupic"), "nupic")

    # Include the Pyproj data folder. Data files are not found by cx_freeze
    # automatically so you need to tell it where to find it.
    includeFiles = ([(pyproj.pyproj_datadir, os.path.join("pyproj", "data"))] +
                    [(os.path.join(modelRunnerDir,
                                   "stats_schema.json"), "stats_schema.json")])

    print includeFiles
    # Freeze the model runner
    executables = [
        cx_Freeze.Executable(os.path.join(modelRunnerDir, "model_runner.py"),
                             targetName="model_runner")
    ]

    freezer = cx_Freeze.Freezer(executables,
                                namespacePackages=["nupic", "prettytable"],
                                zipIncludes=zipIncludes,
                                includeFiles=includeFiles,
                                silent=True)

    freezer.Freeze()

    # final cleanup
    os.system("rm -rf %s" % nupicDir)
コード例 #9
0
def main():
    args = parse_command_line(prepare_parser())
    steps = set(args.steps)
    if "python" in steps:
        app_name = "speech-client"
        app_root = os.path.join("dist")
        source_root = os.path.join(app_root, "speech-client")
        shutil.rmtree(app_root, ignore_errors=True)
        executables = [
            cx_Freeze.Executable(
                MAIN,
                args.init_script,
                args.base_name,
                app_name,
                args.icon,
            )
        ]

        freezer = cx_Freeze.Freezer(
            executables,
            includes=["codecs"],
            excludes=EXCLUDES,
            packages=args.packages,
            compress=args.compress,
            optimizeFlag=args.optimize_flag,
            path=None,
            targetDir=app_root,
            includeFiles=[
                (
                    "Lib\site-packages\webrtcvad_wheels-2.0.10.post2.dist-info",
                    "lib\webrtcvad_wheels-2.0.10.post2.dist-info",
                ),
                ("models", "models"),
                ("bin", "bin"),
            ],
            zipIncludes=args.zip_includes,
            silent=args.silent,
            zipIncludePackages=args.zip_include_packages,
            zipExcludePackages=args.zip_exclude_packages,
        )
        freezer.Freeze()
    app_root = os.path.abspath(os.path.join("..", "..", ".."))
    if "c#" in steps:
        build_release(app_root)
    if 'zip' in steps:
        build_release_zip(app_root)
コード例 #10
0
ファイル: main.py プロジェクト: adUst0/FixSubs
def main():
    options = ParseCommandLine()
    executables = [
        cx_Freeze.Executable(options.script,
                             initScript=options.initScript,
                             base=options.baseName,
                             icon=options.icon,
                             targetName=options.targetName)
    ]
    freezer = cx_Freeze.Freezer(executables,
                                includes=options.includeModules,
                                excludes=options.excludeModules,
                                replacePaths=options.replacePaths,
                                compress=options.compress,
                                optimizeFlag=options.optimized,
                                path=None,
                                targetDir=options.targetDir,
                                zipIncludes=options.zipIncludes,
                                silent=options.silent)
    freezer.Freeze()
コード例 #11
0
def main():
    """
  Package the script. Warning: This assumes that this script is in the 
  same directory as target script to freeze.
  """
    # Initial cleanup.
    scriptDir = os.path.dirname(os.path.realpath(__file__))
    buildDir = os.path.join(scriptDir, "build")
    distDir = os.path.join(scriptDir, "dist")
    os.system("rm -rf build %s %s" % (buildDir, distDir))

    # Freeze the script
    executables = [
        cx_Freeze.Executable(os.path.join(scriptDir, "sensor_publisher.py"),
                             targetName="sensor_publisher")
    ]

    freezer = cx_Freeze.Freezer(executables, silent=True)

    freezer.Freeze()
コード例 #12
0
ファイル: main.py プロジェクト: takluyver/Pcode
def main():
    options = ParseCommandLine()
    executables = [
        cx_Freeze.Executable(options.script, targetName=options.targetName)
    ]
    freezer = cx_Freeze.Freezer(executables,
                                includes=options.includeModules,
                                excludes=options.excludeModules,
                                replacePaths=options.replacePaths,
                                compress=options.compress,
                                optimizeFlag=options.optimized,
                                copyDependentFiles=options.copyDeps,
                                initScript=options.initScript,
                                base=options.baseName,
                                path=None,
                                createLibraryZip=False,
                                appendScriptToExe=True,
                                targetDir=options.targetDir,
                                zipIncludes=options.zipIncludes,
                                icon=options.icon,
                                silent=options.silent)
    freezer.Freeze()
コード例 #13
0
        # Simply include entire package, to save effort
        full_includes = ['skimage', 'pygments']

        full_includes += get_files_for_package_start('pyopencl')
        full_includes += get_files_for_package_start('scikits.ann')
        full_includes += get_files_for_package_start('mpl_toolkits')
        full_includes += get_files_for_package_start('sklearn')

        for package in full_includes:
            if package is not None:
                include_files.append((SITE_PACKAGE_DIR + package, package))

        executables = [
            cx_Freeze.Executable('multiscale_extraction.py', base=None),
            cx_Freeze.Executable('gpu_device_selection.py', base=None)
        ]

        main_system_temp = tempfile.mkdtemp()

        freezer = cx_Freeze.Freezer(executables,
                                    includes=includes,
                                    includeFiles=include_files,
                                    targetDir=main_system_temp)
        freezer.Freeze()

        zip_dir(save_file_name, main_system_temp)
    except:
        raise
    finally:
        if main_system_temp:
            shutil.rmtree(main_system_temp)
コード例 #14
0
ファイル: build_script.py プロジェクト: kristofmulier/esptool
def build_all(toplevel_directory, build_directory):
    '''
    Given the toplevel directory (eg. '~/esptool') and the build-directory (eg.
    '~/esptool/build'), this function builds the following scripts with
    cx_Freeze:
        - espefuse.py
        - espsecure.py
        - esptool.py

    :param toplevel_directory: The toplevel 'esptool' directory, eg. '~/esptool'.
                               The scripts to be built can be found directly in
                               this toplevel directory, eg:
                                   - ~/esptool/espefuse.py
                                   - ~/esptool/espsecure.py
                                   - ~/esptool/esptool.py

    :param build_directory: The directory where the build output gets generated,
                            eg. '~/esptool/build'.

    :return: None
    '''
    print(f'build executables...\n')
    #* Define executables
    #* ------------------
    is_windows = platform.system().lower() == 'windows'
    executables = [
        cx_Freeze.Executable(
            'espefuse.py',
            initScript=None,
            base=None,
            icon='espressif.ico',
            targetName='espefuse.exe' if is_windows else 'espefuse',
        ),
        cx_Freeze.Executable(
            'espsecure.py',
            initScript=None,
            base=None,
            icon='espressif.ico',
            targetName='espsecure.exe' if is_windows else 'espsecure',
        ),
        cx_Freeze.Executable(
            'esptool.py',
            initScript=None,
            base=None,
            icon='espressif.ico',
            targetName='esptool.exe' if is_windows else 'esptool',
        ),
    ]

    #* Define 'search_path'
    #* --------------------
    search_path = []
    temp = sys.path
    temp.append(toplevel_directory)
    for p in temp:
        p = p.replace('\\', '/')
        search_path.append(p)

    #* Invoke Freezer()
    #* ----------------
    freezer = cx_Freeze.Freezer(
        executables,
        replacePaths=[],
        compress=True,
        optimizeFlag=True,
        path=search_path,
        targetDir=build_directory,
        includeFiles=[],
        zipIncludes=[],
        silent=False,
    )
    freezer.Freeze()
    print('\n' 'finish build\n')
    return
コード例 #15
0
def freeze(dist):
    """Freeze the given distribution data using cx_Freeze."""
    includes = dist.includes
    excludes = dist.excludes
    options = dist.freezer_options
    #  Merge in any encludes/excludes given in freezer_options
    for inc in options.pop("includes", ()):
        includes.append(inc)
    for exc in options.pop("excludes", ()):
        excludes.append(exc)
    if "esky" not in includes and "esky" not in excludes:
        includes.append("esky")
    if "pypy" not in includes and "pypy" not in excludes:
        excludes.append("pypy")
    #  cx_Freeze doesn't seem to respect __path__ properly; hack it so
    #  that the required distutils modules are always found correctly.
    def load_distutils(finder, module):
        module.path = distutils.__path__ + module.path
        finder.IncludeModule("distutils.dist")

    cx_Freeze.hooks.load_distutils = load_distutils
    #  Build kwds arguments out of the given freezer opts.
    kwds = {}
    for (nm, val) in options.iteritems():
        kwds[_normalise_opt_name(nm)] = val
    kwds["includes"] = includes
    kwds["excludes"] = excludes
    kwds["targetDir"] = dist.freeze_dir
    #  Build an Executable object for each script.
    #  To include the esky startup code, we write each to a tempdir.
    executables = []
    for exe in dist.get_executables():
        base = None
        if exe.gui_only and sys.platform == "win32":
            base = "Win32GUI"
        executables.append(
            cx_Freeze.Executable(exe.script,
                                 base=base,
                                 targetName=exe.name,
                                 icon=exe.icon,
                                 **exe._kwds))
    #  Freeze up the executables
    f = cx_Freeze.Freezer(executables, **kwds)
    f.Freeze()
    #  Copy data files into the freeze dir
    for (src, dst) in dist.get_data_files():
        dst = os.path.join(dist.freeze_dir, dst)
        dstdir = os.path.dirname(dst)
        if not os.path.isdir(dstdir):
            dist.mkpath(dstdir)
        dist.copy_file(src, dst)
    #  Copy package data into the library.zip
    #  For now, this only works if there's a shared "library.zip" file.
    if f.createLibraryZip:
        lib = zipfile.ZipFile(os.path.join(dist.freeze_dir, "library.zip"),
                              "a")
        for (src, arcnm) in dist.get_package_data():
            lib.write(src, arcnm)
        lib.close()
    else:
        for (src, arcnm) in dist.get_package_data():
            err = "use of package_data currently requires createLibraryZip=True"
            raise RuntimeError(err)
    #  Create the bootstrap code, using custom code if specified.
    code_source = ["__name__ = '__main__'"]
    esky_name = dist.distribution.get_name()
    code_source.append("__esky_name__ = %r" % (esky_name, ))
    code_source.append(inspect.getsource(esky.bootstrap))
    if dist.compile_bootstrap_exes:
        if sys.platform == "win32":
            #  Unfortunately this doesn't work, because the cxfreeze exe
            #  contains frozen modules that are inaccessible to a bootstrapped
            #  interpreter.  Disabled until I figure out a workaround. :-(
            pass
            #  The pypy-compiled bootstrap exe will try to load a python env
            #  into its own process and run this "take2" code to bootstrap.
            #take2_code = code_source[1:]
            #take2_code.append(_CUSTOM_WIN32_CHAINLOADER)
            #take2_code.append(dist.get_bootstrap_code())
            #take2_code = compile("\n".join(take2_code),"<string>","exec")
            #take2_code = marshal.dumps(take2_code)
            #clscript = "import marshal; "
            #clscript += "exec marshal.loads(%r); " % (take2_code,)
            #clscript = clscript.replace("%","%%")
            #clscript += "chainload(\"%s\")"
            #  Here's the actual source for the compiled bootstrap exe.
            #from esky.bdist_esky import pypy_libpython
            #code_source.append(inspect.getsource(pypy_libpython))
            #code_source.append("_PYPY_CHAINLOADER_SCRIPT = %r" % (clscript,))
            #code_source.append(_CUSTOM_PYPY_CHAINLOADER)
        code_source.append(dist.get_bootstrap_code())
        code_source = "\n".join(code_source)
        for exe in dist.get_executables(normalise=False):
            if not exe.include_in_bootstrap_env:
                continue
            bsexe = dist.compile_to_bootstrap_exe(exe, code_source)
            if sys.platform == "win32":
                fexe = os.path.join(dist.freeze_dir, exe.name)
                winres.copy_safe_resources(fexe, bsexe)
    else:
        if sys.platform == "win32":
            code_source.append(_CUSTOM_WIN32_CHAINLOADER)
        code_source.append(dist.get_bootstrap_code())
        code_source.append("bootstrap()")
        code_source = "\n".join(code_source)
        maincode = imp.get_magic() + struct.pack("<i", 0)
        maincode += marshal.dumps(
            compile(code_source, INITNAME + ".py", "exec"))
        #  Create code for a fake esky.bootstrap module
        eskycode = imp.get_magic() + struct.pack("<i", 0)
        eskycode += marshal.dumps(compile("", "esky/__init__.py", "exec"))
        eskybscode = imp.get_magic() + struct.pack("<i", 0)
        eskybscode += marshal.dumps(compile("", "esky/bootstrap.py", "exec"))
        #  Copy any core dependencies
        if "fcntl" not in sys.builtin_module_names:
            for nm in os.listdir(dist.freeze_dir):
                if nm.startswith("fcntl"):
                    dist.copy_to_bootstrap_env(nm)
        for nm in os.listdir(dist.freeze_dir):
            if is_core_dependency(nm):
                dist.copy_to_bootstrap_env(nm)
        #  Copy the loader program for each script into the bootstrap env, and
        #  append the bootstrapping code to it as a zipfile.
        for exe in dist.get_executables(normalise=False):
            if not exe.include_in_bootstrap_env:
                continue
            exepath = dist.copy_to_bootstrap_env(exe.name)
            bslib = zipfile.PyZipFile(exepath, "a", zipfile.ZIP_STORED)
            cdate = (2000, 1, 1, 0, 0, 0)
            bslib.writestr(zipfile.ZipInfo(INITNAME + ".pyc", cdate), maincode)
            bslib.writestr(zipfile.ZipInfo("esky/__init__.pyc", cdate),
                           eskycode)
            bslib.writestr(zipfile.ZipInfo("esky/bootstrap.pyc", cdate),
                           eskybscode)
            bslib.close()
コード例 #16
0
ファイル: _build.py プロジェクト: walkinreeds/pyqt-bootstrap
import os
import sys
import subprocess

from app_settings import *

try:
    import cx_Freeze
except ImportError:
    print("ERROR: cx_freeze is not installed")
    sys.exit(-1)

executables = [
    cx_Freeze.Executable("qt_bootstrap.py",
                         targetName="{}.exe".format(APP_COMMAND))
]

freezer = cx_Freeze.Freezer(executables,
                            copyDependentFiles=True,
                            createLibraryZip=False,
                            appendScriptToExe=True,
                            icon=APP_ICON,
                            silent=False)

freezer.Freeze()
コード例 #17
0
    metadata1.description = '快速代理切换程序'.decode('utf-8')
    metadata2.description = 'PyProxySwitch命令行配置工具'.decode('utf-8')
except:
    metadata1.description = '快速代理切换程序'
    metadata2.description = 'PyProxySwitch命令行配置工具'

freezer1 = cx_Freeze.Freezer(
    [cx_Freeze.Executable('PyProxySwitch/src/PyProxySwitch.pyw', base=base)],
    #                base='Console')],
    includes=['pps_qrc', 'pps_config', 'add_proxy_ui', 'pps_conf_ui'],
    excludes=['PyQt4', 'unicodedata', 'bz2'],
    # replacePaths = options.replacePaths,
    compress=True,
    optimizeFlag=1,
    # initScript = options.initScript,
    #~ path = ,
    createLibraryZip=False,
    appendScriptToExe=True,
    targetDir=targetDir,
    #        copyDependentFiles=False,
    # zipIncludes = options['zipIncludes'],
    includeFiles=includeFiles,
    icon='./PyProxySwitch/img/PyProxySwitch.ico',
    # silent = options.silent
    metadata=metadata1)

freezer2 = cx_Freeze.Freezer(
    [cx_Freeze.Executable("PyProxySwitch/src/pps_config.py", base='Console')],
    excludes=['PyQt4', 'unicodedata', 'bz2'],
    compress=True,
    optimizeFlag=1,