From Fedora Project Wiki

DRAFT

This is a work in progress

Python 3X applications and modules in EPEL 8

Since Python minor version are not ABI compatible and because EPEL guidelines strongly discourage breaking ABI compatibility, separate Python 3 minor versions in EPEL 8 are packaged as separate python3X (currently python38 or python39) packages to allow for independent versions for each Python version. These guidelines are for building modules for the non-primary version(s) of Python in RHEL 8.

New repos for existing Python modules packaged for Fedora can be requested without the need for a new review with:

fedpkg request-repo --exception python38-foo-epel

All Packages

  • When building locally, you must make sure the proper python3X-rpm-macros package is installed, or you can override the __python3 macro, e.g.:
%global __python3 /usr/bin/python3.8
  • Suggest adding:
%global python3_pkgversion 38

and using that macro where possible.

  • No need for the %python_provide macro. It's deprecated and is noop here.
  • Any files in %{_bindir} must only be of the form %{_bindir}/foo-%{python3_version}
  • %{py3_dist ...} can be kept as is. The macro will determine the appropriate value based on %python3_pkgversion.
  • Must change python3dist to python3.Xdist

Example conversion script

#!/bin/bash

sed -i.orig -e '1,/%changelog/s/python3-/python%{python3_pkgversion}-/g' \
            -e '1,/%changelog/s/python3dist(/python3.8dist(/g' \
            -e '/^Name:/s/python-\(.*\)/python%{python3_pkgversion}-\1-epel/' \
            -e '1i%global python3_pkgversion 38' $1

mv $1 $(basename ${1/python-/python38-} .spec)-epel.spec

Example Spec

%global python3_pkgversion 38
%global srcname example

Name:           python%{python3_pkgversion}-%{srcname}-epel
Version:        1.2.3
Release:        1%{?dist}
Summary:        An example Python module
License:        MIT
URL:            https://pypi.python.org/pypi/%{srcname}
Source0:        %{pypi_source}

BuildArch:      noarch

%description
A python module which provides a convenient example.

%package -n python%{python3_pkgversion}-%{srcname}
Summary:        An example Python module
BuildRequires:  python%{python3_pkgversion}-devel
BuildRequires:  python%{python3_pkgversion}-othermodule
Requires:       python%{python3_pkgversion}-othermodule

%description -n python%{python3_pkgversion}-%{srcname}
A python module which provides a convenient example.

%prep
%autosetup -n %{srcname}-%{version}

%build
%py3_build

%install
%py3_install

%check
%pytest

%files -n python%{python3_pkgverision}-%{srcname}
%license COPYING
%doc README.rst
%{_bindir}/sample-exec-%{python3_version}
%{python3_sitelib}/%{srcname}/

%changelog