Skip to content

Commit b207c5b

Browse files
fedorovclaude
andcommitted
Version releases by snapshot date alone, not 1.0.<date>
The 1.0. prefix was upstream's version number, which has been 1.00 for the whole life of dicom3tools and will not move. So it spent two of three segments encoding a constant, while reading as *this* package's API version to anyone scanning a requirements file -- which invites ~=1.0 or <2, constraints that look like compatibility promises. There is no API here to promise anything about; there are dated binaries. A bare date says that and claims nothing. Undotted rather than 2026.9.1 because PEP 440 strips leading zeros from release segments: the natural-looking 2026.09.01 normalizes to 2026.9.1, so the tag would name one version and the wheel it produced another -- silently, and unfixably, since no version can be re-uploaded to either index. 20260901 is a single integer segment, taken verbatim from dicom3tools_snapshot[:8], with no transformation that can round-trip wrong. test_recorded_version_is_already_normalized asserts the recorded version equals its own PEP 440 normal form so the trap cannot reopen; it was checked against 2026.09.01, which it rejects. Nothing is published yet, so this costs nothing now. It would not have been reversible in the other direction later. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
1 parent f3d92e3 commit b207c5b

6 files changed

Lines changed: 71 additions & 28 deletions

File tree

‎.github/scripts/verify_pins.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def _check_provenance(text: str, tag: str) -> int:
5454
snapshot = match.group("snapshot")
5555
expected = {
5656
"dicom3tools_snapshot": snapshot,
57-
"dicom3tools_version": f"1.0.{snapshot[:8]}",
57+
"dicom3tools_version": snapshot[:8],
5858
}
5959

6060
failures = 0

‎README.md‎

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -182,37 +182,48 @@ which is what would catch a release whose assets were replaced.
182182

183183
## Versioning
184184

185-
A release version is **upstream's `1.00` followed by the snapshot date** it packages, with
186-
packaging revisions as PEP 440 post-releases:
185+
A release version is **the date of the upstream snapshot it packages**, `YYYYMMDD` and nothing
186+
else, with packaging revisions as PEP 440 post-releases:
187187

188188
| Wheel version | Means |
189189
| --- | --- |
190-
| `1.0.20260901` | the dicom3tools snapshot of 2026-09-01 |
191-
| `1.0.20260901.post1` | the same snapshot — binaries unchanged, packaging fixed |
192-
| `1.0.20261015` | the snapshot of 2026-10-15 |
190+
| `20260901` | the dicom3tools snapshot of 2026-09-01 |
191+
| `20260901.post1` | the same snapshot — binaries unchanged, packaging fixed |
192+
| `20261015` | the snapshot of 2026-10-15 |
193193

194194
The sibling distributions mirror their upstream version exactly, which is not available here:
195195
dicom3tools has been version `1.00` for its entire life and distinguishes releases only by
196-
snapshot timestamp (`dicom3tools_1.00.snapshot.20260901072548.tar.bz2`). `1.0.<date>` keeps the
197-
upstream version visible, sorts correctly, and says which snapshot is inside — which is the only
198-
thing a user of this package is likely to reason about.
196+
snapshot timestamp (`dicom3tools_1.00.snapshot.20260901072548.tar.bz2`). So the date is the only
197+
thing that actually varies, and it is what a user of this package is likely to reason about.
198+
199+
Dating the version rather than prefixing upstream's `1.00` (`1.0.20260901`) is deliberate. That
200+
prefix spends two segments encoding a constant, and it reads as *this package's* API version to
201+
anyone scanning a requirements file — which invites `dicom3tools~=1.0` or `<2`, constraints that
202+
look like compatibility promises. There is no API here to promise anything about beyond
203+
`run()` and `bin_dir()`; there are dated binaries. A bare date says that and claims nothing.
204+
205+
Undotted rather than `2026.9.1`, for a mechanical reason: PEP 440 normalizes away leading zeros
206+
in release segments, so the natural-looking `2026.09.01` silently becomes `2026.9.1` and the git
207+
tag would permanently disagree with the wheel it produced. `20260901` is a single integer
208+
segment — it is `dicom3tools_snapshot[:8]` taken verbatim, with no transformation that could
209+
round-trip wrong. `tests/test_package.py` asserts the version equals its own normalization, so
210+
that trap cannot reopen.
199211

