Package: bumpver
BumpVer: Automatic VersioningWith the CLI commandbumpver, you can search for and update version strings in your project files. It has a flexible pattern syntax to support many version schemes (SemVer,CalVeror otherwise). BumpVer features:Configurable version patternsOptional Git or Mercurial integrationWorks with plaintext, so you can use it with any project.Project/Repo:Code Quality/CI:OverviewSearch and ReplaceName Change PyCalVer -> BumpVerRelated Projects/AlternativesExample UsageTesting aversion_patternUsingMAJOR/MINOR/PATCH(SemVer Parts)Auto Increment Parts:BUILD/INC0/INC1Persistent Parts:BUILD/TAG/PYTAGSearching for Patterns withgrepReferenceCommand LinePart OverviewNormalization CaveatsPattern ExamplesWeek NumberingConfigurationConfiguration SetupDebugging ConfigurationBump It UpVersion StateThe Current VersionDry ModeVCS Parameters (git/mercurial)OverviewSearch and ReplaceWithbumpver, you configure a singleversion_patternwhich is then used toSearch for version strings in your project filesReplace these with an updated/bumped version number.Your configuration might look something like this:# pyproject.toml
[bumpver]
current_version = "1.5.2"
version_pattern = "MAJOR.MINOR.PATCH"

[bumpver.file_patterns]
"setup.py" = [
    'version="{version}",$',
]
"src/mymodule/__init__.py" = [
    '^__version__ = "{version}"$',
]Using this configuration, the output ofbumpver update --drymight look something like this:$ bumpver update --patch --dry
INFO    - Old Version: 1.5.2
INFO    - New Version: 1.5.3--- setup.py+++ setup.py@@ -63,7 +63,7 @@name="mymodule",-    version="1.5.2",+    version="1.5.3",description=description,--- src/mymodule/__init__.py+++ src/mymodule/__init__.py@@ -3,3 +3,3 @@-__version__ = "1.5.2"+__version__ = "1.5.3"Name Change PyCalVer -> BumpVerThis project was originally developed under the name PyCalVer, with the intent to support various CalVer schemes. The package has since been renamed from PyCalVer to BumpVer and the CLI command frompycalvertobumpver.This name change is to reduce confusion that this project is only suitable for Python projects or only for CalVer versioning schemes, neither of which is the case.Related Projects/AlternativesIf you are looking for an alternative, BumpVer was heavily influenced bybumpversion/bump2version. You may also wish to take a look at their list of related projects:bump2version/RELATED.mdExample UsageYou can override the date used bybumpverwith the--date=<isodate>option. Adding this every time would be distracting, so the examples assume the following date:$date--iso2020-10-15Testing aversion_patternTo test aversion_patternand how to increment it, you can usebumpver test:$bumpvertest'v2020.37''vYYYY.WW'NewVersion:v2020.41Aversion_patternconsists of three kinds of characters:Literal text, such asv,., and-, typically used as delimiters.Avalid partsuch asYYYY/WWin the previous example.Square brackets[]to mark an optional segment.The following example uses all three:vYYYY.WW[-TAG]vYYYY.WW[-TAG]
literal text   ^    ^   ^$bumpvertest'v2020.37-beta''vYYYY.WW[-TAG]'NewVersion:v2020.41-beta
PEP440:2020.41b0Here we see the week number changed from 37 to 41. The test command also shows the normalized version pattern according toPEP440. This removes the"v"prefix and shortens the release tag from-betatob0.To remove the release tag, use the option--tag=final.$bumpvertest'v2020.37-beta''vYYYY.WW[-TAG]'--tag=final
NewVersion:v2020.41
PEP440:2020.41UsingMAJOR/MINOR/PATCH(SemVer Parts)A CalVerversion_patternmay not require any flags to determine which part should be incremented, so long as the date has changed.
With SemVer you must always specify one of--major/--minor/--patch.$bumpvertest'1.2.3''MAJOR.MINOR.PATCH[PYTAGNUM]'--major
NewVersion:2.0.0

$bumpvertest'1.2.3''MAJOR.MINOR.PATCH[PYTAGNUM]'--minor
NewVersion:1.3.0

$bumpvertest'1.2.3''MAJOR.MINOR.PATCH[PYTAGNUM]'--patch
NewVersion:1.2.4

$bumpvertest'1.2.3''MAJOR.MINOR.PATCH[PYTAGNUM]'--patch--tag=beta
NewVersion:1.2.4b0

$bumpvertest'1.2.4b0''MAJOR.MINOR.PATCH[PYTAGNUM]'--tag-num
NewVersion:1.2.4b1These non date based parts also make sense for a CalVerversion_pattern, so that you can create multiple releases in the same month. It is common to include e.g. aPATCHpart.$bumpvertest'2020.10.0''YYYY.MM.PATCH'--patch
NewVersion:2020.10.1Without this flag, we would get an error if the date is still in October.$date--iso2020-10-15

$bumpvertest'2020.10.0''YYYY.MM.PATCH'ERROR-Invalidargumentsorpattern,versiondidnotchange.
ERROR-Versiondidnotchange:'2020.10.0'.Invalidversionand/orpattern'YYYY.MM.PATCH'.
INFO-Perhapstry:bumpvertest--patchOnce the date is in November, thePATCHpart will roll over back to zero. This happens whenever parts to the left change (in this case the year and month), just as it does ifMAJORorMINORwere incremented in SemVer.$bumpvertest'2020.10.1''YYYY.MM.PATCH'--date2020-11-01
NewVersion:2020.11.0The rollover to zero will happen even if you use the--patchargument, so that your first release in a month will always have aPATCHset to 0 instead of 1. You can make thePATCHpart optional with[.PATCH]and always supply the--patchflag in your build script. This will cause the part to be omitted when 0 and added when > 0.$bumpvertest'2020.9.1''YYYY.MM[.PATCH]'--patch
NewVersion:2020.10

