written by Eric J. Ma on 2023-10-18 | tags: bump2version version control pyproject.toml configuration pattern matching patch release dependencies llamabot pyds-cli problem solving
I recently discovered how to ensure that bump2version only bumps the exact version number and not other pattern-matched strings.
Within a pyproject.toml
file, I had the following configuration:
[project] ... version = "0.0.8" dependencies = [ ... "llamabot>=0.0.80", ... ]
If I wanted to do a patch release, bump2version
would pattern-match on the exact string 0.0.8
and give me the following updated pyproject.toml
file:
[project] ... version = "0.0.9" dependencies = [ ... "llamabot>=0.0.90", ... ]
This is undesirable; really, we should be only updating the string version = "{version_number}"
.
Turns out, the configuration that we need within .bumpversion.cfg
is:
[bumpversion:file:pyproject.toml] search = version = "{current_version}" replace = version = "{new_version}"
With this configuration, we get:
[project] ... version = "0.0.9" dependencies = [ ... "llamabot>=0.0.80", ... ]
Which is correct!
I am going to add this to the pyds-cli
configuration to make sure I never encounter the same problem again.
@article{
ericmjl-2023-how-string,
author = {Eric J. Ma},
title = {How to ensure that bump2version only updates the correct string},
year = {2023},
month = {10},
day = {18},
howpublished = {\url{https://ericmjl.github.io}},
journal = {Eric J. Ma's Blog},
url = {https://ericmjl.github.io/blog/2023/10/18/how-to-ensure-that-bump2version-only-updates-the-correct-string},
}
I send out a newsletter with tips and tools for data scientists. Come check it out at Substack.
If you would like to sponsor the coffee that goes into making my posts, please consider GitHub Sponsors!
Finally, I do free 30-minute GenAI strategy calls for teams that are looking to leverage GenAI for maximum impact. Consider booking a call on Calendly if you're interested!