简体   繁体   English

如何使用 cx freeze 使用 setup.py 构建 msi 扩展

[英]How to build msi extension with setup.py using cx freeze

I wouldlike to create a.msi extension for my python script.我想为我的 python 脚本创建 a.msi 扩展。 With this file I wouldike to add possibility to the users to install python and install all depedencies of the project.有了这个文件,我想为用户增加安装 python 并安装项目的所有依赖项的可能性。 I actually don't understand how can I do this.我实际上不明白我该怎么做。 Here it's my setup.py这是我的 setup.py

setup.py:设置.py:

import os
import sys
from cx_Freeze import setup, Executable

    os.system('virtualenv sample/venv && sample\\venv\\Scripts\\activate && pip install -r requirements.txt')
    setup(name = "Myscript",
            version = "0.1",
            description = "My GUI application!",
            executables = [Executable("main.py", base=base)])

Cxfreeze will automatically build all the dependencies inlcuding python and any other modules you have imported in your script. Cxfreeze 将自动构建所有依赖项,包括 python 和您在脚本中导入的任何其他模块。 If you get any module not found error, you have to manually include it in the packages.如果您收到任何未找到模块的错误,您必须手动将其包含在包中。 Any files like images used needs to be explicitly included.任何文件(如使用的图像)都需要明确包含在内。 Here is an example code for your reference -这是一个示例代码供您参考 -

from cx_Freeze import setup, Executable

build_exe_options = {'packages': ['os', 'tkinter', 'matplotlib.backends.backend_svg', 'subprocess'],
                     'namespace_packages': ['mpl_toolkits'],
                     'include_files':['input3.json', 'SF.xlsx', 'SF logo.ico', 'Operative Temperature.pkl',
                                      'Rect_icon.png', 'Soltissim logo.png', 'SF full logo.jpg', 'IES logo.jpg']}

base = None

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

setup ( name = 'Soltissim',
        version = '2',
        description = 'SF GUI',
        options = {'build_exe': build_exe_options},
        executables = [Executable('Soltissim.py', base=base, icon='SF logo.ico])

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM