In Distributing your own package on PyPi I’ve talked about setuptools and twine to upload a package to the Python Package Index.
PBR is a nice little add-on to simplify the setup and the deplyoment of your packages.
PBR stands for Python Build Reasonableness
and it is
A library for managing setuptools packaging needs in a consistent manner.
in their own words.
Table of Contents
Installation
pip install pbr
setup.py
The first thing we can optimize is the structure of the setup.py file:
from setuptools import setup setup( setup_requires=['pbr'], pbr=True )
pyproject.toml
We need to add a pyproject.toml with the following content:
[build-system] requires = ["pbr>=5.7.0", "setuptools>=36.6.0", "wheel"] build-backend = "pbr.build"
setup.cfg
We also add a setup.cfg file which will contain the package metadata:
[metadata]
name = easy_pattern
author = Joern Boegeholz
author-email = boegeholz.joern@gmail.com
summary = A Pseudo-DSL for Python RegEx
description-file = README.md
home-page = https://github.com/jboegeholz/easypattern
license = MIT
classifier =
Development Status :: 4 - Beta
Intended Audience :: Developers
Intended Audience :: Information Technology
License :: OSI Approved :: MIT License
Operating System :: OS Independent
Programming Language :: Python
keywords =
tutorial
[files]
packages =
easy_pattern
classifier is a list of “trove classifiers”
Build a release
Tag the current version:
git tag -am "Version 0.3.0" 0.3.0
build the distribution
python setup.py sdist
under dist you will now find the release easy_pattern-0.3.0.tar.gz
Conclusion
Pros
- Automatically generates version from git tag
- Creates changelog
Cons
- YAD – yet another dependency & YACF – yet another config file
Source Code
https://github.com/jboegeholz/easypattern
Further reading
https://docs.openstack.org/pbr/latest/user/using.html#setup-py






