简体   繁体   English

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

[英]What is the best approach with compiling PySide application

I have lot of pain while compiling pyside code for Linux...much less for Windows, and my source is around 300kb. 编译Linux的pyside代码时我有很多痛苦......对于Windows来说更少,而我的源代码大约为300kb。 I would like to know what is the safest way to compile it. 我想知道什么是最安全的编译方式。

  1. Is it the best to compile Qt, PySide bindings, Python 2.7, and every import with separate process? 编译Qt,PySide绑定,Python 2.7以及使用单独进程的每个导入是最好的吗?

1.1. 1.1。 If I do it this way, is it easier to trace errors? 如果我这样做,跟踪错误会更容易吗?

  1. Does qt4-qmake have any reason to use it while compiling? qt4-qmake有没有理由在编译时使用它?

  2. Is it better to rewrite code for PyQt instead of Pyside? 为PyQt而不是Pyside重写代码是否更好?

  3. Are it depending about happy combination of some versions, for instance: ( Qt v4.8.2, pyside 1.0.1, python 2.7.3 ) ? 它取决于某些版本的快乐组合,例如:(Qt v4.8.2,pyside 1.0.1,python 2.7.3)?

EDIT: By compiling mean to convert Python scripts into executable Windows/Linux programs, as py2exe, cx_Freeze or PyInstaller do. 编辑:通过编译平均值将Python脚本转换为可执行的Windows / Linux程序,如py2exe,cx_Freeze或PyInstaller。

I appreciate your suggestions. 我感谢你的建议。

My only experience is with cx_freeze (using python 3.3). 我唯一的经验是使用cx_freeze(使用python 3.3)。 It works in Windows/Linux/OSX. 它适用于Windows / Linux / OSX。 A simple example can be found here (with its documentation): http://cx-freeze.readthedocs.org/en/latest/distutils.html#distutils 这里有一个简单的例子(及其文档): http//cx-freeze.readthedocs.org/en/latest/distutils.html#distutils

Another example: 另一个例子:

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']
)

按照PyPIPySide页面上的说明进行操作。

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

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