4

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

  1. 编译 Qt、PySide 绑定、Python 2.7 以及每次导入都使用单独的过程是最好的吗?

1.1。如果我这样做,是否更容易跟踪错误?

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

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

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

编辑: 通过编译意味着将 Python 脚本转换为可执行的 Windows/Linux 程序,就像 py2exe、cx_Freeze 或 PyInstaller 一样。

我很欣赏你的建议。

4

2 回答 2

4

我唯一的经验是使用 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']
)
于 2013-08-24T15:33:24.190 回答
-2

按照PyPI 上的 PySide 页面上给出的说明进行操作。

于 2013-08-23T08:26:56.617 回答