编译PySide应用程序的最佳方法是什么?

时间:2013-08-23 08:14:18

标签: python qt cross-compiling pyside

在为Linux编译pyside代码时我有很多痛苦......对于Windows来说更少,而我的源代码大约是300kb。我想知道编译它最安全的方法是什么。

  1. 编译Qt,PySide绑定,Python 2.7以及使用单独进程进行每次导入是最好的吗?
  2. 1.1。如果我这样做,跟踪错误会更容易吗?

    1. qt4-qmake有没有理由在编译时使用它?

    2. 为PyQt而不是Pyside重写代码是否更好?

    3. 是否依赖于某些版本的快乐组合,例如:(Qt v4.8.2,pyside 1.0.1,python 2.7.3)?

    4. 修改 通过编译平均值将Python脚本转换为可执行的Windows / Linux程序,如py2exe,cx_Freeze或PyInstaller。

      感谢您的建议。

2 个答案:

答案 0 :(得分:3)

我唯一的经验是使用cx_freeze(使用python 3.3)。它适用于Windows / Linux / OSX。 这里有一个简单的例子(及其文档):http://cx-freeze.readthedocs.org/en/latest/distutils.html#distutils

另一个例子:

from cx_Freeze import setup, Executable

# dependencies
build_exe_options = {
    "packages": ["os", "sys", "glob", "simplejson", "re", "atexit", "PySide.QtCore", "PySide.QtGui", "PySide.QtXml"],
    "include_files": [("./example/Ui/MainWindow.ui", "Ui/MainWindow.ui"),
                      ("./example/Ui/ExampleWidget.ui", "Ui/ExampleWidget.ui"),
                      ("./example/Ui/TestDialog.ui", "Ui/TestDialog.ui"),
                      ("./example/Resources/style.qss", "Ui/style.qss")], # this isn't necessary after all
    "excludes": ["Tkinter", "Tkconstants", "tcl"],
    "build_exe": "build",
    "icon": "./example/Resources/Icons/monitor.ico"
}

executable = [
    Executable("./bin/Example.py",
               base="Win32GUI",
               targetName="Example.exe",
               targetDir="build",
               copyDependentFiles=True)
]

setup(
    name="Example",
    version="0.1",
    description="Example", # Using the word "test" makes the exe to invoke the UAC in win7. WTH?
    author="Me",
    options={"build_exe": build_exe_options},
    executables=executable,
    requires=['PySide', 'cx_Freeze', 'simplejson']
)

答案 1 :(得分:-2)

按照PySide page on PyPI上的说明进行操作。

相关问题