Convert python source distributions to source RPM (or spec files)
Project description
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 configparserBasicInterpolation
notation, i.e.%(key)s
interpolation, which requires escaping%
if using the project’ssetup.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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pysrpm-0.0.11.tar.gz
.
File metadata
- Download URL: pysrpm-0.0.11.tar.gz
- Upload date:
- Size: 18.4 kB
- Tags: Source
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 998b819faf4a63f9c728fba89ae81e7622a76511e6caf30bd1c9c68fc6ea643c |
|
MD5 | 5ce88738ed932b40b4b7fa32a3af0ad6 |
|
BLAKE2b-256 | cb81a38972960d6ff29dd5745db39a562903b70430a3119fa1c6fcb2aad9eb7f |
File details
Details for the file pysrpm-0.0.11-py3-none-any.whl
.
File metadata
- Download URL: pysrpm-0.0.11-py3-none-any.whl
- Upload date:
- Size: 18.5 kB
- Tags: Python 3
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c1f839d39249ddfee39c827315babf2c0b0160db236b27387184728c70f72392 |
|
MD5 | 2d258d377019a8a86e2a7bdb2b87e463 |
|
BLAKE2b-256 | 77ed7f7c82b2187a3a73b950294c29907162465e65a51086bf8d732776a5c63c |