bdist_rpm¶
Creating RPM packages¶
The RPM format is used by many popular Linux distributions, including Red Hat, SuSE, and Mandrake. 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:
python setup.py bdist_rpm
The command allows you to specify RPM-specific options:
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_rpm option |
RPM |
default value |
---|---|---|
|
Distribution |
(none) |
|
Group |
“Development/Libraries” |
|
Release |
“1” |
|
Serial |
“1” |
|
Vendor |
maintainer or author from setup script |
|
Packager |
(none) |
|
Provides |
(none) |
|
Requires |
(none) |
|
Conflicts |
(none) |
|
Obsoletes |
(none) |
|
BuildRequires |
(none) |
|
Icon |
(none) |
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
.spec
file, 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.spec
file).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.)