200212
The time of day is dropped: two snapshots on the same day would collide, but upstream ships
201213
roughly monthly and a same-day re-snapshot can take a `.postN`. The full 14-digit timestamp is
202214
recorded in `dicom3toolsUrls.cmake` as `dicom3tools_snapshot`, and `VERSION.txt` inside each
203215
wheel names the exact upstream tarball, so a wheel is always traceable to a source snapshot.
204216

205-
Post-releases rather than a fourth component (`1.0.20260901.1`, which would read as an upstream
206-
version that does not exist) or a local version (`1.0.20260901+d3t1`, which PyPI rejects
207-
outright).
217+
Post-releases rather than a fourth component (`20260901.1`, which would read as a date with a
218+
patch level) or a local version (`20260901+d3t1`, which PyPI rejects outright).
208219

209220
### Tags
210221

211222
Two independent tag namespaces are in play, in two different repositories:
212223

213224
| Tag | Where | What it is | Published to |
214225
| --- | --- | --- | --- |
215-
| `v1.0.20260901` | here | a release of *this package* | PyPI |
226+
| `v20260901` | here | a release of *this package* | PyPI |
216227
| `dicom3tools.20260901072548.post3` | `ImagingDataCommons/dicom3tools` | a set of prebuilt archives | GitHub release only |
217228

218229
Versions come from the `v` tags via `setuptools_scm`, so cutting a release is tagging one. Two
@@ -225,7 +236,7 @@ conventional:
225236
- The upload jobs in `cd.yml` are gated on the release tag starting with `v`.
226237

227238
`version_scheme = "post-release"` is set deliberately: the default, `guess-next-dev`, would
228-
report an untagged commit after `v1.0.20260901` as `1.0.20260902.dev2` — inventing an upstream
239+
report an untagged commit after `v20260901` as `20260902.dev2` — inventing an upstream
229240
snapshot date that almost certainly does not exist. Untagged builds also carry a local version
230241
segment (`+g<sha>`), which PyPI refuses, so a development build cannot be uploaded by accident.
231242

@@ -265,8 +276,8 @@ and a rehearsal cannot consume the real version number:
265276

266277
| Release | Tag | Publishes to |
267278
| --- | --- | --- |
268-
| pre-release | `v1.0.20260901rc1` | TestPyPI |
269-
| full release | `v1.0.20260901` | PyPI |
279+
| pre-release | `v20260901rc1` | TestPyPI |
280+
| full release | `v20260901` | PyPI |
270281

271282
The full sequence for a new upstream snapshot:
272283

