From Fedora Project Wiki

< Changes

Revision as of 14:57, 2 March 2018 by Jkurik (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Enabling Python Generators


This change enables the ability to choose to use the Python module dependency generator for packages that provide Python Egg/Wheel metadata.


Current status

Detailed Description

There is RPM dependency generator which is able to automatically add Requires/Provides and other types of dependencies based on egg/wheel metadata. The part which is generating Provides has been used in Fedora since Jun 2016 which means by now all packages which provide egg/wheel metadata have Provides: pythonX.Ydist(xyz) added automatically. With this change proposal we allow people to opt-in for using automatic generation of Requires.

All dependencies which are added are generated out of metadata which means in order to fix them - you need to fix metadata (usually or requirements.txt).

Other distributions (such as Mageia, OpenMandriva, and PLD) have been using this dependency generator for long time already.

In F29 we plan to propose to make generator opt-out.

Benefit to Fedora

  • Packagers do not need to specify runtime dependencies manually anymore
  • No more errors in runtime due to missing dependencies (see example below)

Packager of python-fasteners forgot to add Requires: python3-monotonic >= 0.1 so when anyone does "import fasteners", it fails with traceback:

Traceback (most recent call last):
  File "/builddir/build/BUILD/jenkins-job-builder-2.0.0/tests/yamlparser/", line 42, in test_incorrect_template_dimensions
    reg = registry.ModuleRegistry(config)
  File "/builddir/build/BUILD/jenkins-job-builder-2.0.0/jenkins_jobs/", line 50, in __init__
    Mod = entrypoint.load()
  File "/usr/lib/python3.6/site-packages/pkg_resources/", line 2407, in load
    self.require(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/pkg_resources/", line 2430, in require
    items = working_set.resolve(reqs, env, installer, extras=self.extras)
  File "/usr/lib/python3.6/site-packages/pkg_resources/", line 870, in resolve
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'monotonic>=0.1' distribution was not found and is required by fasteners

With automatic dependency management this should never happen.


  • Proposal owners: Add macros to python-rpm-macros package which enables dependency generator.
  • Other developers: Packagers are advised to replace their hand-crafted list of dependencies on python libraries with simple macros.
  • Release engineering: #7276 (a check of an impact with Release Engineering is needed)
  • Policies and guidelines: Packaging:Python Guidelines need to reference how to turn on the feature (simple variable override). #740.
  • Trademark approval: N/A (not needed for this Change)

Upgrade/compatibility impact

Some new dependencies might be automatically added, but this is rather good because it fixes real bugs.

N/A (not a System Wide Change)

How To Test

  1. Make sure that python-rpm-macros >= 3-25 is installed
  2. Remove all requires for python modules
  3. Add following line to spec: %?python_enable_dependency_generator
  4. Rebuild package

Every dependency mentioned in egg/wheel (e.g. generated by setuptools/distutils from should be automatically added.

User Experience

N/A (not a System Wide Change)


N/A (not a System Wide Change)

Contingency Plan

  • Contingency mechanism: (What to do? Who will do it?) N/A (not a System Wide Change)
  • Contingency deadline: N/A (not a System Wide Change)
  • Blocks release? N/A (not a System Wide Change), Yes/No
  • Blocks product? product


N/A (not a System Wide Change)

Release Notes