openSUSE:Packaging PyQt and SIP

Jump to: navigation, search


The Packaging PyQt and SIP guide is an overview how to package Python software packages which build on top of the PyQt and SIP frameworks for openSUSE and others using the openSUSE Build Service.

PyQt is a set of Python bindings for The Qt framework. It is using SIP as build backend. SIP is a tool that makes it very easy to create Python bindings for C and C++ libraries.

Build Requirements

Packages building with SIP v5 or SIP v6 need the package python-sip-devel.

BuildRequires:  %{python_module sip-devel}

If your package depends on deprecated SIP4, use the python-sip4-devel package:

BuildRequires:  %{python_module sip4-devel}

The PyQt5 and PyQt6 family have a dedicated package enhancing the SIP build system:

BuildRequires:  %{python_module pyqt-builder}

Runtime Requirements

Packages using SIP v4 historically imported the deprecated Python top level module sip. To ensure binary compatibility, the sip4-devel packages provides a macro specifying the correct version:

Requires:       python-sip(api) = %{python_sip_api_ver}

Newer packages use the Python module PyQt5.sip or PyQt6.sip. They are provided as separate packages and are not pinned to the PyQT ABI.

Requires:    python-qt5-sip

or

Requires:    python-PyQt6-sip

Macros

We use a set of helper macros for building PyQt packages using SIP. These are mainly intended for the core PyQt packages, but could come in handy for other SIP based software as well.

BuildRequires:  python-pyqt-rpm-macros

%define use_sip4 1

Define this for distributions or packages where SIP v4 is required

%define pyqt_build_for_qt6 1

Define this for builds against Qt6. Requires SIP v6.

%sip4_only() and %sip5_only()

Apply the arguments only for SIP v4 or SIP v5 builds in case %use_sip4 is only defined for a subset of builds.

%pyqt<N>_sipdir for <N> in {4, 5, 6}

The path to the directory where the .sip bindings files are located.


Build and Install

The following macros take care of the build dir shuffles for different python flavors.

%pyqt_build()

Build instructions for the package using SIP v4 or SIP v5/v6 as defined by %use_sip4

Options:

  • -c %{quote:--configure-parameters}: Additional parameters for configure.py used by SIP v4 builds.
  • -v: Required for "non-standard" configure.py: call configure.py --verbose instead of standard configure -w.
  • -s %{quote:--sip-build-parameters}: Additional parameters for SIP v5 and v6 sip-build.
  • -m %{quote:make_flags}: Additional parameters for make.

%pyqt_install

Install instructions for the package. For SIP v4, the macro also moves the QScintilla API files and SIP binding files to a flavor specific pathname. PyQt[56] plugins are also renamed to contain the Python flavor which they were built for in order to avoid file conflicts.

%pyqt_install_examples suffix

Install the examples subdirectory into %_docdir/%python_prefix-suffix and adjust the script-interpreter line (shebang) for the correct Python flavor.