IdentifiantMot de passe
Mot de passe oublié ?Je m'inscris ! (gratuit)
5.2 Creating RPM packages

5.2 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 bdist_rpm

or the bdist command with the --format option:

python bdist --formats=rpm

The former allows you to specify RPM-specific options; the latter allows you to easily specify multiple formats in one run. If you need to do both, you can explicitly specify multiple bdist_* commands and their options:

python bdist_rpm --packager="John Doe <>" \
                bdist_wininst --target_version="2.0"

Creating RPM packages is driven by a .spec file, much as using the Distutils 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 Distutils configuration files. Various options and sections in the .spec file are derived from options in the setup script as follows:

RPM .spec file option or section Distutils setup script option
Name name
Summary (in preamble) description
Version version
Vendor author and author_email, or
& maintainer and maintainer_email
Copyright licence
Url url
%description (section) long_description

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:

RPM .spec file option or section bdist_rpm option default value
Release release ``1''
Group group ``Development/Libraries''
Vendor vendor (see above)
Packager packager (none)
Provides provides (none)
Requires requires (none)
Conflicts conflicts (none)
Obsoletes obsoletes (none)
Distribution distribution_name (none)
BuildRequires build_requires (none)
Icon 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 setup configuration file, setup.cfg--see section 3. If you distribute or package many Python module distributions, you might want to put options that apply to all of them in your personal Distutils configuration file (~/.pydistutils.cfg).

There are three steps to building a binary RPM package, all of which are handled automatically by the Distutils:

  1. create a .spec file, which describes the package (analogous to the Distutils setup script; in fact, much of the information in the setup script winds up in the .spec file)
  2. create the source RPM
  3. create the ``binary'' RPM (which may or may not contain binary code, depending on whether your module distribution contains Python extensions)

Normally, RPM bundles the last two steps together; when you use the Distutils, all three steps are typically bundled together.

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.)

See About this document... for information on suggesting changes.