В Python с cx_Freeze, как исключить большие numpy dll-файлы - PullRequest
0 голосов
/ 10 ноября 2018

Моя программа на python использует numpy, и использование cx_Freeze приводит к очень большому установочному пакету msi. Я решил, что это связано с несколькими DLL в Numpy / Core. Можно ли исключить эти конкретные файлы в сборке?

В моем файле setup.py я попытался с bin_excluded, но также не работает:

import os
import sys
from cx_Freeze import setup, Executable
import numpy
import tkinter

shortcut_table = [
    ("DesktopShortcut",         # Shortcut
     "DesktopFolder",           # Directory_
     "PhotonSlicer",            # Name
     "TARGETDIR",               # Component_
     "[TARGETDIR]\PhotonSlicer.exe",    # Target
     None,              # Arguments
     None,              # Description
     None,              # Hotkey
     "",                # Icon
     0,                 # IconIndex
     None,              # ShowCmd
     "TARGETDIR",                   # WkDir
     )
    ]


# Now create the table dictionary
msi_data = {"Shortcut": shortcut_table}

# Change some default MSI options and specify the use of the above      defined tables
bdist_msi_options = {'data': msi_data}

# Dependencies are automatically detected, but it might need fine tuning.
# build_exe_options = {"packages": ["os", "numpy"],"include_files": [""], "include_msvcr" : True}
PYTHON_INSTALL_DIR = os.path.dirname(os.path.dirname(os.__file__))

build_exe_options = {
                "packages": ["os", "numpy"],
                "include_msvcr" : True,
                "bin_excludes":["mkl_avx.dll",
                                "mkl_avx2.dll",
                                "mkl_avx512.dll",
                                "mkl_avx512_mic.dll",
                                "mkl_mc.dll",
                                "mkl_mc2.dll",
                                "mkl_mc3.dll",
                                "vml_avx.dll",
                                "vml_avx2.dll",
                                "vml_avx512.dll",
                                "vml_avx512_mic.dll",
                                "mkl_vml_mc.dll",
                                "mkl_vml_mc2.dll",
                                "mkl_vml_mc3.dll",
                                "svml_dispmd.dll"],
                "excludes":[""],
                "include_files":[
                                os.path.join(PYTHON_INSTALL_DIR,'DLLs','tcl86t.dll'), 
                                os.path.join(PYTHON_INSTALL_DIR,'DLLs','tk86t.dll'),
                                "PhotonSlicer.gif",
                                "newfile.photon",
                                "STLs/"
                                ]
                }

os.environ['TCL_LIBRARY'] = os.path.join(PYTHON_INSTALL_DIR, 'tcl', 'tcl8.6')
os.environ['TK_LIBRARY'] = os.path.join(PYTHON_INSTALL_DIR, 'tcl', 'tk8.6')

# GUI applications require a different base on Windows (the default is for a
# console application).
base = None
if sys.platform == "win32":
    base = "Win32GUI"

if 'bdist_msi' in sys.argv:
    sys.argv += ['--initial-target-dir', 'c:\PhotonSlicer']

setup(  name = "PhotonSlicer_GUI",
        version = "0.1",
        author= "Photonsters",
        url="https://github.com/Photonsters",
        description = "Converts STL (binary) files to Images or PhotonFile.",
        options = {"build_exe": build_exe_options,"bdist_msi": bdist_msi_options},
        executables = [Executable(script="PhotonSlicer.py",     base=base,icon="PhotonSlicer.ico",)]
)

Возможно, есть возможность вручную удалить их из каталога временной сборки и затем упаковать в MSI?

...