Skip to content

Latest commit

 

History

History
118 lines (80 loc) · 5.19 KB

BUILD.md

File metadata and controls

118 lines (80 loc) · 5.19 KB

Building Pyside2 bindings for QCustomplot

This project creates Python (v3.6-3.10) bindings for the popular OpenSource QCustomPlot pölotting library for Qt v5.15.2.

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. Building instructions are provided for Linux and Windows 10.

QCustomplot patches

Note, that the original QCustomplot 2.x source code needs a handful of minor patches to compile with the current shiboken2 generator (mainly due to bugs in the generator). Also the bindings generations on Windows 10 needs some minor adjustments. This project contains a patchfile against the original QCustomplot source code and (probably temporarily) the original source files (GPL V3) with the patch applied.

With these files a build can be made directly from this project.

Prerequisites

The basic setup and the library and program sources are described on the following webpages.

Below is a detailled example installation process for Linux and Windows. At some points a bit newer library versions are used compared to the webpages (2019). This will however be updated over time on the original pages. So check there as well.

A good example setup on how to build pyside2 bindings using Shiboken.

Examples

In the folder qcustomplot/qcp_examples are the examples from the QCustomplot webpage translated to Python.

Running the examples

  • Install the matching python wheel from the wheels directory (preferably in a virtual environment).
  • Start the shell script qcustomplot_examples in the qcustomplot_examples_pyside2 folder

Screenshots

See the [Wiki] (https://github.com/SBGit-2019/Pyside-QCP/wiki) for some screenshots.

Building and Installation

Linux

Building on Linux is done with a Dockerimage with a manylinux2 (manylinux_2_17_x86_64) distribution. The Dockerfile to create such an image is provided in the Dockerfile or can be installed from Docker Hub as lyxhub/manylinux2014_x86_64_qt Using for example the build directory io

cd /io
git clone https://github.com/SBGit-2019/Pyside-QCP.git
docker run -v /io:/io lyxhub/manylinux2014_x86_64_qt

This command will automatically create all Linux wheels in the directory wheelhouse.

The github workflow build_linux_wheels.yml performs these steps.

Outside the manylinux image you need to:

  • sudo apt install mesa-common-dev libglu1-mesa-dev build-essential
  • sudo apt install patchelf
  • python -m venv /io/venv/py38
  • source /io/venv/bin/activate
  • Install Qt to /io/Qt (qt-unified-linux-x64-4.3.0-1-online.run)
  • Install pyside2 5.15.2 with shiboken2 and shiboken2 generator (pip install --index-url=http://download.qt.io/official_releases/QtForPython/  --trusted-host download.qt.io  shiboken2 pyside2 shiboken2_generator)
  • Install libclang (>=8.0) libclang-release_110-based-linux-Ubuntu20.04-gcc9.3-x86_64.7z ( https://download.qt.io/development_releases/prebuilt/libclang/)
  • export Qt5_DIR=/io/Qt/5.15.2/gcc_64/lib/cmake
  • export LLVM_INSTALL_DIR=/io/libclang
  • export LD_LIBRARY_PATH=/io/venv/py38/lib/python3.8/site-packages/PySide2/Qt/lib/
  • export MANYLINUX_PYTHON_VERSION=3.8
  • pip wheel --no-deps . -w wheelhouse/

Installation for Windows 10:

Installation of Qt and LLVM environment:

  • Qt 5.15.5 (e.g. MSVC 2017 Kit for Windows)
  • libclang (version >= v8) libclang-release_80-based-windows-vs2017_64.7z and including them into the environment variables
  • CMake (>= 3.13)
  • Installation of build tools:

    • MSVC v142 VS 2019 Build Tools (Release) (from Viual Studio 2019 Installer)

    • Windows 10 SDK (10.0.18362.0)

  • Optionally OpenSSL: openssl-1.0.2j-fips-x86_64.zip
  • Python >= 3.6

Note:

  • For Windows all libraries MUST be created with the same or compatible MSVC versions (this includes, python, pyside2 and Qt)
  • All build should be with the 'Release' version.
  • Very important, you MUST NOT install visual studio / build tools of a too recent version (tested and working is 16.3.8). Using a too high version will introduce bad generator errors in the shiboken runs! Earlier versions can be downloaded from Visual Studio.
  • Environment settings

    • set LLVM_INSTALL_DIR=e:\libclang

    • set Qt5_DIR=E:\Qt\5.15.5\msvc2017_64

  • Create virtual environment

    • python -m venv testenv
  • Activate environment

    • CALL testenv\Scripts\activate.bat
  • Add build packages

    • pip install cmake-build-extension wheel setuptools-U
  • Build using python pip:

    • pip wheel . --no-deps -w wheelhouse/ # Preferred
    • (python setup.py bdist_wheel # as Alternative for more debugging output)

The github workflow build_windows_wheels.yml_ performs all this.