Skip to content

Build wheels in CentOS 7

Federico Bruni edited this page Jul 22, 2019 · 1 revision

python-poppler-qt5 is not a pure python module. As it must be compiled for each os and architecture, installing it via pip from source is problematic (even on Linux if you try to pip install ... within a virtualenv, because some required files are available only outside the virtualenv).

That's why we need wheels.

In order to be able to upload wheels to PyPI with the manylinux tag, we must build the wheel using a not too recent linux distro, as we want to create binaries which can be run on as many computers as possible. We cannot use the manylinux2010 container, as it has a too old distro (CentOS 6), which doesn't have Qt5 packages we need for building. So we'll use the CentOS 7 and then customize it.

I won't use Docker but Podman, easier to use as it doesn't need root privileges and doesn't run as a service. Let's download the image and enter the container:

podman pull centos
podman images
podman run --name centos7 -it IMAGE_ID bash

After quitting the container you can start it again with:

podman start -l

Note: from now on all the commands you see are run as root within the CentOS container.

Let's update the system and install some packages we'll need later:

yum upgrade
yum install -y gcc gcc-c++ git make nano wget which

Install the dependencies needed to build python-poppler-qt5:

yum install -y poppler-devel qt5-qtbase-devel

poppler-qt5-devel is not available in CentOS (see below).

Add qmake to your PATH by adding this line in /root/.bashrc:

export PATH=/usr/lib64/qt5/bin/:"${PATH}"

Reload the file and check the PATH is correct:

source /root/.bashrc
echo $PATH
qmake --version

CentOS comes with python2 only by default. In order to install python3 we must enable an extra repository:

yum install -y centos-release-scl

List all the available python3 installations with yum list rh-python3[0-9]. It currently shows 3.4, 3.5 and 3.6. Let's install the latest:

yum install -y rh-python36

python3 is not available yet. We must launch a new bash with this command:

scl enable rh-python36 bash

python -V will now return 3.6.x. More information in this article.

Let's install the PyPI packages we need to build the wheel:

pip install wheel auditwheel PyQt5

There's a problem with current SIP 4.x distributed on PyPI, because it's not shipping some required .py files, see issue 14. Should be fixed from version 5. The workaround is either installing the python3-sip-devel system package (not available in CentOS) or building sip from source:

wget https://sourceforge.net/projects/pyqt/files/sip/sip-4.19.8/sip-4.19.8.tar.gz
tar zxvf sip-4.19.8.tar.gz
cd sip-4.19.8
python configure.py
make
make install

It's now time to build the wheel:

git clone https://github.com/frescobaldi/python-poppler-qt5.git
cd python-poppler-qt5
python setup.py bdist_wheel

We have a problem: poppler-qt5-devel is not packaged in CentOS. There's only poppler-qt, which is a Qt4 wrapper for poppler. That's why we get this error:

# python setup.py bdist_wheel
Package poppler-qt5 was not found in the pkg-config search path.
Perhaps you should add the directory containing `poppler-qt5.pc'
to the PKG_CONFIG_PATH environment variable
No package 'poppler-qt5' found

TO BE COMPLETED

Let's open a python terminal and see if we can import the popplerqt5 module:

python
>>> import popplerqt5
Clone this wiki locally