Skip to content

Commit

Permalink
switch from bump2version to bump-my-version
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
egpbos committed Dec 20, 2023
1 parent 8f11e38 commit b2d506b
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 32 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
* Use bumpversion for version in Sphinx config [#44](https://github.com/NLeSC/python-template/issues/44)
* Regenerated docs/conf.py with sphinx-quickstart v3.5.4 + enabled built-in extensions [#44](https://github.com/NLeSC/python-template/issues/44)
* Generate api rst files with extension instead of custom function [#95](https://github.com/NLeSC/python-template/issues/95)
* Change from bump2version (unmaintained) to bump-my-version.

### Removed

Expand Down
2 changes: 1 addition & 1 deletion README.dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ In addition to the information in `my-python-project/project_setup.md`, the deve
1. generating `my-python-project`'s documentation locally
1. running `my-python-project`'s tests locally
1. running `my-python-project`'s linters locally
1. verifying that the `my-python-project`'s version can be updated using `bumpversion`
1. verifying that the `my-python-project`'s version can be updated using `bump-my-version`
1. making a release of `my-python-project` on https://test.pypi.org/

Follow the instructions from `my-python-project/README.dev.md` and make sure that everything works.
Expand Down
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Use this [Cookiecutter](https://cookiecutter.readthedocs.io) template to generat
an empty Python package. Features include:

- Boilerplate unit tests and documentation,
- [Python static setup configuration]({{cookiecutter.directory_name}}/setup.cfg),
- [Python static setup configuration]({{cookiecutter.directory_name}}/pyproject.toml),
- Open source software license,
- Continuous integration with [GitHub action workflows]({{cookiecutter.directory_name}}/.github/workflows) for building, testing, link checking and linting,
- Code style checking with [ruff](https://beta.ruff.rs/),
Expand Down Expand Up @@ -69,7 +69,7 @@ cookiecutter https://github.com/nlesc/python-template.git
| ------------------------- | ------------- | ----------- |
| 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) |
| package_name | my_python_package | Name of the package. Avoid using spaces, dashes, or uppercase letters for the best experience across operating systems. |
| 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. |
| 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. |
| keyword1 | keyword1 | A term that describes your package. |
| keyword2 | keyword2 | Another term that describes your package. |
| version | 0.1.0 |   |
Expand All @@ -89,7 +89,6 @@ Good job! You have now generated the skeleton for your package:

```text
my-python-project/
├── .bumpversion.cfg
├── CHANGELOG.md
├── CITATION.cff
├── CODE_OF_CONDUCT.md
Expand Down
2 changes: 1 addition & 1 deletion tests/test_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def test_bumpversion(baked_with_development_dependencies, project_env_bin_dir):
assert original_version in (project_dir / 'my_python_package' / '__init__.py').read_text('utf-8')
assert original_version in (project_dir / 'docs' / 'conf.py').read_text('utf-8')

result = run([f'{bin_dir}bumpversion', 'major'], project_dir)
result = run([f'{bin_dir}bump-my-version', 'major'], project_dir)
assert result.returncode == 0
assert '' in result.stdout
expected_version = '1.0.0'
Expand Down
21 changes: 0 additions & 21 deletions {{cookiecutter.directory_name}}/.bumpversion.cfg

This file was deleted.

8 changes: 4 additions & 4 deletions {{cookiecutter.directory_name}}/README.dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,12 @@ make doctest

## Versioning

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

```shell
bumpversion major
bumpversion minor
bumpversion patch
bump-my-version major # bumps from e.g. 0.3.2 to 1.0.0
bump-my-version minor # bumps from e.g. 0.3.2 to 0.4.0
bump-my-version patch # bumps from e.g. 0.3.2 to 0.3.3
```

## Making a release
Expand Down
2 changes: 1 addition & 1 deletion {{cookiecutter.directory_name}}/project_setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ help you decide which tool to use for packaging.
## Package version number

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

## Logging
Expand Down
17 changes: 16 additions & 1 deletion {{cookiecutter.directory_name}}/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ version = "{{ cookiecutter.version }}"
[project.optional-dependencies]
dev = [
"build", # build is not only used in publishing (below), but also in the template's test suite
"bump2version",
"bump-my-version",
"coverage [toml]",
"pytest",
"pytest-cov",
Expand Down Expand Up @@ -171,3 +171,18 @@ line-length = 120
known-first-party = ["{{ cookiecutter.package_name }}"]
force-single-line = true
no-lines-before = ["future","standard-library","third-party","first-party","local-folder"]

[tool.bumpversion]
current_version = "{{ cookiecutter.version }}"

[[tool.bumpversion.files]]
filename = "{{ cookiecutter.package_name }}/__init__.py"

[[tool.bumpversion.files]]
filename = "pyproject.toml"

[[tool.bumpversion.files]]
filename = "CITATION.cff"

[[tool.bumpversion.files]]
filename = "docs/conf.py"

0 comments on commit b2d506b

Please sign in to comment.