Example #1
0
def package_windows(dev):
    from cx_Freeze import Freezer, Executable
    app_version = get_module_version('core')
    if op.exists('dist'):
        shutil.rmtree('dist')

    is64bit = platform.architecture()[0] == '64bit'
    exe = Executable(
        targetName='PdfMasher.exe',
        script='run.py',
        base='Win32GUI',
        icon='images\\main_icon.ico',
    )
    freezer = Freezer(
        [exe],
        # Since v4.2.3, cx_freeze started to falsely include tkinter in the package. We exclude it explicitly because of that.
        excludes=['tkinter'],
    )
    freezer.Freeze()

    # Now we have to copy pdfminder's cmap to our root dist dir (We'll set CMAP_PATH env at runtime)
    import pdfminer.cmap
    cmap_src = op.dirname(pdfminer.cmap.__file__)
    cmap_dest = op.join('dist', 'cmap')
    shutil.copytree(cmap_src, cmap_dest)

    if not dev:
        # Copy qt plugins
        plugin_dest = op.join('dist', 'qt4_plugins')
        plugin_names = ['accessible', 'codecs', 'iconengines', 'imageformats']
        copy_qt_plugins(plugin_names, plugin_dest)

        # Compress with UPX
        if not is64bit:  # UPX doesn't work on 64 bit
            libs = [
                name for name in os.listdir('dist')
                if op.splitext(name)[1] in ('.pyd', '.dll', '.exe')
            ]
            for lib in libs:
                print_and_do("upx --best \"dist\\{0}\"".format(lib))

    help_path = 'build\\help'
    print("Copying {0} to dist\\help".format(help_path))
    shutil.copytree(help_path, 'dist\\help')
    if is64bit:
        # In 64bit mode, we don't install the VC redist as a prerequisite. We just bundle the
        # appropriate dlls.
        shutil.copy(find_in_path('msvcr100.dll'), 'dist')
        shutil.copy(find_in_path('msvcp100.dll'), 'dist')

    if not dev:
        # AdvancedInstaller.com has to be in your PATH
        # this is so we don'a have to re-commit installer.aip at every version change
        installer_file = 'qt\\installer64.aip' if is64bit else 'qt\\installer.aip'
        shutil.copy(installer_file, 'installer_tmp.aip')
        print_and_do(
            'AdvancedInstaller.com /edit installer_tmp.aip /SetVersion {}'.
            format(app_version))
        print_and_do('AdvancedInstaller.com /build installer_tmp.aip -force')
        os.remove('installer_tmp.aip')
Example #2
0
 def __init__(self, executables, projectPathDict, useData, base, icon,
              metadata, initScript, path, compress, optimizeFlag,
              copyDependentFiles, appendScriptToExe, appendScriptToLibrary,
              includes, excludes, replacePaths, binIncludes, binExcludes,
              binPathIncludes, binPathExcludes, includeFiles, zipIncludes,
              namespacePackages, constantsModules, packages):
     Freezer.__init__(self,
                      executables,
                      silent=True,
                      icon=icon,
                      metadata=metadata,
                      includeMSVCR=True,
                      targetDir=projectPathDict['builddir'],
                      initScript=initScript,
                      path=path,
                      base=base,
                      compress=compress,
                      optimizeFlag=optimizeFlag,
                      copyDependentFiles=copyDependentFiles,
                      appendScriptToExe=appendScriptToExe,
                      appendScriptToLibrary=appendScriptToLibrary,
                      includes=includes,
                      excludes=excludes,
                      replacePaths=replacePaths,
                      binIncludes=binIncludes,
                      binExcludes=binExcludes,
                      binPathIncludes=binPathIncludes,
                      binPathExcludes=binPathExcludes,
                      includeFiles=includeFiles,
                      zipIncludes=zipIncludes,
                      namespacePackages=namespacePackages,
                      constantsModules=constantsModules,
                      packages=packages)
Example #3
0
 def __init__(self, executables,
              projectPathDict,
              useData,
              base,
              icon,
              metadata,
              initScript,
              path,
              compress,
              optimizeFlag,
              copyDependentFiles,
              appendScriptToExe,
              appendScriptToLibrary,
              includes,
              excludes,
              replacePaths,
              binIncludes,
              binExcludes,
              binPathIncludes,
              binPathExcludes,
              includeFiles,
              zipIncludes,
              namespacePackages,
              constantsModules,
              packages):
     Freezer.__init__(self, executables,
                      silent=True,
                      icon=icon,
                      metadata=metadata,
                      includeMSVCR=True,
                      targetDir=projectPathDict['builddir'],
                      initScript=initScript,
                      path=path,
                      base=base,
                      compress=compress,
                      optimizeFlag=optimizeFlag,
                      copyDependentFiles=copyDependentFiles,
                      appendScriptToExe=appendScriptToExe,
                      appendScriptToLibrary=appendScriptToLibrary,
                      includes=includes,
                      excludes=excludes,
                      replacePaths=replacePaths,
                      binIncludes=binIncludes,
                      binExcludes=binExcludes,
                      binPathIncludes=binPathIncludes,
                      binPathExcludes=binPathExcludes,
                      includeFiles=includeFiles,
                      zipIncludes=zipIncludes,
                      namespacePackages=namespacePackages,
                      constantsModules=constantsModules,
                      packages=packages
                      )
