使用cx_freeze和bdist_msi为PySide应用程序创建MSI [英] Creating MSI with cx_freeze and bdist_msi for PySide app

查看:63
本文介绍了使用cx_freeze和bdist_msi为PySide应用程序创建MSI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have a PySide application that I'm trying to package into an MSI using cx_freeze. I can successfully create an MSI installer, but I'm having trouble figuring out how to list additional modules to be included in the package. Here's my setup.py script:

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

I can successfully create an MSI using the command

python setup.py bdist_msi

但是根据用于包装PySide应用程序的文档,我需要包括模块 atexit PySide.QtNetwork 。我试图通过在 bdist_msi_options 中添加'includes'键来做到这一点,但是取消注释该行会导致以下错误:

But according to the documentation for packaging PySide applications, I need to include the modules atexit and PySide.QtNetwork. I tried to do this by adding the 'includes' key to bdist_msi_options, but uncommenting that line causes the following error:

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

如何将那些模块与生成的可执行文件一起包含?

How do I get those modules to be included along with the generated executable?

推荐答案

我在cx-freeze邮件列表中发布了相同的问题,并收到了答案

I posted the same question on the cx-freeze mailing list, and received an answer.

'includes''packages'选项用于'build_exe'命令,因此对安装程序的调用需要同时包含这两个命令。

The 'includes' and 'packages' options are for the 'build_exe' command, so the call to setup needs to include both commands.

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})

这篇关于使用cx_freeze和bdist_msi为PySide应用程序创建MSI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