‎dicom3toolsUrls.cmake‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ set(DICOM3TOOLS_BINARIES_BASE_URL ""
3636
# Do not edit this section directly.
3737

3838
set(dicom3tools_snapshot "20260901072548")
39-
set(dicom3tools_version "1.0.20260901")
39+
set(dicom3tools_version "20260901")
4040

4141
set(linux_x86_64_filename "dicom3tools-linux-x86_64.tar.gz")
4242
set(linux_x86_64_sha256 "630fe080dd004e1e93cc615b1443bd2add8921e47473bfb74861be7ae7d99e35")

‎pyproject.toml‎

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,16 @@ dependencies = []
4646
test = [
4747
"pytest >=6",
4848
"pytest-cov >=3",
49+
# Used by tests/test_package.py to check that the recorded version is already in PEP 440
50+
# normal form. pytest pulls it in anyway; named here so the test does not rest on that.
51+
"packaging",
4952
]
5053
dev = [
5154
"pytest >=6",
5255
"pytest-cov >=3",
56+
# Used by tests/test_package.py to check that the recorded version is already in PEP 440
57+
# normal form. pytest pulls it in anyway; named here so the test does not rest on that.
58+
"packaging",
5359
]
5460

5561
[project.urls]
@@ -104,13 +110,13 @@ wheel.py-api = "py3"
104110

105111
[tool.setuptools_scm]
106112
write_to = "src/dicom3tools/_version.py"
107-
# Releases are named after the upstream dicom3tools snapshot they package -- 1.0.<YYYYMMDD>,
108-
# upstream's 1.00 plus the snapshot date -- with packaging-only revisions as PEP 440
109-
# post-releases (1.0.20260901, then 1.0.20260901.post1). The default version_scheme,
110-
# guess-next-dev, does not fit that: it reports an untagged commit after 1.0.20260901 as
111-
# "1.0.20260902.dev2", inventing an upstream snapshot date that almost certainly does not
112-
# exist. post-release reports "1.0.20260901.post2" instead, which is what the next release from
113-
# here would actually be called. See the Versioning section of the README.
113+
# Releases are named after the upstream dicom3tools snapshot they package -- <YYYYMMDD>, the
114+
# snapshot date and nothing else -- with packaging-only revisions as PEP 440 post-releases
115+
# (20260901, then 20260901.post1). The default version_scheme, guess-next-dev, does not fit
116+
# that: it reports an untagged commit after 20260901 as "20260902.dev2", inventing an upstream
117+
# snapshot date that almost certainly does not exist. post-release reports "20260901.post2"
118+
# instead, which is what the next release from here would actually be called. See the
119+
# Versioning section of the README.
114120
version_scheme = "post-release"
115121
# Restricted to v-prefixed tags. At its defaults setuptools_scm matches any tag containing a
116122
# digit, and its default tag_regex has an optional "[\w-]+-" prefix group, so any other tag

‎scripts/update_dicom3tools_urls.py‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,10 @@ def sha256_of(asset: dict) -> str:
118118
def version_from_tag(tag: str) -> tuple[str, str]:
119119
"""Return (snapshot, wheel version) for a dicom3tools release tag.
120120
121-
The wheel version is upstream's 1.00 followed by the snapshot date: 1.0.20260901. See the
122-
Versioning section of the README for why the date rather than a serial number, and why the
123-
time of day is dropped.
121+
The wheel version is the snapshot date and nothing else: 20260901. That is the tag's own
122+
first eight digits, taken verbatim -- see the Versioning section of the README for why the
123+
date rather than a serial number, why the time of day is dropped, and why the date is not
124+
punctuated into 2026.9.1.
124125
"""
125126
match = TAG_RE.match(tag)
126127
if match is None:
@@ -130,7 +131,7 @@ def version_from_tag(tag: str) -> tuple[str, str]:
130131
)
131132
raise ValueError(msg)
132133
snapshot = match.group("snapshot")
133-
return snapshot, f"1.0.{snapshot[:8]}"
134+
return snapshot, snapshot[:8]
134135

135136

136137
def generate_block(assets: list[dict], tag: str) -> str:

‎tests/test_package.py‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,34 @@
11
from __future__ import annotations
22

33
import importlib.metadata
4+
import re
5+
from pathlib import Path
6+
7+
from packaging.version import Version
48

59
import dicom3tools as m
610

11+
_URLS_FILE = Path(__file__).parent.parent / "dicom3toolsUrls.cmake"
12+
_VERSION_RE = re.compile(r'^set\(dicom3tools_version\s+"([^"]*)"\)', re.MULTILINE)
13+
714

815
def test_version():
916
assert importlib.metadata.version("dicom3tools") == m.__version__
17+
18+
19+
def test_recorded_version_is_already_normalized():
20+
"""The version the next release will be tagged with must survive PEP 440 unchanged.
21+
22+
Versions here are bare snapshot dates (20260901), and the reason they are undotted is that
23+
PEP 440 strips leading zeros from release segments: a punctuated 2026.09.01 would normalize
24+
to 2026.9.1, so the git tag would name one version and the wheel it produced another --
25+
silently, and permanently, since a version can never be re-uploaded. A single integer
26+
segment has no such trap, and this asserts nobody reintroduces one.
27+
"""
28+
match = _VERSION_RE.search(_URLS_FILE.read_text())
29+
assert match is not None, f"no dicom3tools_version in {_URLS_FILE}"
30+
recorded = match.group(1)
31+
assert str(Version(recorded)) == recorded, (
32+
f"dicom3tools_version '{recorded}' normalizes to '{Version(recorded)}'; "
33+
f"tag v{recorded} would not produce a wheel called {recorded}"
34+
)

0 commit comments

Comments
 (0)