Qt for Python/GettingStarted/MacOS: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
m (CristianMaureiraFredes moved page PySide2 MacOS macOS to PySide2 MacOS)
(Updating MacOS section)
Line 1: Line 1:
(page under construction)
(page under construction)
==== Requirements ====                                                               
==== Requirements ====                                                               
* Qt package from https://www.qt.io or a custom build of Qt (preferably '''Qt 5.9''' or '''Qt 5.6''')
* [https://developer.apple.com/xcode/ Xcode]                                                               
* Python from https://www.python.org/downloads/ ('''Python 3.6''' or '''Python 2.7''')
* Python from https://www.python.org/downloads/ ('''Python 3.6''' or '''Python 2.7''')
* '''Xcode''' (macOS)                                                               
* [http://download.qt.io/official_releases/online_installers/qt-unified-linux-x64-online.run Qt 5.6+]
* CMake from https://cmake.org/download/ ('''>= 3.1''')                             
* [http://download.qt.io/development_releases/prebuilt/libclang/ CLANG 3.9] (for 5.9+ branches)
* libclang (required for the 5.9 and dev branches) from [http://download.qt.io/development_releases/prebuilt/libclang/ download.qt.io] ('''>= 3.9''')
* [https://www.openssl.org/source/openssl-1.0.2n.tar.gz OpenSSL 1.0]                
* [https://llvm.org/ LLVM]                                                          
* CMake from https://cmake.org/download/ ('''>= 3.1''')                                                                                       
* virtualenv (optional but recommended)                                               
* virtualenv (optional but recommended)                                               
* Python sphinx package for documentation (optional, pip install sphinx)            
* Python sphinx package for documentation (optional, pip install sphinx)                                    
                                                                                   
=== Building from sources ===
==== setup.py build script ====                                                       
==== Setting up CLANG ====
                                                                                   
* Download [http://download.qt.io/development_releases/prebuilt/libclang/ libclang], e.g.
Note: When doing local builds of Qt on macOS you will need to set either the DYLD_LIBRARY_PATH or DYLD_FRAMEWORK_PATH environment variables.
wget http://download.qt.io/development_releases/prebuilt/libclang/libclang-release_39-mac.7z
                                                                                   
* Extract the files, e.g.
== Development ==                                                                  
7z x libclang-release_39-mac.7z                           
                                                                                   
* Export the installation path to the path you choosed to place the files
Development happens in the 5.9 and dev branches of the [http://code.qt.io/cgit/pyside/pyside-setup.git/ pyside-setup repository].
export CLANG_INSTALL_DIR=$PWD/libclang                                                                                                                                 
                                                                                   
==== Getting PySide2 ====                                                 
* Clonning the official repository
git clone --recursive https://codereview.qt-project.org/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)
cd pyside-setup && git checkout 5.9                                                               
==== Building PySide2 ====                                               
* Check your Qt installation path, to specifically use that version of ''qmake'' to build PySide2:
which qmake
* Check your OpenSSL installation path, to specify it to build PySide2:
which openssl
* 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'' and ''openssl'' path:
python setup.py build --qmake=/path/to/qmake  --openssl=/path/to/openssl --build-tests --ignore-git --jobs=8                                                                         
==== Installing PySide2 ====                                     
* To install on the current directory, just run:
python setup.py install --qmake=/path/to/qmake  --openssl=/path/to/openssl --build-tests --ignore-git --jobs=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/examples/widgets/widgets/tetrix.py                     
== Development ==                                                                                                                                      
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/                                                                                                                           
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 macOS you will need to build the Python interpreter with debug symbols by hand.  
On macOS you will need to build the Python interpreter with debug symbols by hand.                                                                          
                                                                                   
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 macOS, the command                                                                 
On macOS, the command                                                                 
  virtualenv -p /usr/bin/python3-dbg testenv                                           
  virtualenv -p /usr/bin/python3-dbg testenv                                           
creates a Virtual Environment named ''testenv'' for debugging purposes.            
creates a Virtual Environment named ''testenv'' for debugging purposes.                                                                                          
                                                                                   
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

Revision as of 12:27, 29 January 2018

(page under construction)

Requirements

Building from sources

Setting up CLANG

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

Getting PySide2

  • Clonning the official repository
git clone --recursive https://codereview.qt-project.org/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)
cd pyside-setup && git checkout 5.9                                                                 

Building PySide2

  • Check your Qt installation path, to specifically use that version of qmake to build PySide2:
which qmake
  • Check your OpenSSL installation path, to specify it to build PySide2:
which openssl
  • 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 and openssl path:
python setup.py build --qmake=/path/to/qmake  --openssl=/path/to/openssl --build-tests --ignore-git --jobs=8                                                                           

Installing PySide2

  • To install on the current directory, just run:
python setup.py install --qmake=/path/to/qmake  --openssl=/path/to/openssl --build-tests --ignore-git --jobs=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/examples/widgets/widgets/tetrix.py                      

Development

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

  • sources/pyside2-tools: uic, rcc tools
  • examples/

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