$bumpvertest'2020.10''YYYY.MM[.PATCH]'--patch
NewVersion:2020.10.1

$bumpvertest'2020.10.1''YYYY.MM[.PATCH]'--patch
NewVersion:2020.10.2With CalVer, the version is based on a calendar date, so you only have to specify such flags if you've already published a release for the current date. Without such a flag, BumpVer will show the error, that the "version did not change".$bumpvertest'v2020.41-beta0''vYYYY.WW[-TAGNUM]'ERROR-Invalidargumentsorpattern,versiondidnotchange.
ERROR-Invalidversion'v2020.41-beta0'and/orpattern'vYYYY.WW[-TAGNUM]'.In this case you have to change one of the parts that are not based on a calendar date.$bumpvertest'v2020.41-beta0''vYYYY.WW[-TAGNUM]'--tag-num
NewVersion:v2020.41-beta1
PEP440:2020.41b1

$bumpvertest'v2020.41-beta0''vYYYY.WW[-TAGNUM]'--tag=final
NewVersion:v2020.41
PEP440:2020.41If a pattern is not applicable to a version string, then you will get an error message.$bumpvertest'2020.37''YYYY.MM'# expected to fail because 37 is not valid for part MMERROR-Incompletematch'2020.3'forversionstring'2020.37'withpattern'YYYY.MM'/'(?P<year_y>[1-9][0-9]{3})\.(?P<month>1[0-2]|[1-9])'ERROR-Invalidversion'2020.37'and/orpattern'YYYY.MM'.This illustrates that each pattern is internally translated to a regular expression which must match the version string. The--verboseflag will show a verbose form of the regular expression, which may help to debug the discrepancy between the pattern and the version.$bumpvertest'v2020.37''YYYY.WW'--verbose# missing "v" prefixINFO-UsingpatternYYYY.WW
INFO-regex=re.compile(r"""(?P<year_y>[1-9][0-9]{3})\.(?P<week_w>5[0-2]|[1-4][0-9]|[0-9])""",flags=re.VERBOSE)ERROR-Invalidversionstring'v2020.37'forpattern...To fix the above, you can either remove the "v" prefix from the version or add it to the pattern.$bumpvertest'v2020.37''vYYYY.WW'# added "v" prefixNewVersion:v2020.41
PEP440:2020.41Auto Increment Parts:INC0/INC1/BUILDThese parts are incremented automatically, and do not use/require a CLI flag:BUILD/INC0/INC1.$bumpvertest'2020.10.1''YYYY.MM.INC0'NewVersion:2020.10.2

$bumpvertest'2020.10.2''YYYY.MM.INC0'--date2020-11-01
NewVersion:2020.11.0You can make the part optional using the[PART]syntax and it will be added/removed as needed.$bumpvertest'2020.10''YYYY.MM[.INC0]'NewVersion:2020.10.1

$bumpvertest'2020.10.1''YYYY.MM[.INC0]'--date2020-11-01
NewVersion:2020.11You can theBUILDpart tomaintain lexical orderingof version numbers. This means that the expressionolder < newerwill always be true, whether you are dealing with integers or strings, whether you are using software that understands how to parse version numbers or not.$bumpvertest'2020.1001''YYYY.BUILD'NewVersion:2020.1002

$bumpvertest'2020.1002''YYYY.BUILD'NewVersion:2020.1003

$bumpvertest'2020.1999''YYYY.BUILD'NewVersion:2020.22000Persistent Parts:BUILD/TAG/PYTAGTheBUILDandTAGparts will not rollover/reset. Instead they are carried forward from one version to the next.$bumpvertest'v2020.1051-beta''vYYYY.BUILD[-TAG]'NewVersion:v2020.1052-beta
PEP440:2020.1052b0

$bumpvertest'v2020.1051-beta''vYYYY.BUILD[-TAG]'--date2021-01-01
NewVersion:v2021.1052-beta
PEP440:2021.1052b0

