Python Packaging Guidelines
This document describes the Python module packaging guidelines for openRuyi.
Naming
Packages for Python libraries must use the python- prefix.
Dependencies
Packages should not declare an explicit runtime dependency on python3, because the following dependencies are added automatically in the corresponding cases:
-
When you install files into
%{python3_sitelib}or%{python3_sitearch}, the build system automatically generates a dependency onpython(abi) = 3.X. -
If the package contains executable Python scripts, the build system automatically generates a dependency on
/usr/bin/python3.
BuildRequires: python3-devel
Every package that uses Python and/or installs Python modules must include BuildRequires: pkgconfig(python3) in the spec file, even if the build process does not explicitly invoke Python.
Provides: python3-DISTNAME
Since openRuyi does not split python3 into a separate subpackage, but instead provides it directly from the main package, you should add the following entries to the spec file:
Provides: python3-DISTNAME
%python_provide python3-DISTNAME
RPM Macros for Python Modules
This section lists several commonly used RPM macros for packaging Python modules.
Build Macros
%pyproject_buildrequires
Use this macro in the %generate_buildrequires section of the spec file to generate the package's BuildRequires.
%pyproject_wheel
Use this macro to build the package. In most cases, it is the only macro you need in the %build section. It requires the BuildRequires generated by %pyproject_buildrequires.
%pyproject_install
Use this macro to install packages built by %pyproject_wheel builds. It also requires the BuildRequires generated by %pyproject_buildrequires.
%pyproject_save_files
Use this macro to generate the file list corresponding to the specified importable modules and save it as %{pyproject_files}. The generated list does not include README files. If the package metadata declares license files, the list includes them.
%pyproject_files
This macro expands to the path of the file list written by %pyproject_save_files. Example usage:
%files -n python3-DISTNAME -f %{pyproject_files}