Qt for Python/GettingStarted/Windows: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
(Created page with "(Page under development) The Qt library has to be built with the same version of MSVC as Python and PySide2....")
 
No edit summary
 
(37 intermediate revisions by 7 users not shown)
Line 1: Line 1:
(Page under development)
[[Category:Qt for Python]] 


The Qt library has to be built with the same version of MSVC as Python and PySide2. 
== Official documentation ==
                                                                                   
 
==== Requirements ====                                                             
Refer to the [https://doc.qt.io/qtforpython/gettingstarted-windows.html official documentation] to get started on Windows.
* Qt package from https://www.qt.io or a custom build of Qt (preferably '''Qt 5.9''' or '''Qt 5.6''')
 
* Python from https://www.python.org/downloads/ ('''Python 3.6''' or '''Python 2.7''')
== Build considerations ==
* [http://landinghub.visualstudio.com/visual-cpp-build-tools MSVC2015] (for Python 3 on Windows), MSCVC2008 (for Python 2 on Windows)       
Building PySide2 on Windows is a bit special in the sense that some rules have to be followed:
* CMake from https://cmake.org/download/ ('''>= 3.1''')                             
* The MSVC version used to build Python, Qt and PySide2 '''must''' be the same. The only exception are MSVC2015 & MSVC2017 as those compilers produce compatible binaries.
* libclang (required for the 5.9 and dev branches) from [http://download.qt.io/development_releases/prebuilt/libclang/ download.qt.io] ('''>= 3.9''')
** In practice this means that if you use the official Python 3.x package from [https://www.python.org/downloads/] which is built with MSVC 2015, you need to use a Qt package built with MSVC 2015 (or MSVC2017 due to the aforementioned compatibility).
* [https://llvm.org/ LLVM]                                                         
** Using the official Python 2.x package will not be feasible, due to it being built with MSVC 2008, and there being no official prebuilt Qt package for the same MSVC version.
* virtualenv (optional but recommended)                                               
* The build configuration (debug or release) has to be the same for Python, Qt and PySide2.
* Python sphinx package for documentation (optional, pip install sphinx)               
* The above considerations are necessary to ensure that only a '''single''' MSVC runtime library is loaded, otherwise this can cause '''memory corruption, crashes or undefined behavior'''.
                                                                                       
 
== Development ==                                                                      
== Development ==                                                                                                                                                          
                                                                                       
Development happens in the 5.12 and dev branches of the [http://code.qt.io/cgit/pyside/pyside-setup.git/ pyside-setup repository].                                                                                
Development happens in the 5.9 and dev branches of the [http://code.qt.io/cgit/pyside/pyside-setup.git/ pyside-setup repository].
                                                                                       
The top level repository has the following submodules:                                   
The top level repository has the following submodules:                                   
* sources/pyside2-tools: uic, rcc tools   
* sources/pyside2-tools: uic, rcc tools   
* examples/                                             
* sources/pyside2-examples (5.6 only, examples are no longer a submodule in 5.9+)                                                                                                                                 
                                                                                       
Contributions follow the [[Qt_Project_Guidelines|standard process]].                                                                                                
Contributions follow the [[Qt_Project_Guidelines|standard process]].                
                                                                                       
It is helpful to have debug binaries and/or symbols for Python available.               
It is helpful to have debug binaries and/or symbols for Python available.               
On Windows, this is done by choosing ''Customized Installation'' when installing Python and ticking the respective check boxes.
On Windows, this is done by choosing ''Customized Installation'' when installing Python and ticking the respective check boxes.                                                                                
                                                                                       
It is also recommended to use a [http://docs.python-guide.org/en/latest/dev/virtualenvs/ Virtual Environment] for testing to be able to always start from a clean base and avoid issues with write permissions in installations.                                                                                
It is also recommended to use a [http://docs.python-guide.org/en/latest/dev/virtualenvs/ Virtual Environment] for testing to be able to always start from a clean base and avoid issues with write permissions in installations.
                                                                                       
On Windows an installation step may be required:
On Windows an installation step may be required:
  python -m pip install virtualenv                                                       
  python -m pip install virtualenv                                                       
  python -m virtualenv testenv                                                          
  python -m virtualenv testenv                                                                                                                                          
                                                                                       
The Virtual Environment is activated by·                                                 
The Virtual Environment is activated by·                                                 
  CALL testenv\Scripts\activate.bat                                                                                                                                                                                                          
  CALL testenv\Scripts\activate.bat                                                                                                                                                                                                                                                                                            
                                                                                       
Before building the first time, the module [http://www.sphinx-doc.org/en/1.4.9/ Sphinx] should be installed into the virtual environment:·
Before building the first time, the module [http://www.sphinx-doc.org/en/1.4.9/ Sphinx] should be installed into the virtual environment:·
  pip install sphinx
  pip install sphinx
Other useful modules are
pip install numpy PyOpenGL

Latest revision as of 10:54, 2 January 2020


Official documentation

Refer to the official documentation to get started on Windows.

Build considerations

Building PySide2 on Windows is a bit special in the sense that some rules have to be followed:

  • The MSVC version used to build Python, Qt and PySide2 must be the same. The only exception are MSVC2015 & MSVC2017 as those compilers produce compatible binaries.
    • In practice this means that if you use the official Python 3.x package from [1] which is built with MSVC 2015, you need to use a Qt package built with MSVC 2015 (or MSVC2017 due to the aforementioned compatibility).
    • Using the official Python 2.x package will not be feasible, due to it being built with MSVC 2008, and there being no official prebuilt Qt package for the same MSVC version.
  • The build configuration (debug or release) has to be the same for Python, Qt and PySide2.
  • The above considerations are necessary to ensure that only a single MSVC runtime library is loaded, otherwise this can cause memory corruption, crashes or undefined behavior.

Development

Development happens in the 5.12 and dev branches of the pyside-setup repository. The top level repository has the following submodules:

  • sources/pyside2-tools: uic, rcc tools
  • sources/pyside2-examples (5.6 only, examples are no longer a submodule in 5.9+)

Contributions follow the standard process. It is helpful to have debug binaries and/or symbols for Python available. On Windows, this is done by choosing Customized Installation when installing Python and ticking the respective check boxes. It is also recommended to use a Virtual Environment for testing to be able to always start from a clean base and avoid issues with write permissions in installations. On Windows an installation step may be required:

python -m pip install virtualenv                                                       
python -m virtualenv testenv                                                                                                                                           

The Virtual Environment is activated by·

CALL testenv\Scripts\activate.bat                                                                                                                                                                                                                                                                                              

Before building the first time, the module Sphinx should be installed into the virtual environment:·

pip install sphinx

Other useful modules are

pip install numpy PyOpenGL