Skip to content

fix(build): pin hatchling <1.32 to fix twine check CI failure - #1095

Merged
Tranquility2 merged 1 commit into
mainfrom
tranquility2/fix-hatchling-twine-metadata-version
Aug 15, 2026
Merged

fix(build): pin hatchling <1.32 to fix twine check CI failure#1095
Tranquility2 merged 1 commit into
mainfrom
tranquility2/fix-hatchling-twine-metadata-version

Conversation

@Tranquility2

@Tranquility2 Tranquility2 commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Fixes #1096

Problem

The Run twine check CI step fails on all PRs (e.g. run 31887608422 on #1090) with:

Checking dist/testcontainers-4.15.0-py3-none-any.whl: ERROR InvalidDistribution: Invalid distribution metadata: '2.5' is not a valid metadata version

Root cause

hatchling>=1.32 started emitting Metadata-Version: 2.5 in built wheel/sdist metadata. The pinned twine (6.2.0, via packaging) doesn't yet recognize 2.5 as valid and rejects the distribution. This is unrelated to any specific PR's diff — it's an unpinned build-backend version issue. See pypa/twine#1327.

Fix

Pin hatchling to >=1.26,<1.32 in pyproject.toml's [build-system] so it keeps emitting Metadata-Version: 2.4, compatible with the current twine/packaging toolchain.

Verification

Ran locally:

uv build && uv run twine check dist/*

Wheel METADATA now shows Metadata-Version: 2.4, and both wheel and sdist pass twine check (PASSED).

hatchling>=1.32 emits Metadata-Version 2.5 in wheel/sdist metadata,
which twine 6.2.0 (via packaging) does not yet recognize as valid,
causing the 'Run twine check' CI step to fail with:
InvalidDistribution: Invalid distribution metadata: '2.5' is not a
valid metadata version.

Pin hatchling to <1.32 so it keeps emitting Metadata-Version 2.4,
which is compatible with the current twine/packaging toolchain.

See pypa/twine#1327

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 6536a34d-6afa-4f02-81ed-89dc72586d04
@Tranquility2
Tranquility2 merged commit c530436 into main Aug 15, 2026
9 checks passed
@Tranquility2
Tranquility2 deleted the tranquility2/fix-hatchling-twine-metadata-version branch August 15, 2026 16:12
alexanderankin pushed a commit that referenced this pull request Aug 16, 2026
…1100)

## Problem
The `Run twine check` CI step fails on all PRs (e.g. run
[31887608422](https://github.com/testcontainers/testcontainers-python/actions/runs/31887608422/job/95019090461?pr=1090)
on #1090) with:

```
Checking dist/testcontainers-4.15.0-py3-none-any.whl: ERROR InvalidDistribution: Invalid distribution metadata: '2.5' is not a valid metadata version
```

Root cause and original tracking issue: #1096.

## Fix
`hatchling` emits `Metadata-Version: 2.5` in built wheel/sdist metadata.
Rather than pinning `hatchling` back to an older version (as done in
#1095), this upgrades `twine` to `>=7.0.0`, which officially added
support for Metadata-Version 2.5, fixing the root cause instead of
working around it.

Supersedes #1095 as the preferred fix.

## Verification
Ran locally:
```
uv build && uv run twine check dist/*
```
Wheel METADATA shows `Metadata-Version: 2.5` (hatchling unpinned), and
both wheel and sdist pass `twine check` (`PASSED`).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CI: twine check fails with 'Invalid distribution metadata: 2.5 is not a valid metadata version'

2 participants