Skip to content

Commit a6f014a

Browse files
committed
Use setuptools-git-versioning for dist versions (e.g. 1.2.3.dev12)
This change restores a `.devN` suffix to the version of distributions built from an untagged commit. The suffix indicates they're a pre-release and makes the version unique - so the dists can be automatically published to test.py.pi.org. Tagged commits will produce a version without any suffix, then be published to both test.pypi.org and pypi.org. The change replaces a previous mechanism that was disabled in #287, while migrating CI to a PEP 517 build frontend/backend. Differences - Target version bumped from 33.0.0 -> 33.0.1 - Target version now stored in the file VERSION - In ".devN" N now counts commits since the file VERSION was modified, previously N counted all commits back to the initial commit - Distributions built from a dirty working tree will generate a version such as "1.2.3.post0+git.45fd99a2.dirty" using `dirty_template` config - The `upload_dists` CI job no longer does a checkout or run of the project setup action. They should be unnecessary, as `setup.py` no longer runs `git` - setuptools-git-versioning is a new build time dependency, it will be installed by any PEP 517 build frontend (e.g. python -m build, pip, uv) Fixes #288 See - https://setuptools-git-versioning.readthedocs.io - https://packaging.python.org/en/latest/guides/writing-pyproject-toml/ - https://setuptools.pypa.io/en/latest/userguide/pyproject_config.html - https://peps.python.org/pep-0517/
1 parent 8a8d215 commit a6f014a

File tree

4 files changed

+21
-13
lines changed

4 files changed

+21
-13
lines changed

.github/workflows/main.yml

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,12 @@ jobs:
4444
steps:
4545
- uses: actions/checkout@v4
4646
with:
47-
# fetch all history so the git-commit-length-appended-to-version for
48-
# publishes to `test.pypi.org` works. (see `git` command in `setup.py`)
47+
# Fetch history & tags so setuptools-git-versioning can generate a
48+
# unique .devN suffix on untagged builds uploaded to test.pypi.org.
49+
# See `tool.setuptools-git-versioning` in `pyproject.toml`.
4950
fetch-depth: 0
5051
- uses: ./.github/actions/setup
5152
- run: pip install build
52-
# If this is a tagged build use real version numbers
53-
- run: echo "PROD=true" >> $GITHUB_ENV
54-
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
5553
- name: Build sdist (source distribution)
5654
run: |
5755
git clean -fdx wasmtime build
@@ -152,12 +150,6 @@ jobs:
152150
needs: build
153151
runs-on: ubuntu-latest
154152
steps:
155-
- uses: actions/checkout@v4
156-
with:
157-
# fetch all history so the git-commit-length-appended-to-version for
158-
# publishes to `test.pypi.org` works. (see `git` command in `setup.py`)
159-
fetch-depth: 0
160-
- uses: ./.github/actions/setup
161153
- uses: actions/download-artifact@v4
162154
with:
163155
name: dists

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ include .flake8
2121
include CONTRIBUTING.md
2222
include mypy.ini
2323
include pytest.ini
24+
include VERSION
2425

2526
# Wasmtime shared library. Downloaded by ci/download-wasmtime.py
2627
# Included in binary distributions

VERSION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
33.0.1

pyproject.toml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
[build-system]
22
requires = [
33
"setuptools",
4+
"setuptools-git-versioning>=2.0,<3",
45
]
56
# Use an in-tree build backend, to customise the wheels we generate
67
build-backend = "backend"
@@ -10,7 +11,9 @@ backend-path = [
1011

1112
[project]
1213
name = "wasmtime"
13-
version = "33.0.0"
14+
dynamic = [
15+
"version",
16+
]
1417
description = "A WebAssembly runtime powered by Wasmtime"
1518
license = "Apache-2.0 WITH LLVM-exception"
1619
readme = "README.md"
@@ -48,7 +51,7 @@ testing = [
4851
]
4952

5053
[project.urls]
51-
"Homepacge" = "https://github.com/bytecodealliance/wasmtime-py"
54+
"Homepage" = "https://github.com/bytecodealliance/wasmtime-py"
5255
"Bug Tracker" = "https://github.com/bytecodealliance/wasmtime-py/issues"
5356
"Documentation" = "https://bytecodealliance.github.io/wasmtime-py/"
5457
"Source Code" = "https://github.com/bytecodealliance/wasmtime-py"
@@ -74,3 +77,14 @@ packages = [
7477
"generated/*.wasm",
7578
"generated/imports/*.py",
7679
]
80+
81+
[tool.setuptools-git-versioning]
82+
# https://setuptools-git-versioning.readthedocs.io/en/stable/options/index.html
83+
enabled = true
84+
version_file = "VERSION"
85+
count_commits_from_version_file = true
86+
# Version for distributions built from an untagged commit.
87+
# Version "1.0.0.dev4" is a treated as a pre-release of Version "1.0.0".
88+
# {tag}: Version under development, read from `version_file`
89+
# {ccount}: Count of commits since `version_file` was last changed
90+
dev_template = "{tag}.dev{ccount}"

0 commit comments

Comments
 (0)