Qt for Python/GettingStarted/MacOS: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
(Undo revision 32920 by Croitor Alexandru (talk))
No edit summary
(19 intermediate revisions by 4 users not shown)
Line 1: Line 1:
(page under construction)
[[Category:Qt for Python]] 
==== Requirements ====                                                               
==== Requirements ====                                                               
* [https://developer.apple.com/xcode/ Xcode] 8.2 (macOS 10.11), 8.3.3 (macOS 10.12) or 9 (macOS 10.13)
* [https://developer.apple.com/xcode/ Xcode] 8.2 (macOS 10.11), 8.3.3 (macOS 10.12), 9 (macOS 10.13), 10.1 (macOS 10.14)
* Python from https://www.python.org/downloads/ ('''Python 3.6''' or '''Python 2.7''')
* A Python interpreter (version '''Python 3.6''' or '''Python 2.7'''). One possibility is to to use a package from https://www.python.org/downloads/ , it is also possible to use a Homebrew / MacPorts provided python.
* [http://download.qt.io/official_releases/online_installers/qt-unified-linux-x64-online.run Qt 5.6+]
**  System Python usage is discouraged, because package installation will attempt to write into system folders and might fail in different ways because of system permissions (unless you use a virtualenv)
* [http://download.qt.io/development_releases/prebuilt/libclang/ CLANG 3.9] (for 5.9+ branches)               
* [http://download.qt.io/official_releases/online_installers/qt-unified-mac-x64-online.dmg Qt 5.12]
* [http://download.qt.io/development_releases/prebuilt/libclang/ libclang 6.0+] (for 5.12)               
* CMake from https://cmake.org/download/ ('''>= 3.1''')
* CMake from https://cmake.org/download/ ('''>= 3.1''')
* Git ('''>=2''')                                                                                       
* Git ('''>=2''')                                                                                       
* virtualenv (optional but recommended)                                               
* virtualenv ('''strongly recommended''', but optional)                                               
* Python sphinx package for documentation (optional, pip install sphinx)
* Python sphinx package for documentation (optional, pip install sphinx) - documentation generation currently does not work on maCOS
* '''No''' OpenSSL is required because Qt uses [https://developer.apple.com/documentation/security/secure_transport Secure Transport (Apple)] instead.
* '''No''' OpenSSL is required because Qt uses [https://developer.apple.com/documentation/security/secure_transport Secure Transport (Apple)] instead.


Line 14: Line 15:
==== Setting up CLANG ====
==== Setting up CLANG ====
* Download [http://download.qt.io/development_releases/prebuilt/libclang/ libclang], e.g.
* Download [http://download.qt.io/development_releases/prebuilt/libclang/ libclang], e.g.
  wget http://download.qt.io/development_releases/prebuilt/libclang/libclang-release_39-mac.7z
  wget https://download.qt.io/development_releases/prebuilt/libclang/libclang-release_60-mac-clazy.7z
* Extract the files, e.g.
* Extract the files, e.g.
  7z x libclang-release_39-mac.7z                             
  7z x libclang-release_60-mac-clazy.7z                             
* Export the installation path to the path you choosed to place the files
* Export the installation path to the path you choosed to place the files
  export CLANG_INSTALL_DIR=$PWD/libclang                                                                                                                                   
  export CLANG_INSTALL_DIR=$PWD/libclang                                                                                                                                   
==== Getting PySide2 ====                                                   
==== Getting PySide2 ====                                                   
* Clonning the official repository
* Clone the official repository
  git clone --recursive https://codereview.qt-project.org/pyside/pyside-setup        
  git clone --recursive https://code.qt.io/pyside/pyside-setup
* Checking out the version that we want to build, e.g. 5.9 (Keep in mind you need to use the same version as your Qt installation)
* Check out the version you want to build, e.g. 5.12 (Keep in mind you need to use the same version as your Qt installation)
  cd pyside-setup && git checkout 5.9                                                               
  cd pyside-setup && git checkout 5.12
 
==== Building PySide2 ====                                                 
==== Building PySide2 ====                                                 
* Check your Qt installation path, to specifically use that version of ''qmake'' to build PySide2:
* Check your Qt installation path, to specifically use that version of ''qmake'' to build PySide2:
  which qmake
  which qmake
* Strongly consider using a virtualenv (to avoid permission issues when building and installing)
virtualenv testenv; source testenv/bin/activate
* Check which Python interpreter is being picked up in PATH (system one, homebrew one, MacPorts one, virtualenv one, or some other) because this influences where the PySide2 package will be installed:
which python
* Build can take a few minutes, so it is recommended to use more than one CPU core (e.g. 8). Remember to replace the paths to your current ''qmake'' path:
* Build can take a few minutes, so it is recommended to use more than one CPU core (e.g. 8). Remember to replace the paths to your current ''qmake'' path:
  python setup.py build --qmake=/path/to/qmake --build-tests --ignore-git --jobs=8                                                                          
  python setup.py build --qmake=/path/to/qmake --build-tests --ignore-git --parallel=8
 
==== Installing PySide2 ====                                       
==== Installing PySide2 ====                                       
* To install on the current directory, just run:
* To install the PySide2 package into the currently active Python environment (regular, or virtualenv), just run:
  python setup.py install --qmake=/path/to/qmake --build-tests --ignore-git --jobs=8                                                                                
  python setup.py install --qmake=/path/to/qmake --build-tests --ignore-git --parallel=8
 
==== Test installation ====                                                       
==== Test installation ====                                                       
* You can execute one of the examples to verify the process is properly working.
* You can execute one of the examples to verify the process is properly working.
* Remember to properly set the environment variables for Qt and PySide2.
* Remember to properly set the environment variables for Qt and PySide2.
  python examples/examples/widgets/widgets/tetrix.py                    
  python examples/widgets/widgets/tetrix.py
 
== Development ==                                                                                                                                         
== Development ==                                                                                                                                         
Development happens in the 5.9 and dev branches of the [http://code.qt.io/cgit/pyside/pyside-setup.git/ pyside-setup repository].                                                                               
Development happens in the 5.12 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/                                                                                                                          
* 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.             

Revision as of 13:04, 17 December 2018

Requirements

  • Xcode 8.2 (macOS 10.11), 8.3.3 (macOS 10.12), 9 (macOS 10.13), 10.1 (macOS 10.14)
  • A Python interpreter (version Python 3.6 or Python 2.7). One possibility is to to use a package from https://www.python.org/downloads/ , it is also possible to use a Homebrew / MacPorts provided python.
    • System Python usage is discouraged, because package installation will attempt to write into system folders and might fail in different ways because of system permissions (unless you use a virtualenv)
  • Qt 5.12
  • libclang 6.0+ (for 5.12)
  • CMake from https://cmake.org/download/ (>= 3.1)
  • Git (>=2)
  • virtualenv (strongly recommended, but optional)
  • Python sphinx package for documentation (optional, pip install sphinx) - documentation generation currently does not work on maCOS
  • No OpenSSL is required because Qt uses Secure Transport (Apple) instead.

Building from sources

Setting up CLANG

wget https://download.qt.io/development_releases/prebuilt/libclang/libclang-release_60-mac-clazy.7z
  • Extract the files, e.g.
7z x libclang-release_60-mac-clazy.7z                             
  • Export the installation path to the path you choosed to place the files
export CLANG_INSTALL_DIR=$PWD/libclang                                                                                                                                  

Getting PySide2

  • Clone the official repository
git clone --recursive https://code.qt.io/pyside/pyside-setup
  • Check out the version you want to build, e.g. 5.12 (Keep in mind you need to use the same version as your Qt installation)
cd pyside-setup && git checkout 5.12

Building PySide2

  • Check your Qt installation path, to specifically use that version of qmake to build PySide2:
which qmake
  • Strongly consider using a virtualenv (to avoid permission issues when building and installing)
virtualenv testenv; source testenv/bin/activate
  • Check which Python interpreter is being picked up in PATH (system one, homebrew one, MacPorts one, virtualenv one, or some other) because this influences where the PySide2 package will be installed:
which python
  • Build can take a few minutes, so it is recommended to use more than one CPU core (e.g. 8). Remember to replace the paths to your current qmake path:
python setup.py build --qmake=/path/to/qmake --build-tests --ignore-git --parallel=8

Installing PySide2

  • To install the PySide2 package into the currently active Python environment (regular, or virtualenv), just run:
python setup.py install --qmake=/path/to/qmake --build-tests --ignore-git --parallel=8

Test installation

  • You can execute one of the examples to verify the process is properly working.
  • Remember to properly set the environment variables for Qt and PySide2.
python examples/widgets/widgets/tetrix.py

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
  • 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 macOS you will need to build the Python interpreter with debug symbols by hand. 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 macOS, the command

virtualenv -p /usr/bin/python3-dbg testenv                                          

creates a Virtual Environment named testenv for debugging purposes. Before building the first time, the module Sphinx should be installed into the virtual environment:

pip install sphinx