bdist_rpm¶
Creating RPM packages¶
The RPM format is used by many popular Linux distributions, including Red Hat, Fedora, and AlmaLinux. If one of these (or any of the other RPM-based Linux distributions) is your usual environment, creating RPM packages for other users of that same distribution is trivial. Depending on the complexity of your module distribution and differences between Linux distributions, you may also be able to create RPMs that work on different RPM-based distributions.
The usual way to create an RPM of your module distribution is to run the bdist_rpm command:
cxfreeze bdist_rpmpython setup.py bdist_rpm
The command allows you to specify RPM-specific options:
cxfreeze bdist_rpm --packager="John Doe <jdoe@example.org>"python setup.py bdist_rpm --packager="John Doe <jdoe@example.org>"
Creating RPM packages is driven by a .spec file, much as using the
cx_Freeze is driven by the setup script. To make your life easier, the
bdist_rpm command normally creates a .spec file based on the
information you supply in the setup script, on the command line, and in any
cx_Freeze configuration files. Various options and sections in the
.spec file are derived from options in the setup script as follows:
cx_Freeze setup script option |
RPM |
|---|---|
|
Name |
|
Summary (in preamble) |
|
Version |
|
Copyright |
|
Url |
|
%description (section) |
Additionally, there are many options in .spec files that don’t have
corresponding options in the setup script. Most of these are handled through
options to the bdist_rpm command as follows:
- bdist-base¶
base directory for creating built distributions
- rpm-base¶
directory for creating RPM [default: “rpm” under
bdist-base]
- dist-dir¶
directory to put final RPM file in (and .spec file if
spec-onlyis used) [default: “dist”]
- spec-only¶
only regenerate spec file
- distribution-name¶
name of the (Linux) distribution to which this RPM applies (not the name of the module distribution!) [default: none] RPM
.specfile option or section: Distribution
- group¶
package classification [default: “Development/Libraries”] RPM
.specfile option or section: Group
- release¶
RPM release number [default: “1”] RPM
.specfile option or section: Release
- serial¶
RPM serial number [default: “1”] RPM
.specfile option or section: Serial
- vendor¶
RPM “vendor” (eg. “Joe Blow <joe@example.com >”) [default: maintainer or author from setup script] RPM
.specfile option or section: Vendor
- packager¶
RPM packager (eg. “Jane Doe <jane@example.net > [default: same as vendor] RPM
.specfile option or section: Packager
- doc-files¶
list of documentation files (space or comma-separated) RPM
.specfile option or section: %doc
- changelog¶
RPM changelog RPM
.specfile option or section: %changelog
- icon¶
name of icon file [default: none] RPM
.specfile option or section: Icon
- provides¶
capabilities provided by this package [default: none] RPM
.specfile option or section: Provides
- requires¶
capabilities required by this package [default: none] RPM
.specfile option or section: Requires
- conflicts¶
capabilities which conflict with this package [default: none] RPM
.specfile option or section: Conflicts
- build-requires¶
capabilities required to build this package[default: none] RPM
.specfile option or section: BuildRequires
- obsoletes¶
capabilities made obsolete by this package [default: none] RPM
.specfile option or section: Obsoletes
Obviously, supplying even a few of these options on the command line would be
tedious and error-prone, so it’s usually best to put them in the
pyproject.toml configuration file — see section Setup script.
There are three steps to building a binary RPM package, all of which are handled automatically by the cx_Freeze:
create a
.specfile, which describes the package (analogous to the cx_Freeze setup script; in fact, much of the information in the setup script winds up in the.specfile).build an executable or set of executables
create the “binary” RPM
If you wish, you can separate these three steps. You can use the
spec-only option to make bdist_rpm just create the
.spec file and exit; in this case, the .spec file will be
written to the “distribution directory” —normally dist/, but
customizable with the dist-dir option. (Normally, the .spec
file winds up deep in the “build tree,” in a temporary directory created by
bdist_rpm.)