Example #4
0
def freeze():
    from cx_Freeze import Executable, Freezer
    import shutil
    from distutils.dist import DistributionMetadata

    base = "Console"

    if sys.platform == "win32":
        base = "Win32GUI"

    dep_modules = ["PySide.QtNetwork", "PySide.QtWebKit", "atexit"]

    executables = [Executable('src/broom.py')]

    if os.path.exists(output_dir):
        shutil.rmtree(output_dir)

    class MetaData(DistributionMetadata):
        def __init__(self):
            DistributionMetadata.__init__(self)
            self.name = 'broom'
            self.version = __version__
            self.description = u'Broom ' + __version__

    freezer = Freezer(
        executables,
        includeFiles=[],
        includeMSVCR=True,
        packages=dep_modules,
        #includes=dep_modules,
        excludes=[],
        replacePaths=[],
        copyDependentFiles=True,
        base=base,
        path=sys.path + ['src'],
        createLibraryZip=True,
        appendScriptToExe=False,
        targetDir=output_dir,
        zipIncludes=[],
        #icon=icon
        metadata=MetaData())
    freezer.Freeze()
includes = freeze.get_includes()
excludes.extend(freeze.get_excludes())

## Freeze

ex = Executable(
    scriptFile,
    #icon=iconFile,
    #appendScriptToExe = True,
    #base = 'Win32GUI', # this is what hides the console
)

f = Freezer(
    {ex: True},
    includes=includes,
    excludes=excludes,
    targetDir=distDir,
    #copyDependentFiles = True,
    #appendScriptToExe=True,
    optimizeFlag=1,
    compress=False,
    silent=True,
)

f.Freeze()

# Copy resources.
# Some day, cx_Freeze should do this automatically ...
freeze.freeze_copy_resources(distDir, 'imageio')
Example #6
0
# be sure the target dir is removed
shutil.rmtree(target_dir, ignore_errors=True)

frescobaldi = Executable(
    '../frescobaldi',
    icon='../frescobaldi_app/icons/frescobaldi.ico',
    appendScriptToExe=True,
    base='Win32GUI',  # no console
)

f = Freezer(
    [frescobaldi],
    includes=includes,
    packages=packages,
    excludes=excludes,
    targetDir=target_dir,
    copyDependentFiles=True,
    compress=False,
    # silent = True,
)

f.Freeze()


def copy_plugins(name):
    """Copies a folder from the Qt4 plugins directory."""
    path = imp.find_module('PyQt5')[1]
    folder = os.path.join(path, 'plugins', name)
    target = os.path.join(target_dir, name)
    shutil.rmtree(target, ignore_errors=True)
    shutil.copytree(folder, target)
Example #7
0
            'Win32GUI',  # this is what hides the console                            
        )
    else:
        ex = Executable(
            scriptFile,
            targetName='pyzo',
        )
    executables[ex] = True

f = Freezer(
    executables,
    includes=includes,
    binIncludes=['libssl.so', 'libcrypto.so'],
    excludes=excludes,
    targetDir=distDir,
    copyDependentFiles=True,
    includeMSVCR=True,  # Let cx_Freeze find it for us
    #                 appendScriptToExe=True,
    #                 optimizeFlag=1,
    compress=False,
    silent=True,
)

f.Freeze()

## Process source code and other resources

MANIFEST_TEMPLATE = """
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<noInheritable/>
Example #8
0
                            # appendScriptToExe = True,
                            base = 'Win32GUI', # this is what hides the console                            
                            )
    else:
        ex = Executable(    scriptFile, 
                            targetName = 'pyzo',
                        )
    executables[ex] = True


f = Freezer(    executables, 
                includes = includes,
                binIncludes = ['libssl.so', 'libcrypto.so'],
                excludes = excludes,
                targetDir = distDir,
                # copyDependentFiles = True,
                includeMSVCR = True,  # Let cx_Freeze find it for us
#                 appendScriptToExe=True,
#                 optimizeFlag=1, 
                compress=False,
                silent=True,
            )

f.Freeze()


## Process source code and other resources



for d in (os.path.join(distDir, 'PyQt5'), distDir):
    if os.path.isdir(d):
Example #9
0
            scriptFile,
            icon=iconfile,
            appendScriptToExe=True,
        )
    else:
        # Unix Build
        ex = Executable(scriptFile, )

    executables[ex] = True

f = Freezer(
    executables,
    #includes=includes,
    excludes=[],  #excludes,
    targetDir=distdir,
    #initScript="/Users/george/git/OpenMeta-analyst-/src/open_meta_mac.py",
    copyDependentFiles=True,
    #appendScriptToExe=True,
    #optimizeFlag=1,
    compress=False,
    #silent=True,
)

f.Freeze()

# Change the absolute paths in all library files to relative paths
# This should be a cx_freeze task, but cx_freeze doesn't do it
if sys.platform == 'darwin':
    print("Patch librarys for MacOS...")
    shippedfiles = os.listdir(distdir)

    for file in shippedfiles:
Example #10
0
                               }
                   },
    )

elif method == "cxfreeze":
    print "cxfreeze"
    from cx_Freeze import setup, Executable, Freezer
    exe = Executable(
        script="main.py",
        targetName="telesk.exe"
    )
    freezer = Freezer([exe],
        base = "Win32GUI",
        icon = "images\\telesk_default.ico",
        #compress = True,
        path = None,
        createLibraryZip = False,
        #copyDependentFiles =True,
        appendScriptToExe = True,
        #appendScriptToLibrary = True,
        targetDir = 'dist',
        #includes = ["sqlalchemy.dialects.mysql", "PyQt4.QtNetwork"],
        excludes = ['_gtkagg', '_tkagg', 'bsddb', 'curses', 'email', 'pywin.debugger', 'pywin.debugger.dbgcon', 'pywin.dialogs',"Tkconstants","Tkinter","tcl"]
    )
    freezer.Freeze()
    """setup(
        name = "Telesk",
        version = "0.2",
        description = "Telesk Softphone by SKAT LTD",
        executables = [exe]
    )"""