Qt wiki will be updated on October 12th 2023 starting at 11:30 AM (EEST) and the maintenance will last around 2-3 hours. During the maintenance the site will be unavailable.

Building PySide on Linux: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
No edit summary
 
No edit summary
Line 1: Line 1:
'''English''' [http://qt-devnet.developpez.com/tutoriels/python/pyside/installer/?page=linux#VI French] ''[qt-devnet.developpez.com]''
[[Category:LanguageBindings::PySide]]<br />[toc align_right=&quot;yes&amp;quot; depth=&quot;3&amp;quot;]


=Building PySide on Linux=
'''English''' &quot;French&amp;quot;:http://qt-devnet.developpez.com/tutoriels/python/pyside/installer/?page=linux#VI


PySide uses CMake’s system to build the source code packages. You can familiarize yourself with CMake at [[PySide CMake Primer|PySide_CMake_Primer]].
= Building PySide on Linux =


==The Easy Way==
PySide uses CMake's system to build the source code packages. You can familiarize yourself with CMake at [[PySide_CMake_Primer]].


There is now a “BuildScripts” repository available on GitHub:
== The Easy Way ==
 
There is now a &quot;BuildScripts&amp;quot; repository available on GitHub:


https://github.com/PySide/BuildScripts
https://github.com/PySide/BuildScripts


With this repository, you can automate the build steps outlined in this Wiki page. It also takes care of installing the correct prerequisite packages for your distribution (i.e. use <code>sudo ./dependencies.ubuntu.sh</code> to install build dependencies on Debian or Ubuntu). If there is no dependencies script for your distribution, please submit a patch. See the [https://github.com/PySide/BuildScripts#readme <span class="caps">README</span>] ''[github.com]'' file for detailed usage instructions.
With this repository, you can automate the build steps outlined in this Wiki page. It also takes care of installing the correct prerequisite packages for your distribution (i.e. use &lt;code&amp;gt;sudo ./dependencies.ubuntu.sh&amp;lt;/code&amp;gt; to install build dependencies on Debian or Ubuntu). If there is no dependencies script for your distribution, please submit a patch. See the &quot;README&amp;quot;:https://github.com/PySide/BuildScripts#readme file for detailed usage instructions.


==Prerequisites==
== Prerequisites ==


* CMake &gt;= 2.6.0
* CMake &gt;= 2.6.0
Line 21: Line 23:
* Python libraries and development headers &gt;= 2.5 (for shiboken and pyside)
* Python libraries and development headers &gt;= 2.5 (for shiboken and pyside)


==Overview==
== Overview ==


PySide consists of a chain of four interdependent packages:
PySide consists of a chain of four interdependent packages:


# The '''<span class="caps">API</span> Extractor''' library is used by the bindings generator to parse the header and typesystem files to create an internal representation of the <span class="caps">API</span>. It is based on the [http://labs.trolltech.com/page/Projects/QtScript/Generator QtScriptGenerator] ''[labs.trolltech.com]'' codebase.
# The '''API Extractor''' library is used by the bindings generator to parse the header and typesystem files to create an internal representation of the API. It is based on the &quot;QtScriptGenerator&amp;quot;:http://labs.trolltech.com/page/Projects/QtScript/Generator codebase.
# The '''Generator Runner''' (A.K.A. '''generatorrunner''') is the program that controls the bindings generation process according to the rules given by the user through headers, typesystem files and generator front-ends (such as ''Shiboken Generator''). It depends on ''<span class="caps">API</span> Extractor'' library.
# The '''Generator Runner''' (A.K.A. '''generatorrunner''') is the program that controls the bindings generation process according to the rules given by the user through headers, typesystem files and generator front-ends (such as ''Shiboken Generator''). It depends on ''API Extractor'' library.
# The '''Shiboken Generator''' (A.K.A. '''shiboken''') is the plugin that creates the PySide bindings source files from Qt headers and auxiliary files (typesystems, global.h and glue files). It depends on ''Generator Runner'' and ''<span class="caps">API</span> Extractor'' library.
# The '''Shiboken Generator''' (A.K.A. '''shiboken''') is the plugin that creates the PySide bindings source files from Qt headers and auxiliary files (typesystems, global.h and glue files). It depends on ''Generator Runner'' and ''API Extractor'' library.
# '''PySide Qt bindings''' (A.K.A. '''pyside''') is the set of typesystem definitions and glue code that allows generation of Python Qt binding modules using the PySide toolchain. It depends on the ''Shiboken'' libraries and ''Generator Runner''.
# '''PySide Qt bindings''' (A.K.A. '''pyside''') is the set of typesystem definitions and glue code that allows generation of Python Qt binding modules using the PySide toolchain. It depends on the ''Shiboken'' libraries and ''Generator Runner''.


There is also an optional package called '''pyside-tools''' which provides some useful utilities for creating PySide applications. If you don’t want or need that package, skip the commands that say “pyside-tools” in them in the scripts below.
There is also an optional package called '''pyside-tools''' which provides some useful utilities for creating PySide applications. If you don't want or need that package, skip the commands that say &quot;pyside-tools&amp;quot; in them in the scripts below.


===Getting the source code===
=== Getting the source code ===


The source code for the current stable release can be downloaded from [[PySideDownloads]].
The source code for the current stable release can be downloaded from [[PySideDownloads]].


Alternatively, you can get the latest development branch from the repos:<br />
Alternatively, you can get the latest development branch from the repos:<br /><code><br />git clone git://gitorious.org/pyside/apiextractor.git<br />git clone git://gitorious.org/pyside/generatorrunner.git<br />git clone git://gitorious.org/pyside/shiboken.git<br />git clone git://gitorious.org/pyside/pyside.git<br />git clone git://gitorious.org/pyside/pyside-tools.git<br /></code>


==Building and installing==
== Building and installing ==


===Sandbox===
=== Sandbox ===


If you wish to install PySide into a local sandbox then follow these instructions, otherwise you can skip this step.
If you wish to install PySide into a local sandbox then follow these instructions, otherwise you can skip this step.


We will assume that <span class="caps">PYSIDESANDBOXPATH</span> will be the path to your local sandbox.<br />
We will assume that PYSIDESANDBOXPATH will be the path to your local sandbox.<br /><code><br />export PYSIDESANDBOXPATH=$HOME/sandbox<br /></code>


Setup these variables accordingly.<br />
Setup these variables accordingly.<br /><code><br />export PATH=$PYSIDESANDBOXPATH/bin:$PATH<br />export PYTHONPATH=$PYSIDESANDBOXPATH/lib/python2.6/site-packages:$PYTHONPATH<br />export LD_LIBRARY_PATH=$PYSIDESANDBOXPATH/lib:$LD_LIBRARY_PATH<br />export PKG_CONFIG_PATH=$PYSIDESANDBOXPATH/lib/pkgconfig:$PKG_CONFIG_PATH<br /># set -DENABLE_ICECC=1 if you're using the icecream distributed compiler<br />alias runcmake='cmake .. -DCMAKE_INSTALL_PREFIX=$PYSIDESANDBOXPATH -DCMAKE_BUILD_TYPE=Debug -DENABLE_ICECC=0'<br /></code>


It makes sense to place these variables in a shell script that you can reference whenever you need to work with the PySide bindings from the sandbox (especially if you have a system-wide installation of PySide as well).
It makes sense to place these variables in a shell script that you can reference whenever you need to work with the PySide bindings from the sandbox (especially if you have a system-wide installation of PySide as well).


In the next step replace ''cmake'' with '''runcmake''', and
In the next step replace ''cmake'' with '''runcmake''', and <s>sudo</s> make install.


<del>sudo</del>
=== Building ===


make install.
For each package in order (apiextractor, generatorrunner, shiboken, pyside), run the following commands:


===Building===
<code><br />mkdir build<br />cd build<br />cmake ..<br />make<br />sudo make install<br /></code>


For each package in order (apiextractor, generatorrunner, shiboken, pyside), run the following commands:
Depending on the package and whether there is an existing library with the same version number already installed, you might need to run &lt;code&amp;gt;ldconfig&amp;lt;/code&amp;gt; to update the run-time linker cache.


Depending on the package and whether there is an existing library with the same version number already installed, you might need to run <code>ldconfig</code> to update the run-time linker cache.
<code><br />sudo ldconfig<br /></code>


That’s it! PySide should now be successfully built!
That's it! PySide should now be successfully built!


==Practical tips==
== Practical tips ==


===Use build scripts for a successful life===
=== Use build scripts for a successful life ===


Especially if you are just interested in tracking the PySide head, you might be interested in using the following utility scripts.
Especially if you are just interested in tracking the PySide head, you might be interested in using the following utility scripts.


'''clone_all''':
'''clone_all''':
<code><br />#!/usr/bin/env bash
allrepos=&quot;apiextractor generatorrunner shiboken pyside pyside-mobility&amp;quot;
for repo in ${allrepos} ; do<br /> git clone git://gitorious.org/pyside/$repo.git<br />done<br /></code>


'''pull_all''':
'''pull_all''':
<code><br />#!/usr/bin/env bash
alldirs=(&quot;apiextractor&amp;quot; &quot;generatorrunner&amp;quot; &quot;shiboken&amp;quot; &quot;pyside&amp;quot; &quot;pyside-mobility&amp;quot;)
if [ $# == 0 ] ; then<br /> dirs=(&quot;${alldirs[&amp;#64;]}&quot;)<br />else<br /> dirs=(&quot;$&amp;amp;#64;&quot;)<br />fi
for d in &quot;${dirs[&amp;#64;]}&quot; ; do<br /> (cd &quot;$d&amp;quot;<br /> git pull origin master<br /> ) # exit from &quot;$d&amp;quot;<br />done<br /></code>


'''build_all''':
'''build_all''':


===Categories:===
<code><br />#!/usr/bin/env bash
 
alldirs=(&quot;apiextractor&amp;quot; &quot;generatorrunner&amp;quot; &quot;shiboken&amp;quot; &quot;pyside&amp;quot;)
 
if [ $# == 0 ] ; then<br /> dirs=(&quot;${alldirs[&amp;#64;]}&quot;)<br />else<br /> dirs=(&quot;$&amp;amp;#64;&quot;)<br />fi


* [[:Category:LanguageBindings|LanguageBindings]]
for d in &quot;${dirs[&amp;#64;]}&quot; ; do<br /> rm -rf &quot;$d/build&amp;quot;<br /> mkdir -p &quot;$d/build&amp;quot;<br /> (cd &quot;$d/build&amp;quot;<br /> cmake .. &amp;&amp; make -j4 &amp;&amp; sudo make install || exit 1<br /> ) # exit from &quot;$d/build&amp;quot;<br />done<br /></code>
** [[:Category:LanguageBindings::PySide|PySide]]

Revision as of 14:28, 23 February 2015


[toc align_right="yes&quot; depth="3&quot;]

English "French&quot;:http://qt-devnet.developpez.com/tutoriels/python/pyside/installer/?page=linux#VI

Building PySide on Linux

PySide uses CMake's system to build the source code packages. You can familiarize yourself with CMake at PySide_CMake_Primer.

The Easy Way

There is now a "BuildScripts&quot; repository available on GitHub:

https://github.com/PySide/BuildScripts

With this repository, you can automate the build steps outlined in this Wiki page. It also takes care of installing the correct prerequisite packages for your distribution (i.e. use <code&gt;sudo ./dependencies.ubuntu.sh&lt;/code&gt; to install build dependencies on Debian or Ubuntu). If there is no dependencies script for your distribution, please submit a patch. See the "README&quot;:https://github.com/PySide/BuildScripts#readme file for detailed usage instructions.

Prerequisites

  • CMake >= 2.6.0
  • Qt libraries and development headers >= 4.6 (preferably the latest stable release)
  • libxml2 and development headers >= 2.6.32 (for apiextractor only)
  • libxslt and development headers >= 1.1.19 (for apiextractor only)
  • Python libraries and development headers >= 2.5 (for shiboken and pyside)

Overview

PySide consists of a chain of four interdependent packages:

  1. The API Extractor library is used by the bindings generator to parse the header and typesystem files to create an internal representation of the API. It is based on the "QtScriptGenerator&quot;:http://labs.trolltech.com/page/Projects/QtScript/Generator codebase.
  2. The Generator Runner (A.K.A. generatorrunner) is the program that controls the bindings generation process according to the rules given by the user through headers, typesystem files and generator front-ends (such as Shiboken Generator). It depends on API Extractor library.
  3. The Shiboken Generator (A.K.A. shiboken) is the plugin that creates the PySide bindings source files from Qt headers and auxiliary files (typesystems, global.h and glue files). It depends on Generator Runner and API Extractor library.
  4. PySide Qt bindings (A.K.A. pyside) is the set of typesystem definitions and glue code that allows generation of Python Qt binding modules using the PySide toolchain. It depends on the Shiboken libraries and Generator Runner.

There is also an optional package called pyside-tools which provides some useful utilities for creating PySide applications. If you don't want or need that package, skip the commands that say "pyside-tools&quot; in them in the scripts below.

Getting the source code

The source code for the current stable release can be downloaded from PySideDownloads.

Alternatively, you can get the latest development branch from the repos:

<br />git clone git://gitorious.org/pyside/apiextractor.git<br />git clone git://gitorious.org/pyside/generatorrunner.git<br />git clone git://gitorious.org/pyside/shiboken.git<br />git clone git://gitorious.org/pyside/pyside.git<br />git clone git://gitorious.org/pyside/pyside-tools.git<br />

Building and installing

Sandbox

If you wish to install PySide into a local sandbox then follow these instructions, otherwise you can skip this step.

We will assume that PYSIDESANDBOXPATH will be the path to your local sandbox.

<br />export PYSIDESANDBOXPATH=$HOME/sandbox<br />

Setup these variables accordingly.

<br />export PATH=$PYSIDESANDBOXPATH/bin:$PATH<br />export PYTHONPATH=$PYSIDESANDBOXPATH/lib/python2.6/site-packages:$PYTHONPATH<br />export LD_LIBRARY_PATH=$PYSIDESANDBOXPATH/lib:$LD_LIBRARY_PATH<br />export PKG_CONFIG_PATH=$PYSIDESANDBOXPATH/lib/pkgconfig:$PKG_CONFIG_PATH<br /># set -DENABLE_ICECC=1 if you're using the icecream distributed compiler<br />alias runcmake='cmake .. -DCMAKE_INSTALL_PREFIX=$PYSIDESANDBOXPATH -DCMAKE_BUILD_TYPE=Debug -DENABLE_ICECC=0'<br />

It makes sense to place these variables in a shell script that you can reference whenever you need to work with the PySide bindings from the sandbox (especially if you have a system-wide installation of PySide as well).

In the next step replace cmake with runcmake, and sudo make install.

Building

For each package in order (apiextractor, generatorrunner, shiboken, pyside), run the following commands:

<br />mkdir build<br />cd build<br />cmake ..<br />make<br />sudo make install<br />

Depending on the package and whether there is an existing library with the same version number already installed, you might need to run <code&gt;ldconfig&lt;/code&gt; to update the run-time linker cache.

<br />sudo ldconfig<br />

That's it! PySide should now be successfully built!

Practical tips

Use build scripts for a successful life

Especially if you are just interested in tracking the PySide head, you might be interested in using the following utility scripts.

clone_all:

<br />#!/usr/bin/env bash

allrepos=&quot;apiextractor generatorrunner shiboken pyside pyside-mobility&amp;quot;

for repo in ${allrepos} ; do<br /> git clone git://gitorious.org/pyside/$repo.git<br />done<br />

pull_all:

<br />#!/usr/bin/env bash

alldirs=(&quot;apiextractor&amp;quot; &quot;generatorrunner&amp;quot; &quot;shiboken&amp;quot; &quot;pyside&amp;quot; &quot;pyside-mobility&amp;quot;)

if [ $# == 0 ] ; then<br /> dirs=(&quot;${alldirs[&amp;#64;]}&quot;)<br />else<br /> dirs=(&quot;$&amp;amp;#64;&quot;)<br />fi

for d in &quot;${dirs[&amp;#64;]}&quot; ; do<br /> (cd &quot;$d&amp;quot;<br /> git pull origin master<br /> ) # exit from &quot;$d&amp;quot;<br />done<br />

build_all:

<br />#!/usr/bin/env bash

alldirs=(&quot;apiextractor&amp;quot; &quot;generatorrunner&amp;quot; &quot;shiboken&amp;quot; &quot;pyside&amp;quot;)

if [ $# == 0 ] ; then<br /> dirs=(&quot;${alldirs[&amp;#64;]}&quot;)<br />else<br /> dirs=(&quot;$&amp;amp;#64;&quot;)<br />fi

for d in &quot;${dirs[&amp;#64;]}&quot; ; do<br /> rm -rf &quot;$d/build&amp;quot;<br /> mkdir -p &quot;$d/build&amp;quot;<br /> (cd &quot;$d/build&amp;quot;<br /> cmake .. &amp;&amp; make -j4 &amp;&amp; sudo make install || exit 1<br /> ) # exit from &quot;$d/build&amp;quot;<br />done<br />