Skip to content

Commit aad9b53

Browse files
committed
fix(release): force tag version + strip local identifier in CI
The v0.3.5 publish failed because setuptools-scm produced "0.3.6.dev0+g7e9e85604.d20260517" instead of "0.3.5": 1. CI checkout is at the tagged commit, but the frontend build step (`npm run build:viewer`) modifies tracked files before `python -m build` runs. 2. setuptools-scm sees a dirty tree → bumps to dev0 + adds "+gHASH.dDATE" local version identifier. 3. PyPI 400s on upload because PEP 440 forbids local version identifiers on public package indexes. Two complementary fixes per setuptools-scm's documented best practice: - `SETUPTOOLS_SCM_PRETEND_VERSION_FOR_LLM_EVALUATION_SYSTEM` set from the git tag in `publish.yml`. Bypasses setuptools-scm's tree inspection entirely; the version published is exactly the tag value. - `local_scheme = "no-local-version"` in `pyproject.toml` as defense in depth — even if a local dev build accidentally produced a wheel someone tried to upload, the "+gHASH" suffix wouldn't be there to trip PyPI's PEP 440 check. Verified locally that setuptools-scm still derives versions correctly for dev builds; only the PyPI-incompatible suffix is stripped.
1 parent 7e9e856 commit aad9b53

2 files changed

Lines changed: 21 additions & 8 deletions

File tree

.github/workflows/publish.yml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,19 @@ jobs:
3131
- name: Install uv
3232
uses: astral-sh/setup-uv@v4
3333

34-
- name: Verify tag matches the commit
34+
- name: Force version from tag
3535
run: |
36-
TAG="${GITHUB_REF#refs/tags/v}"
37-
echo "Building for tag v$TAG (setuptools-scm will derive version from git)"
36+
# Tag-driven CI publishing: bypass setuptools-scm's working-tree
37+
# inspection so the published version is exactly the tag, never
38+
# a dev-suffixed derivative. Required because build steps (e.g.
39+
# the frontend `npm run build:viewer`) can write into tracked
40+
# paths and trip setuptools-scm's dirty-tree detection — without
41+
# this override we ship things like 0.3.6.dev0 instead of 0.3.5.
42+
# Per setuptools-scm docs the dist-name-scoped env var is the
43+
# recommended way to do this in CI.
44+
VERSION="${GITHUB_REF#refs/tags/v}"
45+
echo "SETUPTOOLS_SCM_PRETEND_VERSION_FOR_LLM_EVALUATION_SYSTEM=$VERSION" >> "$GITHUB_ENV"
46+
echo "Forcing build version to $VERSION (from tag $GITHUB_REF)"
3847
3948
- name: Build viewer frontend
4049
run: |

pyproject.toml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,15 @@ requires = ["setuptools>=68.0.0", "setuptools-scm>=8.0.0", "wheel"]
8787
build-backend = "setuptools.build_meta"
8888

8989
[tool.setuptools_scm]
90-
# Version is derived from the latest `v*` git tag. When building on a tagged
91-
# commit the version is clean (e.g. "0.3.5"); off-tag commits get a dev
92-
# version (e.g. "0.3.6.dev3+gabc1234"). `fallback_version` covers sdist
93-
# builds and shallow clones where git history isn't available.
94-
fallback_version = "0.0.0+unknown"
90+
# Version is derived from the latest `v*` git tag. When building on a
91+
# tagged commit the version is clean (e.g. "0.3.5"); off-tag commits
92+
# get a dev version (e.g. "0.3.6.dev3"). `local_scheme = "no-local-version"`
93+
# strips the "+gHASH.dDATE" suffix so the result is always PyPI-acceptable
94+
# (PEP 440 forbids local version identifiers on public indexes).
95+
# `fallback_version` covers sdist builds and shallow clones where git
96+
# history isn't available.
97+
local_scheme = "no-local-version"
98+
fallback_version = "0.0.0"
9599

96100
[tool.setuptools.packages.find]
97101
where = ["."]

0 commit comments

Comments
 (0)