aboutsummaryrefslogtreecommitdiffstats
path: root/docs/index.rst
blob: 521ca0617ae248a0c2713fef979bfe4db6c5eb31 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
======
PySide
======

.. image:: https://pypip.in/wheel/PySide/badge.png
   :target: https://pypi.python.org/pypi/PySide/
   :alt: Wheel Status

.. image:: https://pypip.in/download/PySide/badge.png
   :target: https://pypi.python.org/pypi/PySide/
   :alt: Downloads

.. image:: https://pypip.in/version/PySide/badge.png
   :target: https://pypi.python.org/pypi/PySide/
   :alt: Latest Version

.. image:: https://pypip.in/license/PySide/badge.png
   :target: https://pypi.python.org/pypi/PySide/
   :alt: License

.. contents:: **Table of Contents** 

Introduction
============

PySide is the Python Qt bindings project, providing access the complete Qt 4.8 framework
as well as to generator tools for rapidly generating bindings for any C++ libraries.

The PySide project is developed in the open, with all facilities you'd expect
from any modern OSS project such as all code in a git repository, an open
Bugzilla for reporting bugs, and an open design process. We welcome
any contribution without requiring a transfer of copyright.

The PySide documentation is hosted at `http://pyside.github.io/docs/pyside/
<http://pyside.github.io/docs/pyside/>`_.

Compatibility
=============

PySide requires Python 2.6 or later and Qt 4.6 or better.

.. note::

   Qt 5.x is currently not supported.

Installation
============

Installing prerequisites
------------------------

Install latest ``pip`` distribution: download `get-pip.py
<https://bootstrap.pypa.io/get-pip.py>`_ and run it using
the ``python`` interpreter.

Installing PySide on a Windows System
-------------------------------------

To install PySide on Windows you can choose from the following options:

#. Use pip to install the ``wheel`` binary packages:

   ::

      pip install -U PySide

#. Use setuptools to install the ``egg`` binary packages (deprecated):

   ::

      easy_install -U PySide

.. note::

   Provided binaries are without any other external dependencies.
   All required Qt libraries, development tools and examples are included.


Installing PySide on a Mac OS X System
--------------------------------------

You need to install or build Qt 4.8 first, see the `Qt Project Documentation
<http://qt-project.org/doc/qt-4.8/install-mac.html>`_.

Alternatively you can use `Homebrew <http://brew.sh/>`_ and install Qt with

::

   $ brew install qt

To install PySide on Mac OS X you can choose from the following options:

#. Use pip to install the ``wheel`` binary packages:

   ::

      $ pip install -U PySide


After the installation, the following call must be made manually:

::

   $ pyside_postinstall.py -install


Installing PySide on a Linux System
-----------------------------------

We do not provide binaries for Linux. Please read the build instructions in section
``Building PySide on a Linux System``.


Building PySide on a Windows System
===================================

Windows: Installing prerequisites
---------------------------------

#. Install `Python
   <http://www.python.org/download/>`_.

#. Install `Qt 4.8 libraries for Windows VS 2008 edition
   <http://download.qt-project.org/official_releases/qt/4.8/4.8.5/qt-win-opensource-4.8.5-vs2008.exe>`_
   when building against Python 2.6, 2.7 or 3.2.
   
   Install `Qt 4.8 libraries for Windows VS 2010 edition
   <http://download.qt-project.org/official_releases/qt/4.8/4.8.5/qt-win-opensource-4.8.5-vs2010.exe>`_
   when building against Python 3.3 or 3.4.

#. Install `Cmake
   <http://www.cmake.org/cmake/resources/software.html>`_.

#. Install `Windows SDK v7.0
   <http://www.microsoft.com/en-us/download/details.aspx?id=3138>`_
   when building against Python 2.6, 2.7 or 3.2.
   
   Install `Windows SDK v7.1
   <http://www.microsoft.com/en-us/download/details.aspx?id=8279>`_
   when building against Python 3.3 or 3.4.

#. Install `Git
   <http://git-scm.com/download/win>`_.

