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.
pip install pbr
The first thing we can optimize is the structure of the setup.py file:
from setuptools import setup setup( setup_requires=['pbr'], pbr=True )
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"
We also add a setup.cfg file which will contain the package metadata:
[metadata] name = easy_pattern author = Joern Boegeholz author-email = firstname.lastname@example.org 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
- Automatically generates version from git tag
- Creates changelog
- YAD – yet another dependency & YACF – yet another config file