Skip to content

Commit 7d53651

Browse files
authored
Use setuptools-git-versioning for dist versions (e.g. 1.2.3.dev12) (#289)
* Migrate project data from setup.py -> pyproject.toml Preperation for using setuptools-git-versioning which will require a [project] entry in pyproject.toml. Once that exists many keywords in setup.py would need to be declared as dynamic in pyproject.toml. Since they're in practice static I elected to bite the bullet and migrate everything. An example error ``` ******************************************************************************** The following seems to be defined outside of `pyproject.toml`: `description = 'A WebAssembly runtime powered by Wasmtime'` According to the spec (see the link below), however, setuptools CANNOT consider this value unless `description` is listed as `dynamic`. https://packaging.python.org/en/latest/specifications/pyproject-toml/#declaring-project-metadata-the-project-table To prevent this problem, you can list `description` under `dynamic` or alternatively remove the `[project]` table from your file and rely entirely on other means of configuration. ******************************************************************************** ``` * 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/ * Ignore all shared libraries download by ci/download-wasmtime.py Prior to this change wasmtime/android-*/ was not ignored. This caused setuptools-git-versioning to apply the `dirty_version` scheme, rather than the desired `dev_version`. E.g. ```console $ .venv/bin/python -m build ... Successfully built wasmtime-33.0.1.post0+git.a6f014a0.dirty-py3-none-android_26_x86_64.whl ```
1 parent 1d44dad commit 7d53651

File tree

6 files changed

+92
-96
lines changed

6 files changed

+92
-96
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

.gitignore

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# NB Coordinate changes here with pyproject.toml
2+
13
build
24
html
35
dist
@@ -8,9 +10,9 @@ __pycache__
810
*.pyd
911
.coverage
1012
htmlcov
11-
wasmtime/linux-*
12-
wasmtime/darwin-*
13-
wasmtime/win32-*
13+
wasmtime/*-*/*.dll
14+
wasmtime/*-*/*.dylib
15+
wasmtime/*-*/*.so
1416
wasmtime/include
1517
wasmtime/bindgen/generated
1618
tests/codegen/generated

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: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,91 @@
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"
78
backend-path = [
89
"ci/_custom_build",
910
]
11+
12+
[project]
13+
name = "wasmtime"
14+
dynamic = [
15+
"version",
16+
]
17+
description = "A WebAssembly runtime powered by Wasmtime"
18+
license = "Apache-2.0 WITH LLVM-exception"
19+
readme = "README.md"
20+
authors = [
21+
{name="The Wasmtime Project Developers", email="[email protected]"},
22+
]
23+
requires-python=">=3.9"
24+
dependencies = [
25+
"importlib_resources>=5.10",
26+
]
27+
classifiers=[
28+
"Programming Language :: Python",
29+
"Programming Language :: Python :: 3",
30+
"Programming Language :: Python :: 3.9",
31+
"Programming Language :: Python :: 3.10",
32+
"Programming Language :: Python :: 3.11",
33+
"Programming Language :: Python :: 3.12",
34+
"Programming Language :: Python :: 3.13",
35+
"Programming Language :: Python :: Implementation :: CPython",
36+
"Programming Language :: Python :: Implementation :: PyPy",
37+
"Programming Language :: Rust",
38+
"Topic :: Software Development :: Compilers",
39+
"Topic :: Software Development :: Interpreters",
40+
]
41+
42+
[project.optional-dependencies]
43+
testing = [
44+
"coverage",
45+
"pycparser",
46+
"pytest-mypy",
47+
"pytest",
48+
# componentize-py only support x86_64 builds on Windows
49+
# platform.machine() on Windows returns 'AMD64' for x86_64
50+
"componentize-py; platform_system != 'Windows' or platform_machine == 'AMD64'",
51+
]
52+
53+
[project.urls]
54+
"Homepage" = "https://github.com/bytecodealliance/wasmtime-py"
55+
"Bug Tracker" = "https://github.com/bytecodealliance/wasmtime-py/issues"
56+
"Documentation" = "https://bytecodealliance.github.io/wasmtime-py/"
57+
"Source Code" = "https://github.com/bytecodealliance/wasmtime-py"
58+
59+
[tool.setuptools]
60+
include-package-data = true
61+
packages = [
62+
"wasmtime",
63+
"wasmtime.bindgen",
64+
]
65+
66+
[tool.setuptools.package-data]
67+
# NB Coordinate changes here with .gitignore
68+
"wasmtime" = [
69+
# Wasmtime shared library. Downloaded by ci/download-wasmtime.py
70+
"*-*/*.dll",
71+
"*-*/*.dylib",
72+
"*-*/*.so",
73+
"py.typed",
74+
]
75+
"wasmtime.bindgen" = [
76+
# WebAssmbly modules, python bindings. Generated by ci/build-rust.py
77+
"generated/*.py",
78+
"generated/*.wasm",
79+
"generated/imports/*.py",
80+
]
81+
82+
[tool.setuptools-git-versioning]
83+
# https://setuptools-git-versioning.readthedocs.io/en/stable/options/index.html
84+
enabled = true
85+
version_file = "VERSION"
86+
count_commits_from_version_file = true
87+
# Version for distributions built from an untagged commit.
88+
# Version "1.0.0.dev4" is a treated as a pre-release of Version "1.0.0".
89+
# {tag}: Version under development, read from `version_file`
90+
# {ccount}: Count of commits since `version_file` was last changed
91+
dev_template = "{tag}.dev{ccount}"

setup.py

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

0 commit comments

Comments
 (0)