#. (Optional) Install `OpenSSL
   <http://slproweb.com/products/Win32OpenSSL.html>`_.

#. Install latest ``pip`` distribution into the Python you
   installed in the first step: download `get-pip.py 
   <https://bootstrap.pypa.io/get-pip.py>`_ and run it using
   the ``python`` interpreter of your Python 2.7 installation using a
   command prompt:

   ::

      c:\> c:\Python27\python get-pip.py

#. Install latest `wheel` distribution:

   ::

      c:\> c:\Python27\Scripts\pip install wheel


Windows: Building PySide distribution
-------------------------------------

#. Download and extract `PySide source distribution
   <https://pypi.python.org/packages/source/P/PySide/PySide-1.2.2.tar.gz>`_

#. Switch to the distribution directory:

   ::

      c:\> cd PySide-1.2.2

#. Build the ``wheel`` binary distribution:

   ::

      c:\> c:\Python27\python.exe setup.py bdist_wheel --qmake=c:\Qt\4.8.5\bin\qmake.exe --openssl=c:\OpenSSL32bit\bin


Windows: Building PySide distribution from a Git repository
-----------------------------------------------------------

#. Clone ``PySide`` setup scripts from git repository:

   ::

      c:\> git clone https://github.com/PySide/pyside-setup.git pyside-setup

#. Switch to the ``pyside-setup`` directory:

   ::

      c:\> cd pyside-setup

#. Build the `wheel` binary distribution:

   ::

      c:\> c:\Python27\python.exe setup.py bdist_wheel --version=1.2.2 --qmake=c:\Qt\4.8.5\bin\qmake.exe --openssl=c:\OpenSSL32bit\bin

#. To build the development version of ``PySide`` distribution, ignore the --version parameter:

   ::

      c:\> c:\Python27\python.exe setup.py bdist_wheel --qmake=c:\Qt\4.8.5\bin\qmake.exe --openssl=c:\OpenSSL32bit\bin


Windows: Installing PySide distribution
---------------------------------------

#. After the successful build, install the distribution with ``pip``:

   ::

      c:\> c:\Python27\Scripts\pip install dist\PySide-1.2.2-cp27-none-win32.whl


Windows: Installing PySide distribution into ``virtual`` Python environment
---------------------------------------------------------------------------

#. Install latest ``virtualenv`` distribution:

   ::

      c:\> c:\Python27\Scripts\pip install virtualenv

#. Use ``virtualenv`` to make a workspace:

   ::

      c:\> c:\Python27\Scripts\virtualenv env

#. Switch to the ``env`` directory:

   ::

      c:\> cd env

#. Install the distribution with ``pip``:

   ::

      c:\> Scripts\pip install ..\dist\PySide-1.2.2-cp27-none-win32.whl


Building PySide on a Mac OS X System
====================================

Mac OS X is a Unix flavor, partially based upon 
`BSD Unix <http://en.wikipedia.org/wiki/Berkeley_Software_Distribution>`_.

The supported Mac OS X versions created by `Apple <http://www.apple.com/>`_ are

- OS X 10.6 *Snow Leopard*
- OS X 10.7 *Lion*
- OS X 10.8 *Mountain Lion*
- OS X 10.9 *Mavericks*

Mac OS X is a proprietary UNIX flavor of BSD Unix and only partially similar to
Linux. Therefore, the usual packages from Linux distributions cannot be used
without modifications.

There are several known package managers which provide support for Mac OS X, namely

- `MacPorts <http://www.macports.org/>`_
- `Fink <http://www.finkproject.org/>`_
- `Homebrew <http://brew.sh/>`_

The main purpose of all of these projects is to provide the missing Linux packages
for Mac OS X.

Throughout this tutorial, we are only using `Homebrew <http://brew.sh/>`_, because
it appears to be the most light-weight package manager available. All installations
are made to /usr/local/(bin|lib|include|shared) by simple symlinks.

But it should be easy to translate these instructions for the other, heavier package managers.


Mac OS X: Installing prerequisites
----------------------------------

