c4urself / bump2version

Version-bump your software with a single command
https://pypi.python.org/pypi/bump2version
MIT License
1.05k stars 134 forks source link

Is it possible to single source the version number with bump2version? #217

Closed srazzell closed 3 years ago

srazzell commented 3 years ago

I would like to have a single location for the version number in our repo. Is this possible with bump2version?

I found this guide, but it didn't have any details if you are using bump2version: https://packaging.python.org/guides/single-sourcing-package-version/

Can setup.py read the version from the bump2version.cfg file? Or can bump2version and setup.py read from another file (like VERSION, setup.cfg, __init__.py, etc.). Ideally, I'd like to not need the bump2version.cfg file and have it read the current version from an existing file.

florisla commented 3 years ago

You can place the [bumpversion] configuration in setup.cfg (as an alternative to .bumpversion.cfg). So you don't need a separate file.

Making setup.py read the version from there is definitely possible, but that's not how bump2version is conceived.

Our goal is: let the version be a simple string in every file where it's used. Avoiding fancy lookup code in setup.py whatsoever.

Bump2version then makes sure that these version numbers are in sync, and bumps them all in one commit.

Currently it not possible to place the version string only in setup.py. This might change in the (far) future; see #185.