openstack · OpenDev: Free Software Needs Free Tools

Stephen Finucane 9ec6e72af4 Fix hook ordering race that drops subpackages from wheels

The finalize_distribution_options hook added in 3e8f971 ("Remove need
for setup.cfg, setup.py") has no explicit 'order' attribute, so it
defaults to 0 which is the same priority as setuptools' built-in
'keywords' hook. When the PBR hook happens to run first, it sets
'_pbr_initialized' on the Distribution before the 'keywords' hook fires.
The 'keywords' hook is what triggers 'setupcfg.pbr()', which reads
'setup.cfg' and calls 'smart_find_packages' to expand top-level package
names into the full package tree. Because 'setupcfg.pbr()' sees the
'_pbr_initialized' guard and returns immediately, package discovery
never runs.
The result is that 'dist.packages' falls through to whatever
'[tool.setuptools] packages' lists in pyproject.toml. For projects
that only list the top-level package there (relying on PBR to discover
subpackages), the built wheel silently drops every subpackage.
Fix by setting 'pbr.order = 1' so the hook runs after the
'keywords' hook (order 0). For projects with setup.py + setup.cfg,
'setupcfg.pbr()' gets first shot and sets '_pbr_initialized',
so the finalize hook correctly no-ops. For pyproject.toml-only
projects (no setup.cfg), the keyword handler returns early and the
finalize hook takes over as intended.
Change-Id: I33bc998c47cf9f51309a5350e4601f283da491e2
Assisted-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>

2026-08-13 14:15:28 +01:00

2026-08-10 17:34:25 +00:00

2026-08-13 14:15:28 +01:00

2020-08-06 10:41:29 -07:00

2026-08-10 17:32:43 +00:00

2026-06-26 18:50:03 +00:00

2016-10-19 15:16:29 +05:30

2020-08-11 21:20:17 +00:00

2019-04-19 19:36:17 +00:00

2013-07-11 15:02:12 -04:00

2025-07-03 15:38:45 +01:00

2018-07-18 10:12:17 +01:00

2026-06-26 18:50:03 +00:00

2022-06-13 17:06:43 -04:00

2013-03-10 18:02:43 -04:00

2026-06-25 17:59:07 +00:00

2025-07-17 10:32:05 +01:00

2025-01-28 16:44:44 +00:00

2026-06-26 18:46:51 +00:00

2025-10-24 15:48:40 +01:00

2025-10-28 15:54:47 +00:00

2025-10-24 11:18:18 +01:00

Introduction

Latest Version

Downloads

PBR is a library that injects some useful and sensible default behaviors into your setuptools run. It started off life as the chunks of code that were copied between all of the OpenStack projects. Around the time that OpenStack hit 18 different projects each with at least 3 active branches, it seemed like a good time to make that code into a proper reusable library.

PBR is only mildly configurable. The basic idea is that there's a decent way to run things and if you do, you should reap the rewards, because then it's simple and repeatable. If you want to do things differently, cool! But you've already got the power of Python at your fingertips, so you don't really need PBR.

PBR also aims to maintain a stable base for packaging. While we occasionally deprecate features, we do our best to avoid removing them unless absolutely necessary. This is important since while projects often do a good job of constraining their runtime dependencies they often don't do so for their install time dependencies. By limiting feature removals, we ensure the long tail of older software continues to be installable with recent versions of PBR automatically installed.

PBR builds on top of the work that d2to1 started to provide for declarative configuration. d2to1 is itself an implementation of the ideas behind distutils2. Although distutils2 is long-since abandoned, declarative config is still a great idea and it has since been adopted elsewhere, starting with setuptools' own support for setup.cfg files and extending to the pyproject.toml file format introduced in PEP 517. PBR attempts to support these changes as they are introduced.

Read the original on opendev.org ↗