Registry / devops / pbr

pbr

JSON →
library7.0.3pypypi✓ verified 52d ago

PBR (Python Build Reasonableness) is a library developed by OpenStack that injects useful and sensible default behaviors into setuptools-based Python projects. It automates common packaging tasks such as version management based on Git tags, generation of AUTHORS and ChangeLog files from Git history, handling dependencies via requirements files, and automatic long descriptions from READMEs. It aims to simplify the `setup.py` and `setup.cfg` configuration for consistent and repeatable builds. The current version is 7.0.3, with an active release cadence tied to OpenStack development cycles.

devops
pip install pbr
Install & Compatibility
Where this runs
tested against v7.0.3 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.925 runs
installs and imports cleanly · install 0.0s · import 0.716s · 19.7MB
glibc
py 3.103.925 runs
installs and imports cleanly · install 1.9s · import 0.608s · 20MB
21MB installed
● package 21MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

setup
from setuptools import setup
PBR is primarily configured via setup.cfg and pyproject.toml, with a minimal setup.py calling setuptools.setup().
VersionInfo
import pbr.version; version = pbr.version.VersionInfo('my_package').version_string()
from pbr import version
The version information is typically accessed via the pbr.version module's VersionInfo class, not a direct import of 'version' from 'pbr'.

To use PBR, you need a minimal `setup.py` file that calls `setuptools.setup()` and sets `pbr=True`. Most of your project metadata and configuration (e.g., name, dependencies, entry points, versioning strategy) will reside in `setup.cfg` and, for modern Python packaging, in `pyproject.toml`. PBR then processes these configuration files to provide default behaviors and inject values into `setuptools`.

import setuptools # setup.py setuptools.setup( setup_requires=['pbr>=2.0.0'], pbr=True, ) # --- setup.cfg --- # [metadata] # name = my-package # author = Your Name # author-email = your@email.com # summary = A short summary of my package # description-file = README.rst # license = MIT # classifier = # Development Status :: 4 - Beta # Programming Language :: Python # keywords = example, packaging # # [files] # packages = my_package # # [entry_points] # console_scripts = # my-command = my_package.cli:main # # --- pyproject.toml (for modern projects) --- # [build-system] # requires = ["pbr>=7.0.0", "setuptools>=61.0.0", "wheel"] # build-backend = "pbr.build"
pbr --version
Debug
Known issues
breakingPBR 7.0.0 introduced significant breaking changes, deprecating or removing many options from `setup.cfg` sections like `[backwards_compat]`, `[metadata]`, `[files]`, and `[entry_points]`. The `tests_require` option was also deprecated.
fix
Review the official PBR 7.0.0 release notes and documentation for updated configuration options. Migrate deprecated `setup.cfg` options to their new locations or equivalent `pyproject.toml` configurations. For example, `[files]` and `[entry_points]` sections should be moved to `[options]` or `[tools.setuptools]` in `setup.cfg` or `pyproject.toml` respectively.
affects: >=7.0.0
deprecatedPBR has deprecated support for `pyN`-suffixed requirement files in favor of environment markers. Additionally, `testr` and `nose` integration for `setup.py test` has been deprecated.
fix
Update requirement files to use PEP 508 environment markers. For testing, use `testr` or `nose` directly with their native setuptools commands instead of relying on PBR's integration.
affects: >=7.0.0
gotchaPBR heavily relies on Git for versioning, AUTHORS, and ChangeLog generation. If your project is not a Git repository, or if Git is not installed/accessible, these features will not work as expected and may result in default versions (e.g., '0.0.1') or build failures.
fix
Ensure your project is a Git repository and that Git is installed and accessible in the build environment. For production releases, it's recommended to create a Git tag to explicitly define the version.
affects: All versions
gotchaOlder versions of PBR (e.g., 0.11.0, 1.10.0) had known issues causing `ImportError: No module named pbr.pbr_json` or `ModuleNotFoundError: No module named 'testrepository'` during `pip install` of packages that depend on them. This often occurred when `pbr` was not installed or was an outdated version before its dependencies.
fix
Ensure `pbr` is explicitly listed as a `setup_requires` dependency in `setup.py` (e.g., `setup_requires=['pbr>=2.0.0']`) and/or update `pyproject.toml` to specify a sufficiently recent version (`pbr>=7.0.0`). Uninstalling and reinstalling `pbr` or clearing problematic `site-packages` entries might also be necessary.
affects: <=1.10.0 (and possibly others up to ~2.0)
deprecatedPBR 7.0.2 removed remaining uses of `pkg_resources` internally, moving towards `importlib.metadata` and `packaging` for better Python 3 compatibility and modern practices.
fix
While this is an internal change, it's a good practice for downstream projects to also avoid direct `pkg_resources` usage where possible, especially in `setup.py` scripts that PBR interacts with.
affects: All versions, but particularly important for migrations to newer Python versions or build backends.
breakingPBR requires a `setup.cfg` file in the project's root directory for configuration. If `setup.cfg` is missing, PBR will raise a `DistutilsFileError`, leading to a build failure.
fix
Ensure a `setup.cfg` file exists in the project root directory. It should contain at least a `[metadata]` section and a `[pbr]` section with `autodoc_index_modules = True` or `skip_authors = True` and `skip_changelog = True` if not using those features.
affects: All versions
gotchaWhen `pbr=True` is specified in `setup.py`, PBR expects a `setup.cfg` file to exist in the project root for configuration and metadata extraction. Its absence will result in a `distutils.errors.DistutilsFileError`.
fix
Ensure a `setup.cfg` file is present in your project's root directory when `pbr=True` is used in `setup.py`. Even if it's minimal (e.g., an empty file or just a `[metadata]` section), it must exist.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'pbr'
The 'pbr' package is not installed in the Python environment being used, or there is a mismatch between the Python interpreter used for installation and the one running the application.
fix
Ensure pbr is installed in the correct environment using `pip install pbr` or `pip3 install pbr`. If using a virtual environment, activate it before installing.
Exception: Versioning for this project requires either an sdist tarball, or access to an upstream git repository. It's also possible that there is a mismatch between the package name in setup.cfg and the argument given to pbr.version.VersionInfo. Project name <project_name> was given, but was not able to be found.
PBR relies on Git metadata (tags, commits) to determine the package version. This error occurs when installing from a source distribution without Git information (e.g., a downloaded .zip file from GitHub), or if Git tags are not properly set/signed, or if the project name in `setup.cfg` does not match the expected package name.
fix
When developing, clone the repository using `git clone` instead of downloading a zip. Ensure Git tags are correctly formatted and preferably signed (`git tag -s v1.0.0`). For distribution, create a source distribution (`python setup.py sdist`) from a Git-enabled directory before packaging.
AttributeError: 'NoneType' object has no attribute 'get_script_header'
This error typically arises during `setup.py` execution within a pbr-managed project, often due to an outdated or conflicting version of setuptools, or an issue where pbr's internal machinery (like `easy_install`) cannot be properly initialized or accessed.
fix
Upgrade setuptools to the latest version (`pip install --upgrade setuptools`). If the issue persists, ensure all direct and transitive dependencies are compatible and consider running `pip install pbr --upgrade`.
Upgrade
Version history
7.0.3latest on PyPI
Audit
Dependencies
setuptoolsrequiredPBR is a setuptools plugin and builds on its functionality for packaging.
gitrequiredRequired for automatic versioning, AUTHORS, and ChangeLog generation.
wheeloptionalRequired for building wheel distributions, especially with PEP 517/518 build systems.
Agent activity
11 hits · last 30 days
seranking-bot
4
ahrefsbot
3
node
2
Resources