Tool to build a RPM package backed by PEP 517

Moving from PEP 610 usage guidelines for Linux distributions.

This thread is intended to be used as a canonical location to point users to when asked about building a RPM package without a setup.py.

Background

Traditionally, Python packages are built as a RPM package by running setup.py. The Python packaging community, however, is steadily moving away from relying on setuptools as a first-order tool, promoting instead to use wheels as the primary exchange artifact format, and PEP 517 as a way to build them. This enables Python projects to use alternative packaging tools while maintaining interoperability of their artifacts, and there is a visible trend for Python projects to not include a setup.py as a result. (See: Which mainstream projects removed setup.py files?) And even for a setuptools-based project, the recommendation is still to build a wheel using setuptools’s PEP 517 hooks, instead of invoking setup.py directly.

Building for RPM

Meanwhile, however, RPM packaging tools are still catching up to this new trend. Fedora’s official guidelines, for example, still instructs using setup.py directly. Developer from Fedora are working on a provisional implementation, pyproject-rpm-macros, to provide tooling to build a PEP 517 project using the pyproject.toml build tool definition, as specified in PEP 518. This provides a solution to build a RPM package from a Python project that does not contain a setup.py, and also a migration path to move off invoking setup.py directly if a Python project has declared itself as using PEP 517, to better ensure the resulting RPM package has the same behaviour as the Python package installed as a wheel.

Note that those are Fedora guidelines, not general RPM guidelines. E.g. openSUSE has their own – possibly also using setup.py behind the macros.

While it is true that Red Hat is my employer, I’d rather say “Developers from Fedora”. We don’t name Python developers based on the company that pays them. We also have contributions from people not employed by Red Hat. Thanks.

1 Like

Thanks @hroncok, I’ll edit the top post accordingly.

Note that pyproject-rpm-macros are late alpha and may still change.
If you want to use them, please subscribe to Fedora’s python-devel list; that’s where we discuss and announce changes.

1 Like