Skip to content

Commit 2f43c92

Browse files
committed
chore: switch to versioningit
I have been finding hatch-vcs (built on top of setuptools-scm) to be a bit too finicky, so I am switching to versioningit. Signed-off-by: JP-Ellis <josh@jpellis.me>
1 parent 1bfacef commit 2f43c92

File tree

5 files changed

+83
-90
lines changed

5 files changed

+83
-90
lines changed

docs/releases.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ There are a couple of exceptions to the [semantic versioning](https://semver.org
1717

1818
Any deviation from the the standard semantic versioning rules will be clearly documented in the release notes.
1919

20-
The version is stored in `pact/__version__.py`. This file is automatically generated by [`hatch-vcs`](https://pypi.org/project/hatch-vcs/) and generates a version based on the latest version tag and the number of commits since that tag. Specifically:
20+
The version is stored in `pact/__version__.py`. This file is automatically generated by [`versioningit`](https://versioningit.readthedocs.io/en/stable/) and generates a version based on the latest version tag and the number of commits since that tag. Specifically:
2121

2222
- If the latest tag is `v1.2.3` and there have been no commits since then and the repository is clean, the version will be `1.2.3`.
23-
- Otherwise, the version will take the form of `1.2.3.dev{N}+g{hash}` (or `1.2.3.dev{N}+g{hash}.d{date}` if there's a dirty repository) where `N` is the number of commits since the latest tag, `hash` is the short hash of the latest commit.
23+
- Otherwise, the version will take the form of a post-release based on the last version.
2424

2525
## Build Pipeline
2626

pact-python-cli/pyproject.toml

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -63,38 +63,19 @@ types = ["mypy==1.19.0"]
6363
################################################################################
6464
[build-system]
6565
build-backend = "hatchling.build"
66-
requires = ["hatch-vcs", "hatchling", "packaging"]
66+
requires = ["hatchling", "packaging", "versioningit"]
6767

6868
[tool.hatch]
6969

7070
[tool.hatch.version]
71-
source = "vcs"
72-
tag-pattern = '^pact-python-cli/(?P<version>\d+(?:\.\d+)*(?:(?:a|b|rc|\.post)\d+)?)$'
73-
74-
[tool.hatch.version.raw-options]
75-
git_describe_command = [
76-
"git",
77-
"describe",
78-
"--tags",
79-
"--dirty",
80-
"--always",
81-
"--long",
82-
"--match",
83-
"pact-python-cli/*",
84-
]
85-
root = ".."
86-
version_scheme = "no-guess-dev"
71+
source = "versioningit"
8772

8873
[tool.hatch.build]
74+
artifacts = ["src/pact_cli/__version__.py"]
75+
packages = ["src/pact_cli"]
8976

90-
[tool.hatch.build.hooks.vcs]
91-
version-file = "src/pact_cli/__version__.py"
92-
93-
[tool.hatch.build.targets.wheel]
94-
packages = ["src/pact_cli"]
95-
96-
[tool.hatch.build.targets.wheel.hooks.custom]
97-
patch = "hatch_build.py"
77+
[tool.hatch.build.targets.wheel.hooks.custom]
78+
patch = "hatch_build.py"
9879

9980
########################################
10081
## Hatch Environment Configuration
@@ -133,6 +114,26 @@ requires = ["hatch-vcs", "hatchling", "packaging"]
133114
[[tool.hatch.envs.test.matrix]]
134115
python = ["3.10", "3.11", "3.12", "3.13", "3.14"]
135116

117+
################################################################################
118+
## Versioningit Configuration
119+
################################################################################
120+
[tool.versioningit]
121+
[tool.versioningit.vcs]
122+
match = ["pact-python-cli/*"]
123+
method = "git"
124+
125+
[tool.versioningit.tag2version]
126+
rmprefix = "pact-python-cli/"
127+
128+
[tool.versioningit.write]
129+
file = "src/pact_cli/__version__.py"
130+
template = '''\
131+
# This file is auto-generated by versioningit. Do not edit.
132+
__version__ = "{version}"
133+
__version_tuple__ = {version_tuple}
134+
__commit_id__ = "{revision}"
135+
'''
136+
136137
################################################################################
137138
## PyTest Configuration
138139
################################################################################

pact-python-ffi/pyproject.toml

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -50,38 +50,19 @@ types = ["mypy==1.19.0", "typing-extensions~=4.0"]
5050
################################################################################
5151
[build-system]
5252
build-backend = "hatchling.build"
53-
requires = ["hatch-vcs", "hatchling", "packaging", "cffi"]
53+
requires = ["hatchling", "packaging", "cffi", "setuptools", "versioningit"]
5454

5555
[tool.hatch]
5656

5757
[tool.hatch.version]
58-
source = "vcs"
59-
tag-pattern = '^pact-python-ffi/(?P<version>\d+(?:\.\d+)*(?:(?:a|b|rc|\.post)\d+)?)$'
60-
61-
[tool.hatch.version.raw-options]
62-
git_describe_command = [
63-
"git",
64-
"describe",
65-
"--tags",
66-
"--dirty",
67-
"--always",
68-
"--long",
69-
"--match",
70-
"pact-python-ffi/*",
71-
]
72-
root = ".."
73-
version_scheme = "no-guess-dev"
58+
source = "versioningit"
7459

7560
[tool.hatch.build]
61+
artifacts = ["src/pact_ffi/__version__.py"]
62+
packages = ["src/pact_ffi"]
7663

77-
[tool.hatch.build.hooks.vcs]
78-
version-file = "src/pact_ffi/__version__.py"
79-
80-
[tool.hatch.build.targets.wheel]
81-
packages = ["src/pact_ffi"]
82-
83-
[tool.hatch.build.targets.wheel.hooks.custom]
84-
patch = "hatch_build.py"
64+
[tool.hatch.build.targets.wheel.hooks.custom]
65+
patch = "hatch_build.py"
8566

8667
########################################
8768
## Hatch Environment Configuration
@@ -91,7 +72,7 @@ requires = ["hatch-vcs", "hatchling", "packaging", "cffi"]
9172
# Install dev dependencies in the default environment to simplify the developer
9273
# workflow.
9374
[tool.hatch.envs.default]
94-
extra-dependencies = ["hatch-vcs", "hatchling", "packaging", "cffi"]
75+
extra-dependencies = ["hatchling", "packaging", "cffi"]
9576
installer = "uv"
9677
path = ".venv"
9778
pre-install-commands = ["uv pip install --group dev -e ."]
@@ -127,6 +108,26 @@ requires = ["hatch-vcs", "hatchling", "packaging", "cffi"]
127108
[[tool.hatch.envs.test.matrix]]
128109
python = ["3.10", "3.11", "3.12", "3.13", "3.14"]
129110

111+
################################################################################
112+
## Versioningit Configuration
113+
################################################################################
114+
[tool.versioningit]
115+
[tool.versioningit.vcs]
116+
match = ["pact-python-ffi/*"]
117+
method = "git"
118+
119+
[tool.versioningit.tag2version]
120+
rmprefix = "pact-python-ffi/"
121+
122+
[tool.versioningit.write]
123+
file = "src/pact_ffi/__version__.py"
124+
template = '''\
125+
# This file is auto-generated by versioningit. Do not edit.
126+
__version__ = "{version}"
127+
__version_tuple__ = {version_tuple}
128+
__commit_id__ = "{revision}"
129+
'''
130+
130131
################################################################################
131132
## PyTest Configuration
132133
################################################################################

pyproject.toml

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -150,40 +150,21 @@ test-v2 = [
150150
"uvicorn[standard]~=0.0",
151151
]
152152

153-
[build-system]
154-
build-backend = "hatchling.build"
155-
requires = ["hatch-vcs", "hatchling"]
156-
157153
################################################################################
158154
## Hatch Configuration
159155
################################################################################
156+
[build-system]
157+
build-backend = "hatchling.build"
158+
requires = ["hatchling", "versioningit"]
159+
160160
[tool.hatch]
161161

162162
[tool.hatch.version]
163-
source = "vcs"
164-
tag-pattern = '^pact-python/(?P<version>\d+(?:\.\d+)*(?:(?:a|b|rc|\.post)\d+)?)$'
165-
166-
[tool.hatch.version.raw-options]
167-
git_describe_command = [
168-
"git",
169-
"describe",
170-
"--tags",
171-
"--dirty",
172-
"--always",
173-
"--long",
174-
"--match",
175-
"pact-python/*",
176-
]
177-
root = "."
178-
version_scheme = "no-guess-dev"
163+
source = "versioningit"
179164

180165
[tool.hatch.build]
181-
182-
[tool.hatch.build.hooks.vcs]
183-
version-file = "src/pact/__version__.py"
184-
185-
[tool.hatch.build.targets.wheel]
186-
packages = ["/src/pact"]
166+
artifacts = ["src/pact/__version__.py"]
167+
packages = ["src/pact"]
187168

188169
########################################
189170
## Hatch Environment Configuration
@@ -193,7 +174,7 @@ requires = ["hatch-vcs", "hatchling"]
193174
# Install dev dependencies in the default environment to simplify the developer
194175
# workflow.
195176
[tool.hatch.envs.default]
196-
extra-dependencies = ["hatchling", "hatch-vcs"]
177+
extra-dependencies = ["hatchling", "packaging"]
197178
installer = "uv"
198179
path = ".venv"
199180
# This is require to get around an incompatibility between hatch and uv
@@ -272,6 +253,26 @@ requires = ["hatch-vcs", "hatchling"]
272253
[[tool.hatch.envs.v2-example.matrix]]
273254
python = ["3.10", "3.11", "3.12", "3.13", "3.14"]
274255

256+
################################################################################
257+
## Versioningit Configuration
258+
################################################################################
259+
[tool.versioningit]
260+
[tool.versioningit.vcs]
261+
match = ["pact-python/*"]
262+
method = "git"
263+
264+
[tool.versioningit.tag2version]
265+
rmprefix = "pact-python/"
266+
267+
[tool.versioningit.write]
268+
file = "src/pact/__version__.py"
269+
template = '''\
270+
# This file is auto-generated by versioningit. Do not edit.
271+
__version__ = "{version}"
272+
__version_tuple__ = {version_tuple}
273+
__commit_id__ = "{revision}"
274+
'''
275+
275276
################################################################################
276277
## UV Workspace
277278
################################################################################

src/pact/__version__.pyi

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

0 commit comments

Comments
 (0)