#. Install Package Manager:

   ::

      $ ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"

   Follow the on-screen instructions to make adjustions, especially run

   ::

      $ brew doctor

   Also see the `homebrew homepage <http://brew.sh/>`_ for further information

#. Install `Xcode <https://itunes.apple.com/en/app/xcode/id497799835?mt=12>`_ (optional):

   Follow the on-screen instructions. If you selected any extensions to be installed,
   wait for their completion before you proceed.

   .. note::

      If you are using Mavericks, you can also use the Xcode Command Line Tools without actually installing Xcode
      (not tested, see this article: `How to Install Command Line Tools in OS X Mavericks (Without Xcode)
      <http://osxdaily.com/2014/02/12/install-command-line-tools-mac-os-x/>`_).

#. Install the Xcode command Line Tools:

   After Xcode installation has finished, you can open a command shell and issue

   ::

      $ xcode-select --install

   This will open a dialog window with further instructions.
   After the command line tools are installed, you will not need to use Xcode again
   in order to set up PySide.

#. Install build dependencies:

   ::

      $ brew install python cmake qt

   Remark: This installs ``Homebrew`` Python, which is fine for you as a single user.
   If you are considering to build installers for external users, see the section
   ``About PySide Distributions``.

#. Install latest ``pip`` distribution into the Python you
   installed in the first step: download `get-pip.py 
   <https://bootstrap.pypa.io/get-pip.py>`_ and run it using
   the ``python`` interpreter of your Python 2.7 installation using a
   command prompt:

   ::

      $ wget https://bootstrap.pypa.io/get-pip.py
      $ sudo python2.7 get-pip.py

   .. note::

      There are situations with older Python versions, where the above procedure does not work.
      You can then use this last-resort work-around (tested)::

         $ wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py
         $ sudo python2.7 ez_setup.py
         $ sudo easy_install pip
         $ sudo pip install setuptools -U
         $ sudo pip install wheel -U

#. Install latest ``wheel`` distribution:

   ::

      $ sudo pip2.7 install wheel


Mac OS X: About PySide Distribution
-----------------------------------

If you want to build PySide for your own use, the above instructions are ok.

But when you are considering to build PySide for other versions or other users, you need
to be aware of the following caveat:

- Mac OS X has the concept of a ``MACOSX_DEPLOYMENT_TARGET``

- The current deployment targets which work with PySide are 10.6 to 10.9 .

- All binary installers from https://www.python.org are built with the setting

::

   $ export MACOSX_DEPLOYMENT_TARGET=10.6  # Snow Leopard

- The default setting for the deployment target of an extension (like PySide)
  is always inherited from the Python used for building.
  You can set the deployment target higher than that, but not below the
  OS X version that was set during building your Python installation.
  
- Current distributions like Homebrew set the deployment target to the same
  value as the OS version they are built with. (I.E. 10.9 for Mavericks).
  
- Example: A PySide, built on Mavericks, will therefore not run on a Python that was built
  for Mountain Lion.

Recommendation:

- Use Homebrew's simplicity for your own machine. Do not use it for distributing.

- Use one of the `Python.org Distributions <https://www.python.org/downloads/>`_
  or 
  
- Build your own Python, either from a tar archive (
  `Python 2.7 <https://www.python.org/ftp/python/2.7.6/Python-2.7.6.tgz>`_ or
  `Python 3.4 <https://www.python.org/ftp/python/3.4.0/Python-3.4.0.tgz>`_), or from a
  `Mercurial repository <https://docs.python.org/devguide/>`_ with an explicit setting of
  ``MACOSX_DEPLOYMENT_TARGET``.

Mac OS X: Building PySide distribution
--------------------------------------

#. Download ``PySide`` source distribution:

   ::

      $ wget https://pypi.python.org/packages/source/P/PySide/PySide-1.2.2.tar.gz

#. Extract the source distribution:

   ::

      $ tar -xvzf PySide-1.2.2.tar.gz

#. Switch to the distribution directory:

   ::

      $ cd PySide-1.2.2

