Package: pysrpm
Make RPM files from python releasesImagined as a drop-in replacement for setuptools’sbdist_rpmcommand (being deprecated),
this package does much of the same things thanpyp2rpmdoes, except simpler.
In particular all the parsing of dependencies, package build systems, versions, etc. is done by external libraries,
such aspackagingandpep517.At its simplest:$pysrpmpackage-release.tar.gzor$pysrpmpackage-source-directory/ConfigurationYou can override any options from the command line, seepysrpm --helpfor 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 theflavouroption, e.g.:$pysrpm--flavourfedorapackage-release.tar.gzor$catpysrpm.cfg[pysrpm]flavour=fedora
$pysrpm--configpysrpm.cfgpackage-release.tar.gzTemplatingMost configurability is done through config files however, that can be provided on the command line, or options can be fecthed from the project’ssetup.cfg(under[pysrpm]and[pysrpm.*]), or the project’spyproject.toml(undertool.pysrpm).Any new sections underpysrpmcan become a new flavour, and can inherit from any existing template. E.g. in a project’ssetup.cfg:[pysrpm]flavour=add_post[pysrpm.add_post]# Pick a parent (defaults to base if absent)inherits=base# Add a post scriptpost=rm -rf $$$$RPM_BUILD_ROOTSeepresets/00-base.conffor an explanation of available parameters.Currently there are no other presents than thebasetemplate, but specialisations can be added if needed, for example for platforms that are stuck on older rpm versions.Escaping charactersTo 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 configparserExtendedInterpolationnotation, i.e.${key}or${section:key}, which requires escaping$RPM uses%{macro}for its macros, which requires escaping%setup.cfguses configparserBasicInterpolationnotation, i.e.%(key)sinterpolation, which requires escaping%if using the project’ssetup.cfgpyproject.tomlhas backslahes for double quotes in double-quoted strings, which requires escaping\if using double-quoted strings in tomlHere are a couple of examples:example specfile resulttoml configsetup.cfgpackage version1.2.3a4val = "{version}"val = {version}parent templatevalue from[base]val = "${base:key}"val = ${base:key}shell variable$RPM_BUILD_ROOTval = "$$RPM_BUILD_ROOT"val = $$RPM_BUILD_ROOTRPM macro%define foo 1val = "%%define foo 1"val = %%define foo 1RPM macro%{error:message}val = "%%{{error:message}}"val = %%{{error:message}}"A literal %echo "100%%"val = 'echo "100%%"'val = echo "100%%%%"A literal\printf '%s\n' fooval = "printf '%s\\n' foo"val = printf '%s\n' fooRPM dependency and automatic generationDependencies 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 aspython3Xdist(package)withXthe version. This is controlled by thepython_packagetemplate − seepresets/00-base.conffor more options.Dependencies can also be specified by therequiresandsuggeststemplate entries.