These macros allow projects that follow the Python packaging specifications to be packaged as RPMs. They work for: * traditional Setuptools-based projects that use the setup.py file, * newer Setuptools-based projects that have a setup.cfg file, * general Python projects that use the PEP 517 pyproject.toml file (which allows using any build system, such as setuptools, flit or poetry). These macros replace %%py3_build and %%py3_install, which only work with setup.py.
Go to file
Petr Viktorin e6c1981103 Clean up try blocks
- minimize code in try blocks
- remove "except Exception" (global error handling to be added later)
2019-07-17 12:29:05 +02:00
tests Build packages on Fedora CI 2019-07-17 12:17:47 +02:00
.gitignore initial import (#1717389) 2019-07-02 12:41:04 +02:00
LICENSE initial import (#1717389) 2019-07-02 12:41:04 +02:00
macros.pyproject Add %pyproject_buildrequires 2019-07-05 11:28:55 +02:00
pyproject_buildrequires.py Clean up try blocks 2019-07-17 12:29:05 +02:00
pyproject-rpm-macros.rpmlintrc Add rpmlint RC file and URL 2019-07-02 13:06:11 +02:00
pyproject-rpm-macros.spec Add %pyproject_buildrequires 2019-07-05 11:28:55 +02:00
README.md Add %pyproject_buildrequires 2019-07-05 11:28:55 +02:00
sources initial import (#1717389) 2019-07-02 12:41:04 +02:00

pyproject RPM macros

This is a provisional implementation of pyproject RPM macros for Fedora 30+.

These macros are useful for packaging Python projects that use the PEP 517 pyproject.toml file, which specifies the package's build dependencies (including the build system, such as setuptools, flit or poetry).

Usage

If your upstream sources include pyproject.toml and you want to use these macros, BuildRequire them:

BuildRequires: pyproject-rpm-macros

This will bring in python3-devel, so you don't need to require python3-devel explicitly.

In order to get automatic build dependencies on Fedora 31+, run %pyproject_buildrequires in the %generate_buildrequires section:

%generate_buildrequires
%pyproject_buildrequires

Only build dependencies according to PEP 517 and PEP 518 will be added. All other build dependencies (such as non-Python libraries or test dependencies) still need to be specified manually.

Then, build a wheel in %build with %pyproject_wheel:

%build
%pyproject_wheel

And install the wheel in %install with %pyproject_install:

%install
%pyproject_install

Limitations

%pyproject_install currently installs all wheels in $PWD. We are working on a more explicit solution.

This macro changes shebang lines of every Python script in %{buildroot}%{_bindir} to #! %{__python3} %{py3_shbang_opt} (#! /usr/bin/python3 -s). We plan to preserve existing Python flags in shebangs, but the work is not yet finished.

The PEPs don't (yet) define a way to specify test dependencies and test runners. That means you still need to handle test dependencies and %check on your own.