#. Build the ``wheel`` binary distribution:

   ::

      $ python2.7 setup.py bdist_wheel


Mac OS X: Building PySide distribution from a Git repository
------------------------------------------------------------

#. Clone ``PySide`` setup scripts from git repository:

   ::

      $ git clone https://github.com/PySide/pyside-setup.git pyside-setup

#. Switch to the ``pyside-setup`` directory:

   ::

      $ cd pyside-setup

#. Build ``PySide`` distribution:

   ::

      $ python2.7 setup.py bdist_wheel --version=1.2.2

   ..  commented out, working on this
        #. Optionally you can build standalone version of distribution with embedded Qt libs:
        
           ::
        
              $ python2.7 setup.py bdist_wheel --version=1.2.2 --standalone

#. To build the development version of ``PySide`` distribution, ignore the --version parameter:

   ::

      $ python2.7 setup.py bdist_wheel


Mac OS X: Installing PySide distribution
----------------------------------------

#. After the successful build, install the distribution with ``pip``:

   ::

      $ sudo pip2.7 install dist/PySide-1.2.2-cp27-none-linux-x86_64.whl

#. Run the post-install script to finish the package configuration:
   
   ::

      $ sudo python2.7 pyside_postinstall.py -install


Mac OS X: Installing PySide distribution into ``virtual`` Python environment
----------------------------------------------------------------------------

#. Install latest ``virtualenv`` distribution:

   ::

      $ sudo pip2.7 virtualenv

#. Use ``virtualenv`` to make a workspace:

   ::

      $ virtualenv-2.7 env

#. Activate the virtual Python in the ``env`` directory:

   ::

      $ source env/bin/activate

#. Install the distribution with ``pip``:

   ::

      (env) $ pip install ../dist/PySide-1.2.2-cp27-none-linux-x86_64.whl

#. Run the post-install script to finish the package configuration:

   ::

      (env) $ pyside_postinstall.py -install

#. Leave the virtual environment (optional):

   ::

      (env) $ deactivate
      $ 


Building PySide on a Linux System (Ubuntu 12.04 - 14.04)
========================================================

Linux: Installing prerequisites
-------------------------------

#. Install build dependencies:

   ::

      $ sudo apt-get install build-essential git cmake libqt4-dev libphonon-dev python2.7-dev libxml2-dev libxslt1-dev qtmobility-dev

#. Install latest ``pip`` distribution into the Python you
   installed in the first step: download `get-pip.py 
   <https://bootstrap.pypa.io/get-pip.py>`_ and run it using
   the ``python`` interpreter of your Python 2.7 installation using a
   command prompt:

   ::

      $ wget https://bootstrap.pypa.io/get-pip.py
      $ sudo python2.7 get-pip.py

#. Install latest ``wheel`` distribution:

   ::

      $ sudo pip2.7 install wheel


Linux: Building PySide distribution
-----------------------------------

#. Download ``PySide`` source distribution:

   ::

      $ wget https://pypi.python.org/packages/source/P/PySide/PySide-1.2.2.tar.gz

#. Extract the source distribution:

   ::

      $ tar -xvzf PySide-1.2.2.tar.gz

#. Switch to the distribution directory:

   ::

      $ cd PySide-1.2.2

#. Build the ``wheel`` binary distribution:

   ::

      $ python2.7 setup.py bdist_wheel --qmake=/usr/bin/qmake-qt4

#. Optionally you can build standalone version of distribution with embedded Qt libs:

   ::

      $ python2.7 setup.py bdist_wheel --qmake=/usr/bin/qmake-qt4 --standalone


Linux: Building PySide distribution from a Git repository
---------------------------------------------------------

#. Clone ``PySide`` setup scripts from git repository:

   ::

      $ git clone https://github.com/PySide/pyside-setup.git pyside-setup

#. Switch to the ``pyside-setup`` directory:

   ::

      $ cd pyside-setup

#. Build ``PySide`` distribution:

   ::

      $ python2.7 setup.py bdist_wheel --qmake=/usr/bin/qmake-qt4 --version=1.2.2

