Skip to content

Add sdist metadata regression test and fix version sanitization - #256

Merged
manugarg merged 1 commit into
mainfrom
fix-sdist-metadata
Aug 22, 2026
Merged

Add sdist metadata regression test and fix version sanitization#256
manugarg merged 1 commit into
mainfrom
fix-sdist-metadata

Conversation

@manugarg

Copy link
Copy Markdown
Owner

Follow-up to #253 (broken sdist metadata) and the already-merged sdist fix (#255).

pip prepares an sdist's metadata by re-running setup.py inside the extracted
archive, where there is no git metadata. If the version can't be recovered there,
pacparser_version() falls back to 1.0.0 and pip discards the file with
"inconsistent version" — the symptom in #253.

This PR hardens that path and adds a guard so it can't silently regress:

  • sanitize_version(): now handles exact tags. v1.5.2 sanitizes to 1.5.2
    instead of keeping the leading v (previously only rescued by setuptools'
    lenient normalization). version.mk now carries a clean PEP 440 version.
  • tests/test_sdist_metadata.py (new): builds the sdist, verifies it ships
    version.mk + the C sources, re-runs egg_info in a git-free copy of the
    archive (exactly what pip does), and asserts the regenerated metadata version
    equals the archive name.
  • CI: runs that test in the build-linux-wheels job right after the sdist
    build.

Verified:

  • New test passes on current code and fails on v1.5.1 (missing version.mk in sdist) — it catches the Broken metadata: 1.3.9..1.5.1 versions #253 regression.
  • Simulated release (tag v1.5.2 → sdist → git-free egg_info → wheel →
    install): metadata version is 1.5.2 end to end, and the installed module
    reports version() == 1.5.2 and parses PAC files.
  • NO_INTERNET=1 make -C src and make -C src pymod pass.

Note: closing #253 also requires cutting the next release (tag + GitHub Release)
so CI publishes a corrected sdist; this PR makes that release safe and
self-verifying.

pip re-runs setup.py inside the extracted sdist (where there is no git
metadata) to prepare installation metadata. If the version cannot be
recovered there, the metadata falls back to 1.0.0 and pip discards the
archive with 'inconsistent version' (see #253).

- Make sanitize_version() handle exact tags: v1.5.2 now sanitizes to
  1.5.2 instead of keeping the leading 'v' (which was only saved by
  setuptools' lenient version normalization).
- Add tests/test_sdist_metadata.py: builds the sdist, verifies it ships
  version.mk and the C sources, re-runs egg_info in a git-free copy of
  the archive and asserts the regenerated metadata version matches the
  archive name.
- Run that test in the build-linux-wheels CI job.
@sonarqubecloud

Copy link
Copy Markdown

@manugarg
manugarg merged commit cd24f63 into main Aug 22, 2026
30 checks passed
@manugarg
manugarg deleted the fix-sdist-metadata branch August 22, 2026 21:14
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.

1 participant