【问题标题】:Creating MSI with cx_freeze and bdist_msi for PySide app使用 cx_freeze 和 bdist_msi 为 PySide 应用程序创建 MSI
【发布时间】:2013-06-25 21:31:52
【问题描述】:

我有一个 PySide 应用程序,我正在尝试使用 cx_freeze 将其打包到 MSI 中。我可以成功创建一个 MSI 安装程序,但是我无法弄清楚如何列出要包含在包中的其他模块。这是我的setup.py 脚本:

import sys
from cx_Freeze import setup, Executable

company_name = 'My Company Name'
product_name = 'My Gui'

bdist_msi_options = {
    'upgrade_code': '{66620F3A-DC3A-11E2-B341-002219E9B01E}',
    'add_to_path': False,
    'initial_target_dir': r'[ProgramFilesFolder]\%s\%s' % (company_name, product_name),
    # 'includes': ['atexit', 'PySide.QtNetwork'], # <-- this causes error
    }

# GUI applications require a different base on Windows
base = None
if sys.platform == 'win32':
    base = 'Win32GUI'

exe = Executable(script='MyGui.py',
                 base=base,
                 icon='MyGui.ico',
                )

setup(name=product_name,
      version='1.0.0',
      description='blah',
      executables=[exe],
      options={'bdist_msi': bdist_msi_options})

我可以使用命令成功创建 MSI

python setup.py bdist_msi

但是根据 documentation 用于打包 PySide 应用程序,我需要包含模块 atexitPySide.QtNetwork。我尝试通过将'includes' 键添加到bdist_msi_options 来做到这一点,但取消注释该行会导致以下错误:

running bdist_msi
error: error in setup script: command 'bdist_msi' has no such option 'includes'

如何让这些模块与生成的可执行文件一起包含在内?

【问题讨论】:

    标签: python python-3.x pyside distutils cx-freeze


    【解决方案1】:

    我在 cx-freeze 邮件列表上发布了同样的问题,并收到了an answer

    'includes''packages' 选项用于 'build_exe' 命令,因此对 setup 的调用需要包含这两个命令。

    bdist_msi_options = {
        'upgrade_code': '{66620F3A-DC3A-11E2-B341-002219E9B01E}',
        'add_to_path': False,
        'initial_target_dir': r'[ProgramFilesFolder]\%s\%s' % (company_name, product_name),
        }
    
    build_exe_options = {
        'includes': ['atexit', 'PySide.QtNetwork'],
        }
    
    ...
    
    setup(name=product_name,
          version='1.0.0',
          description='blah',
          executables=[exe],
          options={
              'bdist_msi': bdist_msi_options,
              'build_exe': build_exe_options})
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-11-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-07-23
      • 2018-02-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多