This is a static archive of the Python wiki, which was retired in February 2026 due to lack of usage and the resources necessary to serve it — predominately to bots, crawlers, and LLM companies.
Pages are preserved as they were at the time of archival. For current information, please visit python.org.
If a change to this archive is absolutely needed, requests can be made via the infrastructure@python.org mailing list.

This extension of the bdist_rpm command shows how to modify the SPEC file before it is passed to the RPM shell command. It makes the Python version used to call "setup.py" known within the spec file, and also sets another prefix for the install step.

Note that you can use pre_install and post_install in your "setup.cfg" to add customized %pre and %post sections (those settings contain the names of files that are then appended to the SPEC file).

   1 class bdist_rpm_ext(bdist_rpm):
   2     """ Überladung von bdist_rpm, um das SPEC-File etwas zu erweitern.
   3     """
   4 
   5     def _make_spec_file(self):
   6         spec_file = bdist_rpm._make_spec_file(self)
   7         spec_file[0:0] = [
   8             '%define pyversion ' + sys.version[:3],
   9         ]
  10 
  11         install = spec_file.index('%install')
  12         spec_file[install+1] = spec_file[install+1].replace(
  13             'setup.py install',
  14             'setup.py install --prefix /opt/%{name}/%{version}')
  15 
  16         return spec_file

2026-02-14 16:07