#. Optionally you can build standalone version of distribution with embedded Qt libs:

   ::

      $ python2.7 setup.py bdist_wheel --qmake=/usr/bin/qmake-qt4 --version=1.2.2 --standalone

#. To build the development version of ``PySide`` distribution, ignore the --version parameter:

   ::

      $ python2.7 setup.py bdist_wheel --qmake=/usr/bin/qmake-qt4


Linux: Installing PySide distribution
-------------------------------------

#. After the successful build, install the distribution with ``pip``:

   ::

      $ sudo pip2.7 install dist/PySide-1.2.2-cp27-none-linux-x86_64.whl

#. Run the post-install script to finish the package configuration:

   ::

      $ sudo python2.7 pyside_postinstall.py -install


Linux: Installing PySide distribution into ``virtual`` Python environment
-------------------------------------------------------------------------

#. Install latest ``virtualenv`` distribution:

   ::

      $ sudo pip2.7 virtualenv

#. Use ``virtualenv`` to make a workspace:

   ::

      $ virtualenv-2.7 env

#. Switch to the ``env`` directory:

   ::

      $ cd env

#. Install the distribution with ``pip``:

   ::

      $ bin/pip2.7 install ../dist/PySide-1.2.2-cp27-none-linux-x86_64.whl

#. Run the post-install script to finish the package configuration:

   ::

      $ bin/python bin/pyside_postinstall.py -install


PySide Setup Script command line options
========================================

Usage on a Windows System
-------------------------

::

   c:\> c:\Python27\python.exe setup.py [distribution_type] [options]

Usage on a Linux/Mac OS X System
--------------------------------

::

   python2.7 setup.py [distribution_type] [options]


Distribution types
------------------

``bdist_wheel``
    Create a wheel binary distribution.
    This distribution type can be installed with ``pip``.

``bdist_egg``
    Create an egg binary distribution.
    This distribution type can be installed with ``easy_install``.

``bdist_wininst``
    Create a standalone windows installer with embedded Qt libs and development tools.
    This distribution type can be installed with ``easy_install``.

``install``
    Install package to site packages folder.

``develop``
    Install package in ``development mode``, such that it's available on
    ``sys.path``, yet can still be edited directly from its source folder.

``sdist``
    Create a full source distribution with included sources of PySide Setup Scripts,
    PySide, Shiboken, PySide Tools and PySide Examples.
    Can be used to build binary distribution in offline mode.

Options
-------

``--qmake``
    Specify the path to qmake.
    Useful when the qmake is not in path or more than one Qt versions are installed.

``--openssl``
    Specify the path to OpenSSL libs.

``--only-package``
    Skip rebuilding everything and create distribution from prebuilt binaries.
    Before using this option first time, the full distribution build is required.

``--cmake``
    Specify the path to cmake.
    Useful when the cmake is not in path.

``--standalone``
    When enabled, all required Qt libs will be included in PySide distribution.
    This option is allways enabled on Windows.
    On Linux it's disabled by default.

    .. note::

      This option does not work on Mac OS X, yet.

``--version``
    Specify what version of PySide distribution to build.
    This option is available only when the setup scripts are cloned from git repository.

``--list-versions``
    List available versions of PySide distributions.

``--ignore-git``
    Don't pull sources from git repository.

``--make-spec``
    Specify the cmake makefile generator type.
    Available values are ``msvc`` on Windows and ``make`` on Linux/Mac OS X.

``--no-examples``
    Don't include PySide examples in PySide distribution

``--jobs``
    Specify the number of parallel build jobs

``--jom``
    Use `jom <http://qt-project.org/wiki/jom>`_ instead of nmake with msvc

``--build-tests``
    Enable building the tests

Feedback and getting involved
=============================

- Mailing list: http://lists.qt-project.org/mailman/listinfo/pyside
- Issue tracker: https://bugreports.qt-project.org/browse/PYSIDE
- Code Repository: http://qt.gitorious.org/pyside