Common macros for Python 3 RPMs

In a Python RPM spec file, always use the macros for Python 3 RPMs rather than hardcoding their values.

You can redefine which Python 3 version is used in these macros. To do so, define the python3_pkgversion macro at the top of your spec file. For more information, see A spec file description for an example Python package. If you define the python3_pkgversion macro, the macro values in the following table match that Python 3 version.

Table 1. Macros for Python 3 RPMs
Macro Normal Definition Description

%{python3_pkgversion}

3

The Python version that is used by all other macros. Redefine this macro when you build for a different Python version than the default.

%{python3}

/usr/bin/python3

The Python 3 interpreter.

%{python3_version}

3.12

The major.minor version of the Python 3 interpreter.

%{python3_sitelib}

/usr/lib/python3.12/site-packages

The location where pure-Python modules are installed.

%{python3_sitearch}

/usr/lib64/python3.12/site-packages

The location where modules containing architecture-specific extension modules are installed.

%py3_build

Expands to the setup.py build command with arguments suitable for an RPM package.

%py3_install

Expands to the setup.py install command with arguments suitable for an RPM package.

%{py3_shebang_flags}

sP

The default set of flags for the Python interpreter directives macro, %py3_shebang_fix.

%py3_shebang_fix

Changes Python interpreter directives to #! %{python3}, preserves any existing flags (if found), and adds flags defined in the %{py3_shebang_flags} macro.