Skip to main content

Make RPM files from python releases

Imagined as a drop-in replacement for setuptools’s bdist_rpm command (being deprecated), this package does much of the same things than pyp2rpm does, except simpler. In particular all the parsing of dependencies, package build systems, versions, etc. is done by external libraries, such as packaging and pep517.

At its simplest:

$ pysrpm package-release.tar.gz

or

$ pysrpm package-source-directory/

Configuration

You can override any options from the command line, see pysrpm --help for a full list. The system is building the specfile purely by interpolating (possibly inherited) templates. With time, more system-specific templates will be available. You can choose them with the flavour option, e.g.:

$ pysrpm --flavour fedora package-release.tar.gz

or

$ cat pysrpm.cfg
[pysrpm]
flavour = fedora
$ pysrpm --config pysrpm.cfg package-release.tar.gz

Templating

Most configurability is done through config files however, that can be provided on the command line, or options can be fecthed from the project’s setup.cfg (under [pysrpm] and [pysrpm.*]), or the project’s pyproject.toml (under tool.pysrpm).

Any new sections under pysrpm can become a new flavour, and can inherit from any existing template. E.g. in a project’s setup.cfg:

[pysrpm]
flavour = add_post
[pysrpm.add_post]
# Pick a parent (defaults to base if absent)
inherits = base
# Add a post script
post =
	rm -rf $$$$RPM_BUILD_ROOT

See presets/00-base.conf for an explanation of available parameters.

Currently there are no other presents than the base template, but specialisations can be added if needed, for example for platforms that are stuck on older rpm versions.

Escaping characters

To make templates extendable, interpolation is used. This means some characters need to be protected (by doubling them) if they aren’t meant as interpolation.

Up to 3 levels of expansion can happen:

  • templates are evaluating as python, which requires escaping any { and }
  • this project uses configparser ExtendedInterpolation notation, i.e. ${key} or ${section:key}, which requires escaping $
  • RPM uses %{macro} for its macros, which requires escaping %
  • setup.cfg uses configparser BasicInterpolation notation, i.e. %(key)s interpolation, which requires escaping % if using the project’s setup.cfg
  • pyproject.toml has backslahes for double quotes in double-quoted strings, which requires escaping \ if using double-quoted strings in toml

Here are a couple of examples:

example specfile result toml config setup.cfg
package version 1.2.3a4 val = "{version}" val = {version}
parent template value from [base] val = "${base:key}" val = ${base:key}
shell variable $RPM_BUILD_ROOT val = "$$RPM_BUILD_ROOT" val = $$RPM_BUILD_ROOT
RPM macro %define foo 1 val = "%%define foo 1" val = %%define foo 1
RPM macro %{error:message} val = "%%{{error:message}}" val = %%{{error:message}}"
A literal % echo "100%%" val = 'echo "100%%"' val = echo "100%%%%"
A literal \ printf '%s\n' foo val = "printf '%s\\n' foo" val = printf '%s\n' foo

RPM dependency and automatic generation

Dependencies can be extracted automatically from the package metadata, but only for python packages. Expressing complex dependency requirements − especially conditional ones − may be a little shaky currently. Dependencies on other python packages are expressed by default as python3Xdist(package) with X the version. This is controlled by the python_package template − see presets/00-base.conf for more options.

Dependencies can also be specified by the requires and suggests template entries.

Release files for pysrpm 0.0.11

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pysrpm 0.0.11
File Size Uploaded
pysrpm-0.0.11.tar.gz 18.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pysrpm 0.0.11
File Interpreter ABI Platform
pysrpm-0.0.11-py3-none-any.whl Python 3 none any Details

Total release size: 36.8 kB

Release files / pysrpm-0.0.11.tar.gz

Download URL pysrpm-0.0.11.tar.gz
Size 18.4 kB
Tags Source
SHA-256 checksum
How to use checksums
998b819faf4a63f9c728fba89ae81e7622a76511e6caf30bd1c9c68fc6ea643c
BLAKE2b-256 checksum
How to use checksums
cb81a38972960d6ff29dd5745db39a562903b70430a3119fa1c6fcb2aad9eb7f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.12.0 pkginfo/1.5.0.1 requests/2.28.1 requests-toolbelt/0.9.1 tqdm/4.64.1 CPython/3.10.8

Release files / pysrpm-0.0.11-py3-none-any.whl

Download URL pysrpm-0.0.11-py3-none-any.whl
Size 18.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c1f839d39249ddfee39c827315babf2c0b0160db236b27387184728c70f72392
BLAKE2b-256 checksum
How to use checksums
77ed7f7c82b2187a3a73b950294c29907162465e65a51086bf8d732776a5c63c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.12.0 pkginfo/1.5.0.1 requests/2.28.1 requests-toolbelt/0.9.1 tqdm/4.64.1 CPython/3.10.8

Release history Release notifications | RSS feed

This release

0.0.11 This release

2 release files

0.0.10

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page