Skip to content

Commit b2d506b

Browse files
committed
switch from bump2version to bump-my-version
bump2version is no longer maintained and suggests using bump-my-version instead. This also allows to put the configuration in pyproject.toml and simplify it at the same time.
1 parent 8f11e38 commit b2d506b

8 files changed

Lines changed: 26 additions & 32 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
* Use bumpversion for version in Sphinx config [#44](https://github.com/NLeSC/python-template/issues/44)
2626
* Regenerated docs/conf.py with sphinx-quickstart v3.5.4 + enabled built-in extensions [#44](https://github.com/NLeSC/python-template/issues/44)
2727
* Generate api rst files with extension instead of custom function [#95](https://github.com/NLeSC/python-template/issues/95)
28+
* Change from bump2version (unmaintained) to bump-my-version.
2829

2930
### Removed
3031

README.dev.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ In addition to the information in `my-python-project/project_setup.md`, the deve
8282
1. generating `my-python-project`'s documentation locally
8383
1. running `my-python-project`'s tests locally
8484
1. running `my-python-project`'s linters locally
85-
1. verifying that the `my-python-project`'s version can be updated using `bumpversion`
85+
1. verifying that the `my-python-project`'s version can be updated using `bump-my-version`
8686
1. making a release of `my-python-project` on https://test.pypi.org/
8787

8888
Follow the instructions from `my-python-project/README.dev.md` and make sure that everything works.

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Use this [Cookiecutter](https://cookiecutter.readthedocs.io) template to generat
88
an empty Python package. Features include:
99

1010
- Boilerplate unit tests and documentation,
11-
- [Python static setup configuration]({{cookiecutter.directory_name}}/setup.cfg),
11+
- [Python static setup configuration]({{cookiecutter.directory_name}}/pyproject.toml),
1212
- Open source software license,
1313
- Continuous integration with [GitHub action workflows]({{cookiecutter.directory_name}}/.github/workflows) for building, testing, link checking and linting,
1414
- Code style checking with [ruff](https://beta.ruff.rs/),
@@ -69,7 +69,7 @@ cookiecutter https://github.com/nlesc/python-template.git
6969
| ------------------------- | ------------- | ----------- |
7070
| directory_name | my-python-project | Name of the directory that contains the package. Avoid using spaces or uppercase letters for the best experience across operating systems. To get an impression of what will be generated, see the directory tree [below](https://github.com/NLeSC/python-template#step-33-read-about-what-was-just-generated) |
7171
| package_name | my_python_package | Name of the package. Avoid using spaces, dashes, or uppercase letters for the best experience across operating systems. |
72-
| package_short_description | Short description of package | The information that you enter here will end up in the README, documentation, license, and setup.cfg, so it may be a good idea to prepare something in advance. |
72+
| package_short_description | Short description of package | The information that you enter here will end up in the README, documentation, license, and pyproject.toml, so it may be a good idea to prepare something in advance. |
7373
| keyword1 | keyword1 | A term that describes your package. |
7474
| keyword2 | keyword2 | Another term that describes your package. |
7575
| version | 0.1.0 |   |
@@ -89,7 +89,6 @@ Good job! You have now generated the skeleton for your package:
8989

9090
```text
9191
my-python-project/
92-
├── .bumpversion.cfg
9392
├── CHANGELOG.md
9493
├── CITATION.cff
9594
├── CODE_OF_CONDUCT.md

tests/test_project.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ def test_bumpversion(baked_with_development_dependencies, project_env_bin_dir):
182182
assert original_version in (project_dir / 'my_python_package' / '__init__.py').read_text('utf-8')
183183
assert original_version in (project_dir / 'docs' / 'conf.py').read_text('utf-8')
184184

185-
result = run([f'{bin_dir}bumpversion', 'major'], project_dir)
185+
result = run([f'{bin_dir}bump-my-version', 'major'], project_dir)
186186
assert result.returncode == 0
187187
assert '' in result.stdout
188188
expected_version = '1.0.0'

{{cookiecutter.directory_name}}/.bumpversion.cfg

Lines changed: 0 additions & 21 deletions
This file was deleted.

{{cookiecutter.directory_name}}/README.dev.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,12 @@ make doctest
113113

114114
## Versioning
115115

116-
Bumping the version across all files is done with [bumpversion](https://github.com/c4urself/bump2version), e.g.
116+
Bumping the version across all files is done with [bump-my-version](https://github.com/callowayproject/bump-my-version), e.g.
117117

118118
```shell
119-
bumpversion major
120-
bumpversion minor
121-
bumpversion patch
119+
bump-my-version major # bumps from e.g. 0.3.2 to 1.0.0
120+
bump-my-version minor # bumps from e.g. 0.3.2 to 0.4.0
121+
bump-my-version patch # bumps from e.g. 0.3.2 to 0.3.3
122122
```
123123

124124
## Making a release

{{cookiecutter.directory_name}}/project_setup.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ help you decide which tool to use for packaging.
7676
## Package version number
7777

7878
- We recommend using [semantic versioning](https://guide.esciencecenter.nl/#/best_practices/releases?id=semantic-versioning).
79-
- For convenience, the package version is stored in a single place: `{{ cookiecutter.directory_name }}/.bumpversion.cfg`.
79+
- For convenience, the package version is stored in a single place: `{{ cookiecutter.directory_name }}/pyproject.toml` under the `tool.bumpversion` header.
8080
- Don't forget to update the version number before [making a release](https://guide.esciencecenter.nl/#/best_practices/releases)!
8181

8282
## Logging

{{cookiecutter.directory_name}}/pyproject.toml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ version = "{{ cookiecutter.version }}"
4444
[project.optional-dependencies]
4545
dev = [
4646
"build", # build is not only used in publishing (below), but also in the template's test suite
47-
"bump2version",
47+
"bump-my-version",
4848
"coverage [toml]",
4949
"pytest",
5050
"pytest-cov",
@@ -171,3 +171,18 @@ line-length = 120
171171
known-first-party = ["{{ cookiecutter.package_name }}"]
172172
force-single-line = true
173173
no-lines-before = ["future","standard-library","third-party","first-party","local-folder"]
174+
175+
[tool.bumpversion]
176+
current_version = "{{ cookiecutter.version }}"
177+
178+
[[tool.bumpversion.files]]
179+
filename = "{{ cookiecutter.package_name }}/__init__.py"
180+
181+
[[tool.bumpversion.files]]
182+
filename = "pyproject.toml"
183+
184+
[[tool.bumpversion.files]]
185+
filename = "CITATION.cff"
186+
187+
[[tool.bumpversion.files]]
188+
filename = "docs/conf.py"

0 commit comments

Comments
 (0)