4

I have lot of pain while compiling pyside code for Linux...much less for Windows, and my source is around 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?

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?

  2. Is it better to rewrite code for PyQt instead of 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 ) ?

EDIT: By compiling mean to convert Python scripts into executable Windows/Linux programs, as py2exe, cx_Freeze or PyInstaller do.

I appreciate your suggestions.

Alex
  • 3,167
  • 6
  • 35
  • 50
  • 1
    I don't understand your question: 1.- Do you want to build PySide? -> Use the Nicola's answer (BTW, compiling it on linux is much more easy that on windows) 2.- Compile an app using Pyside? -> Well, that is python code, it doesn't compile... 3.- Using Python Code in a C++ app? -> http://docs.python.org/2/extending/embedding.html – Angel Aug 23 '13 at 21:11
  • Pythonist could understand me...please see: http://stackoverflow.com/questions/1689086/are-there-any-alternatives-to-py2exe – Alex Aug 24 '13 at 08:54
  • 1
    OH! Do you want to make a standalone executable? Well, you don't need to compile nothing (at least, using cx_freeze). Just install cx_freeze (or py2exe, etc, etc), make a setup.py file, run it (the setup.py file), and be happy :) However, the trace errors are a pain to see (in windows). – Angel Aug 24 '13 at 15:27

2 Answers2

4

My only experience is with cx_freeze (using python 3.3). It works in Windows/Linux/OSX. A simple example can be found here (with its documentation): 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']
)
Angel
  • 360
  • 6
  • 13
-2

Follow the instructions given on the PySide page on PyPI.

Nicola Musatti
  • 17,834
  • 2
  • 46
  • 55