$bumpvertest'v2020.1051-beta''vYYYY.BUILD[-TAG]'--tag=rc
NewVersion:v2020.1052-rc
PEP440:2020.1052rc0To remove a release tag, mark it as final with--tag=final.$bumpvertest'v2020.1051-beta''vYYYY.BUILD[-TAG]'--tag=final
NewVersion:v2020.1052
PEP440:2020.1052Explicit--set-versionIf the various automatic version incrementing methods don't work for you, you can explicitly do--set-version=<version>.$ bumpver update --dry --set-version="v2020.1060"
INFO    - Old Version: v2020.1051-beta
INFO    - New Version: v2020.1060--- setup.py+++ setup.py@@ -63,7 +63,7 @@name="mymodule",-    version="2020.1051b0",+    version="2020.1060",description=description,--- src/mymodule/__init__.py+++ src/mymodule/__init__.py@@ -3,3 +3,3 @@-__version__ = "v2020.1051-beta"+__version__ = "v2020.1060"Searching for Patterns withgrepYou can usebumpver grepto test and debug entries for your configuration.$bumpvergrep\'__version__ = "YYYY.MM[-TAGNUM]"'\src/module/__init__.py3:4:__version__="2020.9-beta1"5:When searching your project files for version strings, there are some limitations to keep in mind:A version string cannot span multiple lines.Brackets[]can be escaped with backslash:\[\].There is no way to escape a valid part (so you cannot match the literal textYYYY).Note that everything in the pattern is treated as literal text, except for a valid part (in all caps).__version__ = "YYYY.MM[-TAGNUM]"
literal text  ^^^^^^^^^^^^^^^    ^   ^       ^When you write your configuration, you can avoid repeating your version pattern in every search pattern, by using these placeholders{version}{pep440_version}Applied to the above example, you can instead write this:$bumpvergrep\--version-pattern"YYYY.MM[-TAGNUM]"\'__version__ = "{version}"'\src/module/__init__.py3:4:__version__="2020.9-beta1"5:The corresponding configuration would look like this.[bumpver]current_version="2020.9-beta1"version_pattern="YYYY.MM[-TAGNUM]"...[bumpver:file_patterns]src/module/__init__.py__version__="{version}"...If you use a version pattern that is not in the PEP440 normalized form (such as the one above), you can nonetheless match version strings in your project files whicharein thePEP440 normalized form. To do this, you can use the placeholder{pep440_version}instead of the{version}placeholder.$bumpvergrep--version-pattern"YYYY.MM[-TAGNUM]"'version="{pep440_version}"'setup.py
setup.py65:url="https://github.com/org/project",66:version="2020.9b1",67:description=description,The placeholder{version}matches2020.9-beta1, while the placeholder{pep440_version}matches2020.9b1(excluding the "v" prefix, the "-" separator and with a short form release tag "b1" instead of "beta1"). These two placeholders make it possible to mostly use your preferred format for version strings, but use a PEP440 compliant/normalized version string where appropriate.As aneat trickfurther illustration of how the search and replace works, you might wish to keep the year of your copyright headers up to date.$bumpvergrep'Copyright (c) 2018-YYYY'src/mymodule/*.py|head
src/mymodule/__init__.py3:4:# Copyright (c) 2018-2020 Vandelay Industries - All rights reserved.5:

src/mymodule/config.py3:4:# Copyright (c) 2018-2020 Vandelay Industries - All rights reserved.5:The corresponding configuration for this pattern would look like this.[bumpver:file_patterns]...src/mymodule/*.pyCopyright (c) 2018-YYYY Vandelay Industries - All rights reserved.Note that there must be a match for every entry infile_patterns. If there is no match,bumpverwill show an error. This ensures that a pattern is not skipped when your project changes. In this case the side effect is to make sure that every file has a copyright header.$bumpverupdate--dry
ERROR-Nomatchforpattern'Copyright (c) 2018-YYYY Vandelay Industries - All rights reserved.'ERROR-# https://regex101.com/?flavor=python&flags=gmx&regex=Copyright%5B%20%5D%5C%28c%5C%29%0A%5B%20%5D2018%5C-%0A%28%3FP%3Cyear_y%3E%5B1-9%5D%5B0-9%5D%7B3%7D%29%0A%5B%20%5DVandelay%5B%20%5DIndustries%5B%20%5D%5C-%5B%20%5DAll%5B%20%5Drights%5B%20%5Dreserved%5C.regex=re.compile(r"""Copyright[ ]\(c\)[ ]2018\-(?P<year_y>[1-9][0-9]{3})[ ]Vandelay[ ]Industries[ ]\-[ ]All[ ]rights[ ]reserved\.""",flags=re.VERBOSE)ERROR-Nopatternsmatchedforfile'src/mymodule/utils.py'ReferenceCommand Line$ bumpver --help
Usage: bumpver [OPTIONS] COMMAND [ARGS]...

  Automatically update version strings in plaintext files.

Options:
  --version      Show the version and exit.
  -v, --verbose  Control log level. -vv for debug level.
  -h, --help     Show this message and exit.

Commands:
  grep    Search file(s) for a version pattern.
  init    Initialize [bumpver] configuration.
  show    Show current version of your project.
  test    Increment a version number for demo purposes.
  update  Update project files with the incremented version string.$ bumpver update --help
Usage: bumpver update [OPTIONS]

  Update project files with the incremented version string.

Options:
  -d, --dry                       Display diff of changes, don't rewrite
                                  files.
  -f, --fetch / -n, --no-fetch    Sync tags from remote origin.
  -v, --verbose                   Control log level. -vv for debug level.
  --allow-dirty                   Commit even when working directory is has
                                  uncomitted changes. (WARNING: The commit
                                  will still be aborted if there are
                                  uncomitted to files with version strings.
  --ignore-vcs-tag                Ignore VCS tag invariant and update version
                                  anyway.
  --set-version <VERSION>         Set version explicitly.
  --date <ISODATE>                Set explicit date in format YYYY-0M-0D (e.g.
                                  2023-07-10).
  --pin-date                      Leave date components unchanged.
  --pin-increments                Leave the auto-increments INC0 and INC1
                                  unchanged.
  --tag-num                       Increment release tag number (rc1, rc2,
                                  rc3..).
  -t, --tag <NAME>                Override release tag of current_version.
                                  Valid options are: alpha, beta, dev, rc,
                                  post, final.
  -p, --patch                     Increment PATCH component.
  -m, --minor                     Increment MINOR component.
  --major                         Increment MAJOR component.
  -c, --commit-message <TMPL>     Set commit message template.
  --tag-message <TMPL>            Set tag message template.
  --commit / --no-commit          Create a commit with all updated files.
  --tag-commit / --no-tag-commit  Tag the newly created commit.
  --push / --no-push              Push to the default remote.
  --tag-scope [default|global|branch]
                                  Tag scope for the current version.
  --pre-commit-hook <PATH>        Custom script that runs before the commit
                                  step
  --post-commit-hook <PATH>       Custom script that runs after the commit
                                  step is completed
  -h, --help                      Show this message and exit.To help with shell script automation, you can usebumpver show --environ.$bumpvershow-n--environYEAR_Y=2020YEAR_G=...TAG=final
...

$eval$(bumpvershow-n--environ)$echo$TAGfinalPart OverviewWhere possible, these patterns match the conventions fromCalVer.org.partrange / example(s)infoMAJOR0..9, 10..99, 100..bumpver update --majorMINOR0..9, 10..99, 100..bumpver update --minorPATCH0..9, 10..99, 100..bumpver update --patchTAGdev, alpha, beta, rc, post--tag=<tag>PYTAGa, b, rc, post--tag=<tag>NUM0, 1, 2...-r/--tag-numYYYY2019, 2020...Full year, based onstrftime('%Y')YY18, 19..99, 0, 1Short year, based onint(strftime('%y'))MM9, 10, 11, 12Month, based onint(strftime('%m'))DD1, 2, 3..31Day, based onint(strftime('%d'))BUILD1001, 1002 .. 1999, 22000build number (maintains lexical order)INC00, 1, 2...0-based auto incrementing numberINC11, 2...1-based auto incrementing numberPYTAGNUMa0, a1, rc0, ...PYTAG+NUM(no white-space in between)The following are also available, but you should review theNormalization Caveatsbefore you decide to use them.partrange / example(s)commentQ1, 2, 3, 4Quarter0Y18, 19..99, 00, 01Short Yearstrftime('%y')(zero-padded)0M09, 10, 11, 12Monthstrftime('%m')(zero-padded)0D01, 02, 03..31Daystrftime('%d')(zero-padded)JJJ1,2,3..366Day of yearint(strftime('%j'))00J001, 002..366Day of yearstrftime('%j')(zero-padded)WW0, 1, 2..52Week number¹int(strftime('%W'))0W00, 01, 02..52Week number¹strftime('%W')(zero-padded)UU0, 1, 2..52Week number²int(strftime('%U'))0U00, 01, 02..52Week number²strftime('%U')(zero-padded)VV1, 2..53Week number¹³int(strftime('%V'))0V01, 02..53Week number¹³strftime('%V')(zero-padded)GGGG2019, 2020...strftime("%G")ISO 8601 week-based yearGG19, 20...99, 0, 1Short ISO 8601 week-based year0G19, 20...99, 00, 01Zero-padded ISO 8601 week-based year¹ Monday is the first day of the week.² Sunday is the first day of the week.³ ISO 8601 week. Week 1 contains Jan 4th.Normalization CaveatsPackage managers and installation tools will parse your version numbers. When doing so, your version number may go through a normalization process and may not be exactly  as you specified. In the case of Python, the packaging tools (such as pip, twine,setuptools) followPEP440 normalization rules.According to these rules (among other things):Any non-numerical prefix (such asv) is removedLeading zeros in delimited parts are truncatedXX.08->XX.8Tags are converted to a short form (-alpha->a0)For example:Pattern:vYY.0M.0D[-TAG]Version:v20.08.02-betaPEP440 :20.8.2b0I am not aware of any technical reason to use a normalized representation everywhere in your project. However, if you choose a pattern which is always in a normalized form, it will help to avoid confusion. For example, it may not be obvious at a glance, thatv20.08.02-betais the same as20.8.2b0.A further consideration for the choice of yourversion_patternis that it may be processed by tools thatdo notinterpret it as a version number, but treat it just like any other string. It may also be confusing to your users if they a list of version numbers, sorted lexicographically by some tool (e.g. fromgit tags) and versions are not listed in order of their release:$ git tag
18.6b4
18.9b0
19.10b0
19.3b0
20.8b0
20.8b1If you wish to avoid this, you should use a pattern which maintains lexicographical ordering.Pattern ExamplespatternexamplesPEP440lexico.MAJOR.MINOR.PATCH[PYTAGNUM]0.13.10          0.16.10yesnoMAJOR.MINOR[.PATCH[PYTAGNUM]]0.11.15          0.16.18yesnoYYYY.BUILD[PYTAGNUM]2020.1031        2020.1406yesyesYYYY.BUILD[-TAG]2021.1393-beta   2022.1279noyesYYYY.INC0[PYTAGNUM]2020.4b0         2020.16yesnoYYYY0M.PATCH[-TAG]202210.10        202211.13-betanono¹YYYY0M.BUILD[-TAG]202005.1269-beta 202206.1056noyesYYYY.0M2020.01          2021.04noyesYYYY.MM2020.2           2022.2yesnoYYYY.WW2020.33          2020.39yesnoYYYY.MM.PATCH[PYTAGNUM]2022.3.1b0       2022.11.15b0yesnoYYYY.0M.PATCH[PYTAGNUM]2020.03.2        2022.02.4nono¹YYYY.MM.INC02020.7.10        2021.7.7yesnoYYYY.MM.DD2020.8.9         2020.8.20yesnoYYYY.0M.0D2020.11.02       2022.05.03noyesYY.0M.PATCH20.05.12         22.03.5nono²¹ IfPATCH > 9² For the year 2100, the partYYwill produce 0Week NumberingWeek numbering is a bit special, as it depends on your definition of "week":First day of the week is either Monday or Sunday.Range either from 0-52 or 1-53.At the beginning/end of the year, you either have partial weeks or a week that spans multiple years.If you useVV/0V, be aware that you cannot also useYYYY.
Instead useGGGG. This is to avoid an edge case where your version
number would run backwards if it was created around New Year.YYYY WW UU  GGGG VV
2020-12-26 (Sat):  2020 51 51  2020 52
2020-12-27 (Sun):  2020 51 52  2020 52
2020-12-28 (Mon):  2020 52 52  2020 53
2020-12-29 (Tue):  2020 52 52  2020 53
2020-12-30 (Wed):  2020 52 52  2020 53
2020-12-31 (Thu):  2020 52 52  2020 53
2021-01-01 (Fri):  2021 00 00  2020 53
2021-01-02 (Sat):  2021 00 00  2020 53
2021-01-03 (Sun):  2021 00 01  2020 53
2021-01-04 (Mon):  2021 01 01  2021 01ConfigurationConfiguration SetupThe create an initial configuration for project withbumpver init.$pipinstallbumpver
...
Installingcollectedpackages:clicktomllexidbumpver
Successfullyinstalledbumpver-2023.1129

$cdmyproject
~/myproject/

$bumpverinit--dry
Exitingbecauseof'-d/--dry'.Wouldhavewrittentobumpver.toml:[bumpver]current_version="2020.1001a0"version_pattern="YYYY.BUILD[PYTAGNUM]"commit_message="bump version to {new_version}"tag_message="{new_version}"tag_scope="default"pre_commit_hook=""post_commit_hook=""commit=truetag=truepush=true[bumpver.file_patterns]"README.md"=["{version}","{pep440_version}",]"bumpver.toml"=['current_version = "{version}"',]If you already have configuration file in your project (such assetup.cfgorpyproject.toml), thenbumpver initwill update that file instead.~/myproject
$ bumpver init
Updated pyproject.tomlYourpyproject.tomlmay now look something like this:[bumpver]current_version="2019.1001-alpha"version_pattern="YYYY.BUILD[-TAG]"commit_message="bump version to {new_version}"tag_message="{new_version}"tag_scope="default"pre_commit_hook=""post_commit_hook=""commit=truetag=truepush=true[bumpver.file_patterns]"pyproject.toml"=['current_version="{version}"',]"setup.py"=['version="{pep440_version}",',]"README.md"=['{version}','{pep440_version}',]Debugging ConfigurationFor the entries in[bumpver:file_patterns]you can expect two failure modes:False negative: A patternwill notmatch a version number in the associated filewhich it shouldmatch.False positive: A patternwillmatch something itshould not match(less likely).Most obviously you will see such cases when you first attempt to usebumpver update:$bumpverupdate--dry--no-fetch
INFO-OldVersion:2020.1001-alpha
INFO-NewVersion:2020.1002-alpha
ERROR-Nomatchforpattern'version="YYYY.BUILD[PYTAGNUM]",'ERROR-# https://regex101.com/?flavor=python&flags=gmx&regex=version%3D%5C%22%0A%28%3FP%3Cyear_y%3E%5B1-9%5D%5B0-9%5D%7B3%7D%29%0A%5C.%0A%28%3FP%3Cbid%3E%5B1-9%5D%5B0-9%5D%2A%29%0A%28%3F%3A%0A%20%20%20%20%28%3FP%3Cpytag%3Epost%7Crc%7Ca%7Cb%29%0A%20%20%20%20%28%3FP%3Cnum%3E%5B0-9%5D%2B%29%0A%29%3F%0A%5C%22%2Cregex=re.compile(r"""version=\"(?P<year_y>[1-9][0-9]{3})\.(?P<bid>[1-9][0-9]*)(?:(?P<pytag>post|rc|a|b)(?P<num>[0-9]+))?\",""",flags=re.VERBOSE)ERROR-Nopatternsmatchedforfile'setup.py'The internally used regular expression is also shown, which you can use to debug the issue, for example onregex101.com.To debug such issues, you can simplify your pattern and see if you can find a match withbumpver grep.$bumpvergrep'YYYY.BUILD[PYTAGNUM]'setup.py45:name='myproject',46:version='2019.1001b0',47:license='MIT',Here we can see that the pattern for setup.py should be changed to used single quotes instead of doublequotes.As withbumpver update, if your pattern is not found,bumpver grepwill show an error message with the regular expression it uses, to help you debug the issue.$bumpvergrep'YYYY.BUILD[PYTAGNUM]'setup.py
ERROR-Patternnotfound:'YYYY.BUILD[PYTAGNUM]'# https://regex101.com/...An example of a more complex pattern is one where you want to keep a version badge in your README up to date.$bumpvergrep'shields.io/badge/CalVer-YYYY.BUILD[--TAG]-blue'README.md61:62:[img_version]:https://img.shields.io/badge/CalVer-2020.1001--beta-blue63:[url_version]:https://pypi.org/org/package/Bump It UpVersion StateThecurrent_versionis considered global state and must be stored somewhere. Typically this might be in aVERSIONfile, or some other file which is part of the repository. This creates the risk that parallel branches can have different states. If thecurrent_versionwere defined only by files in the local checkout, the same version might be generated on different systems for different commits.To avoid this issue,bumpvertreats Git/Mercurial tags as a second source, depending on thetag_scopeoption, for the most recent version and attempts to change this state in the most atomic way possible. This is why some actions of thebumpvercommand can take a few seconds, as it is synchronizing with the remote repository to get the most recent versions and to push any new version tags as soon as possible.The Current VersionThe current version depends on the configuredtag_scopeand is eithertag_scope =current_version =defaultmax(config.current_version, max(global_vcs_tags))globalmax(global_vcs_tags)branchmax(branch_vcs_tags)Before any tags have been createdbumpverwill always default to the value ofcurrent_versioninbumpver.toml/setup.cfg/pyproject.toml.Only Git/Mercurial tags which matches theversion_patternfrom your config will be considered and sorted usingpkg_resources.parse_version.As part of doingbumpver updateandbumpver show, your local tags are updated usinggit fetch --tags/hg pull.$bumpvershow-vv2020-10-18T20:20:58.062DEBUGbumpver.cli-Loggingconfigured.2020-10-18T20:20:58.065DEBUGbumpver.config-ConfigParsed:Config(...2020-10-18T20:20:58.067DEBUGbumpver.vcs-vcsfound:git2020-10-18T20:20:58.067INFObumpver.vcs-fetchingtagsfromremote(toturnoffuse:-n/--no-fetch)2020-10-18T20:20:58.068DEBUGbumpver.vcs-gitfetch2020-10-18T20:21:00.886DEBUGbumpver.vcs-gittag--list2020-10-18T20:21:00.890INFObumpver.cli-Latestversionfromgittag:2020.1019
CurrentVersion:2020.1019Here we see that:Git had a newer version than we had locally (2020.1019vs2020.1018).It took 2 seconds to fetch the tags from the remote repository.The approach of fetching tags before the version is bumped/incremented, helps to reduce the risk that the newest tag is not known locally. This means that it less likely for the same version to be generated by different systems for different commits. This would result in an ambiguous version tag, which may not be the end of the world, but is better to avoid. Typically this might happen if you have a build system where multiple builds are triggered at the same time.For a small project (with only one maintainer and no automated packaging) this is a non-issue and you can always use-n/--no-fetchto skip fetching the tags.Dry ModeOnce you have a valid configuration, you can usebumpver update --dryto see  the changes it would make (and leave your project files untouched).$ bumpver update --dry --no-fetch
INFO    - Old Version: 2019.1001-beta
INFO    - New Version: 2019.1002-beta--- README.md+++ README.md@@ -11,7 +11,7 @@[![Supported Python Versions][pyversions_img]][pyversions_ref]-[![Version 2019.1001-beta][version_img]][version_ref]+[![Version 2019.1002-beta][version_img]][version_ref][![PyPI Releases][pypi_img]][pypi_ref]--- src/mymodule_v1/__init__.py+++ src/mymodule_v1/__init__.py@@ -1,1 +1,1 @@-__version__ = "2019.1001-beta"+__version__ = "2019.1002-beta"--- src/mymodule_v2/__init__.py+++ src/mymodule_v2/__init__.py@@ -1,1 +1,1 @@-__version__ = "2019.1001-beta"+__version__ = "2019.1002-beta"--- setup.py+++ setup.py@@ -44,7 +44,7 @@name="myproject",-    version="2019.1001b0",+    version="2019.1002b0",license="MIT",VCS Parameters (git/mercurial)The individual steps performed bybumpver update:FetchVCS tags from origin.Get most recent version.Generate the updated version string.Check that you have no local changes that are uncommitted.Replace version strings in all files configured infile_patterns.Run pre-commit hook.Committhe updated files.Run post-commit hook.Tagthe new commit.Pushthe new commit and tag.The configuration for these steps can be done with the following parameters:ParameterTypeDescriptiontag_scopestringScope for thecurrent_versionin step 2.commit_messagestring¹Template for commit message in step 6.tag_messagestring¹Template for tag message in step 9.pre_commit_hookstring²Path to the pre-commit script.commitbooleanCreate a commit with all updated files.post_commit_hookstring²Path to the post-commit script.tagboolean²Tag the newly created commit.pushboolean²Push to the default remote.¹ Available template placeholders:{new_version},{old_version},{new_version_pep440},{old_version_pep440}² Requirescommit = TrueAn example configuration might look like this:[bumpver]...commit_message="bump version to {new_version}"tag_message="{new_version}"tag_scope="default"pre_commit_hook="scripts/run_checks.sh"post_commit_hook="scripts/update_changelog.sh"commit=Truetag=Truepush=TrueIf everything looks OK, you can dobumpver update.$bumpverupdate--verbose
INFO-fetchingtagsfromremote(toturnoffuse:-n/--no-fetch)INFO-OldVersion:2020.1005
INFO-NewVersion:2020.1006
INFO-Runpre-commithook:scripts/run_checks.sh
INFO-...
INFO-gitcommit--message'bump version to 2020.1006'INFO-Runpost-commithook:scripts/update_changelog.sh
INFO-...
INFO-gittag--annotate2020.1006--message2020.1006
INFO-gitpushorigin--follow-tags2020.1006HEADYou can also override the config values by passing these command line flags tobumpver update:FlagOverride config--commitcommit = True--no-commitcommit = False,tag = False,push = False--tag-committag = True--no-tag-committag = False--pushpush = True--no-pushpush = FalseCustom Commit MessageIn addition to thecommit_messageconfiguration, you can also override the string used as the the commit message template with the-c/--commit-message=<TMPL>parameter:$bumpverupdate--tagfinal--commit-message'bump version {old_version} -> {new_version} [ci-publish]'--verbose
INFO-OldVersion:2021.1005b0
INFO-NewVersion:2021.1006
INFO-gitcommit--message'bump version 2020.1005b0 -> 2021.1006 [ci-publish]'INFO-gittag--annotate2020.1006--message'2020.1006'INFO-gitpushorigin--follow-tags2020.1006HEADAs this is a manual operation (rather than a long lived configuration option), you can use the placeholdersOLDandNEWfor convenience, instead of the more verbose{old_version}and{new_version}.$bumpverupdate-f-tfinal-c'[final-version] OLD -> NEW'...
INFO-OldVersion:1.2.0b2
INFO-NewVersion:1.2.0
INFO-gitcommit--message'[final-version] 1.2.0b2 -> 1.2.0'...Custom Tag MessageSimilarly to--commit-messageyou can provide a tag message template by using the--tag-message=<TMPL>parameter or thetag_messageconfiguration:$bumpverupdate-f-tfinal--tag-message'release NEW'INFO-OldVersion:1.2.0b2
INFO-NewVersion:1.2.0
...
INFO-gittag--annotate1.2.0--message'release 1.2.0'...You can use the same placeholders as in the--commit-messagetemplate.If an empty tag message is provided, bumpver uses a lightweight tag in Git. Otherwise, it utilizes an annotated Git tag. You can read more about Git tagginghere.$bumpverupdate-f-tfinal--tag-message''INFO-OldVersion:1.2.0b2
INFO-NewVersion:1.2.0
...
INFO-gittag1.2.0
...Pre/Post-Commit HooksBumpverallows you to run custom scriptsbeforeandafterthe commit step using the--pre-commit-hook=<PATH>and--post-commit-hook=<PATH>parameter, respectively their configuration counterpartspre_commit_hookandpost_commit_hook. Both options requirecommit=Trueto be set and the<PATH>must be either absolute or relative to the working dir.If a script fails (exits with areturn_code!=0)bumpveraborts and all subsequent steps won't be executed, e.g.commit,tagandpush.For your convenience there are two environment variables available which can be used in the scripts:BUMPVER_OLD_VERSIONandBUMPVER_NEW_VERSION.Example:#!/usr/bin/env python# File path: scripts/print_new_version.pyfromosimportenvironprint("The new version is "+environ.get('BUMPVER_NEW_VERSION',''))$ bumpver update --post-commit-hook scripts/print_new_version.py
INFO    - fetching tags from remote (to turn off use: -n / --no-fetch)
INFO    - Old Version: 2023.1001-alpha
INFO    - New Version: 2023.1002-alpha
INFO    - git commit --message 'bump version 2023.1001-alpha -> 2023.1002-alpha'
INFO    - Run post-commit hook: scripts/print_new_version.py
INFO    - 	The new version is 2023.1002-alpha
INFO    - git tag --annotate 2023.1002-alpha --message '2023.1002-alpha'
INFO    - git push origin --follow-tags 2023.1002-alpha HEADMake sure your script is executable, otherwise you might be greeted with:$ bumpver update --post-commit-hook scripts/print_new_version.py
...
INFO    - Run post-commit hook: scripts/print_new_version.py
ERROR   - 	[Errno 13] Permission denied: 'scripts/print_new_version.py'
ERROR   - Script exited with an error. StoppingContributorsNamerolesinceuntilManuel Barkhau (mbarkhau@gmail.com)author/maintainer2018-09-Changelog forhttps://github.com/mbarkhau/bumpverBumpVer 2023.1129Fix#224: Add--environso it emits0values. Depricate-e/--env.Add#223: Add support for.bumpver.tomlThank youAdriannefor this issue report.
Thank youXavier Franciscofor your contribution.BumpVer 2023.1127Add#222: Add part HEXHASH.Thank youAtwamfor your contribution.BumpVer 2023.1126Add#214: Support for pre/post commit hooks.Add#219: Fix pathlib issues on Windows.Fix#201: Better error message for SemVer corner case.Update#215: Better error message for greedy pattern matching.Update#216: Use .toml format in REAMDE examples.Thank youSven Lohrmannfor your contribution.
Thank youMaikel Punieyour issue report.
Thank you for your help in debugging Windows issues:Søren FurboMichal VašutJustin CookseyyqbearBumpVer 2023.1125Add#188: Add--tag-scope=<SCOPE>to support separate versioning for branches.Add#185: Add--tag-message=<TMPL>parameter andtag_messageconfiguration option.Fix#209: Make--no-tag-commitommit--follow-tags.Thank youSven Lohrmannfor your contributions.
Thank youtardis4500for the issue report.BumpVer 2023.1124Fix#208: Fix handling of versions with PEP440 epoch.Thank youWen Kokkefor the issue report.BumpVer 2023.1122Fix#207: Add --ignore-vcs-tag to support bumping older versionsThank youJusong Yufor your contribution.BumpVer 2023.1121Fix#200: Fix compatability with packaging 23.0.Fix#203: Add dev to the list of valid release tagsThank youSharon Yogevfor your contribution.BumpVer 2022.1120Fix#196: Add--pin-increments.Thank youMarkus Holtermannfor
this contribution.BumpVer 2022.1119Fix#190: Allow multiple patterns on the same lineFix#182: Use quotes for vcs commandsBumpVer 2022.1118Fix#181: Enable use of^$charachters to restrict
matching to beginning and end of line.AddGITHASHtoversion_pattern(@mpasternak)BumpVer 2022.1116Fix:incorrect version comparison when updating from vcs tag.When comparing the updated version to the latest vcs tag,
an insufficient string comparison was used instead of
comparing the parsed versions.Thank you to Timo Ludwig @timoludwig for this contribution.BumpVer 2022.1115Fix:use default date values.When parsing the current version, if it doesn't specify anyt
date part, (such as is the case for e.g. SemVer), then use the
current date to populate default parts.This enables updating YYYY patterns in copyright headers even
for projects that don't use a CalVer pattern.Thank youBenjamin Depardon (@bdepardo)for
finding and reporting this issue.BumpVer 2021.1114Add:flags to override vcs optionsforbumpver updateThank you to Timo Ludwig @timoludwig for this contribution.BumpVer 2021.1113Add:--commit-messageargumentforbumpver updateBumpVer 2021.1112Fix: Build from source on windows.BumpVer 2021.1110Fixgithub#157: Improve error messages.Fixgithub#158: ClarifyPYTAGNUM"part"Thank you to Julien Palard @JulienPalard for testing and feedback.BumpVer 2021.1109Add-e/--envoption to support shell script automation.Fixgithub#151: invalid increment ofTAGNUMwhenTAG=finalis set.Thank you to Dave Wapstra @dwapstra for your contributions.BumpVer 2020.1108Don't match empty patterns (possibly causing a whole file to be rewritten if braces[]are not escaped).BumpVer 2020.1107Non-Beta release (no significant code changes).BumpVer 2020.1105-betaFixgitlab#15: Fix config parsing corner case.Fixgitlab#16: Fix rollover handling for tag/pytag.BumpVer 2020.1104-betaFixgitlab#13: Add--set-version=<VERSION>to explicitly set version.Fixgitlab#14: Parsetool.bumpverwhen using pyproject.toml as per PEP 518.BumpVer 2020.1100-betaRename package and module from PyCalVer to BumpVer. This name change is due to confusion that this project is either Python specific, or only suitible for CalVer versioning schemes, neither of which is the case.This release includes a new syntax for patterns.version_pattern = "vYYYY0M.BUILD[-RELEASE]"             # new style
version_pattern = "v{year}{month}{build}{release}"      # old style

version_pattern = "MAJOR.MINOR.PATCH"                   # new style semver
version_pattern = "{MAJOR}.{MINOR}.{PATCH}"             # old style semverThe main reasons for this switch were:To enable optional parts using braces[PART].To align the syntax with the conventions used on CalVer.orgThe previous syntax will continue to be supported, but all documentation has been updated to primarily reference new style patterns.Switch main repo from gitlab to github.Newgitlab#7: New style pattern syntax.Better support for week numbers.Better support for optional parts.New:BUILDpart now starts at1000instead of0001to avoid truncation of leading zeros.New: AddINC0(0-based) andINC1(1-based) parts that do auto increment and rollover.New:MAJOR/MINOR/PATCH/INCwill roll over when a date part changes to their left.Newgitlab#2: Addedgrepsub-command to help with debugging of patterns.Newgitlab#10:--pin-dateto keep date parts unchanged, and only increment non-date parts.New: Added--date=<iso-date>parameter to set explicit date (instead of current date).New: Added--release-numto increment thealphaN/betaN/a0/b0/etc. release numberNew: Added better error messages to debug regular expressions.Newgitlab#9: Make commit message configurable.Fixgitlab#12: Error with sorting non-lexical version tags (e.g. SemVer).Fixgitlab#11: Show regexp when--verboseis used.Fixgitlab#8:bumpver updatewill now also push HEAD (previously only the tag itself was pushed).Fix: Disallow--release=dev. The semantics of adevreleases are different than for other release tags and further development would be required to support them correctly.Fix: Entries infile_patternswere ignored if there were multiple entries for the same file.This release no longer includes thepycalver.lexidmodule, which has been moved into its own package:pypi.org/project/lexid/.Many thanks to contributors of this release: @LucidOne, @khanguslee, @chaudumPyCalVer v202010.1042Add deprication warning to README.mdPyCalVer v201907.0036Fix: Don't use git/hg command ifcommit=Falseis configured (thanks @valentin87)PyCalVer v201907.0035Fixgitlab#6: Add parts{month_short},{dom_short},{doy_short}.Fixgitlab#5: Better warning when using bump with SemVer (one of --major/--minor/--patch is required)Fixgitlab#4: Make {release} part optional, so that versions generated by --release=final are parsed.PyCalVer v201903.0030Fix: Use pattern from config instead of hard-coded {pycalver} pattern.Fix: Better error messages for git/hg issues.Add: Implicit default pattern for config file.PyCalVer v201903.0028Fix: Add warnings when configured files are not under version control.Add: Colored output for bump --dryPyCalVer v201902.0027Fix: Allow --release=postFix: Better error reporting for bad patternsFix: Regex escaping issue with "?"PyCalVer v201902.0024Added: Support for globs in file patterns.Fixed: Better error reporting for invalid config.PyCalVer v201902.0020Added: Support for many more custom version patterns.PyCalVer v201812.0018Fixed: Better handling of pattern replacements with "-final" releases.PyCalVer v201812.0017Fixed [github#2].pycalver initwas broken.Fixed pattern escaping issues.Added lots more tests for cli.Cleaned up documentation.PyCalVer v201812.0011-betaAdd version tags using git/hg.Use git/hg tags as SSOT for most recent version.Start usinghttps://gitlab.com/mbarkhau/bootstrapitMove tohttps://gitlab.com/mbarkhau/pycalverPyCalVer v201809.0001-alphaInitial release