Skip to content

Instantly share code, notes, and snippets.

@fredrikaverpil
Last active December 18, 2020 21:22
Show Gist options
  • Save fredrikaverpil/52dc5b2cdcb17001c7b0c13bdba4d494 to your computer and use it in GitHub Desktop.
Save fredrikaverpil/52dc5b2cdcb17001c7b0c13bdba4d494 to your computer and use it in GitHub Desktop.
PyQt4 & PyQt5
brew install Qt4
brew install openssl
brew install cmake
git clone https://github.com/PySide/pyside-setup.git --recurse-submodules
cd pyside-setup
# The following must be executed in a bash shell
python setup.py bdist_wheel --ignore-git --qmake=/usr/local/Cellar/qt/4.8.7_2/bin/qmake --openssl=/usr/local/Cellar/openssl/1.0.2h_1/bin/openssl --cmake=/usr/local/Cellar/cmake/3.5.2/bin/cmake

macOS

Install PyQt4 and PyQt5 for Python 2.x

If you wish to compile sip yourself:

# cd /sip-4.18
# python configure.py -d /usr/local/lib/python2.7/site-packages/ --arch x86_64

Install Qt5 via brew:

brew install qt5

Install PyQt4 via brew:

# PyQt4 with sip for Python 2.7
brew install pyqt sip  # installs PyQt4 with sip for Python 2.7

Build and install PyQt5 from source:

# PyQt5 for Python 2.7
brew install qt5
cd PyQt5_gpl-5.6
python configure.py -d /usr/local/lib/python2.7/site-packages/ --qmake /usr/local/Cellar/qt5/5.6.0/bin/qmake --sip=/usr/local/bin/sip --sip-incdir=/Users/fredrik/code/source/sip-4.18/siplib
make
sudo make install
sudo make clean

Ubuntu 14.04

Prerequisites

apt-get update
apt-get install wget make g++ libxext-dev python-pip python-dev
apt-get install openssl cmake  # PySide

Compile everything

Compile and install Qt4

wget https://download.qt.io/archive/qt/4.8/4.8.6/qt-everywhere-opensource-src-4.8.6.tar.gz
tar -xvf qt-everywhere-opensource-src-4.8.6.tar.gz
cd qt-everywhere-opensource-src-4.8.6

Configuration options: http://doc.qt.io/qt-4.8/configure-options.html#cross-platform-options

./configure -fast

Qt is now configured for building. Just run 'make'. Once everything is built, you must run 'make install'. Qt will be installed into /usr/local/Trolltech/Qt-4.8.6 To reconfigure, run 'make confclean' and 'configure'.

make
make install

Compile and install SIP

cd ..
wget https://sourceforge.net/projects/pyqt/files/sip/sip-4.18/sip-4.18.tar.gz/download
mv download sip-4.18.tar.gz
tar -xvf sip-4.18.tar.gz
cd sip-4.18
python configure.py
make
make install

Compile and install PyQt4

cd ..
wget https://sourceforge.net/projects/pyqt/files/PyQt4/PyQt-4.10.4/PyQt-x11-gpl-4.10.4.tar.gz/download
mv download PyQt-x11-gpl-4.10.4.tar.gz
tar -xvf PyQt-x11-gpl-4.10.4.tar.gz
cd PyQt-x11-gpl-4.10.4
python configure.py --qmake=/usr/local/Trolltech/Qt-4.8.6/bin/qmake
make
make install
# Installed into cd /usr/lib/python2.7/dist-packages/PyQt4

Compile and install PySide wheel

cd ..
git clone https://github.com/PySide/pyside-setup.git --recurse-submodules
cd pyside-setup
python setup.py bdist_wheel --ignore-git --qmake=/usr/local/Trolltech/Qt-4.8.6/bin/qmake
cd dist
pip install PySide-1.2.4-cp27-none-linux_x86_64.whl

Faster approach

docker run -ti ubuntu:14.04 bash
apt-get update && apt-get install -y wget qt4-qmake libqt4-dev python-dev python-pip
wget https://sourceforge.net/projects/pyqt/files/sip/sip-4.13.3/sip-4.13.3.tar.gz/download
mv download sip-4.13.3.tar.gz
tar -xvf sip-4.13.3.tar.gz
cd sip-4.13.3
make
make install
cd ..
wget ftp://ftp.csc.fi/.m/mirrors1e/ftp.netbsd.org/pub/NetBSD/packages/distfiles/PyQt-x11-gpl-4.8.4.tar.gz
tar -xvf PyQt-x11-gpl-4.8.4.tar.gz
cd PyQt-x11-gpl-4.8.4
python configure.py --qmake=/usr/bin/qmake  # Errors out because of wrong sip version?
# make
# make install
apt-get update
apt-get install wget make g++ libxext-dev
wget https://download.qt.io/archive/qt/4.8/4.8.6/qt-everywhere-opensource-src-4.8.6.tar.gz
tar -xvf qt-everywhere-opensource-src-4.8.6.tar.gz
cd qt-everywhere-opensource-src-4.8.6
# Configuration options: http://doc.qt.io/qt-4.8/configure-options.html#cross-platform-options
./configure -fast
# Qt is now configured for building. Just run 'make'.
# Once everything is built, you must run 'make install'.
# Qt will be installed into /usr/local/Trolltech/Qt-4.8.6
# To reconfigure, run 'make confclean' and 'configure'.
make
make install
apt-get install wget make g++ libxext-dev python-pip python-dev
wget https://sourceforge.net/projects/pyqt/files/sip/sip-4.18/sip-4.18.tar.gz/download
mv download sip-4.18.tar.gz
tar -xvf sip-4.18.tar.gz
cd sip-4.18
python configure.py
make
make install
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment