Commit ab6d1d2
authored
feat: read build-details.json (PEP 739) for version detection (#452)
Fixes #449.
Python 3.14+ ships
[`build-details.json`](https://packaging.python.org/en/latest/specifications/build-details/)
(PEP 739) in the platform-independent stdlib directory. Read it as a
faster, more authoritative source than parsing `patchlevel.h` headers,
slotting it between `pyvenv.cfg` and the existing header-based fallback
in the version detection chain.
### Changes
- New `pet_python_utils::build_details` module — finds and parses
`build-details.json` from a sys.prefix-like path. Handles both Unix
(`<prefix>/lib/python<X.Y>[t]/`) and Windows (`<prefix>/Lib/`) layouts.
- New `version::from_build_details(prefix)` and updated chain in
`version::from_prefix`: `pyvenv.cfg → build-details → headers`.
- `version::from_creator_for_virtual_env` now also tries
`build-details.json` (with a `(major, minor)` hint from `pyvenv.cfg`) on
the creator's sys_root before scanning headers.
- Schema validation: only `1.x` accepted; unknown `releaselevel` or read
failures emit warnings.
- Stdlib directory matching uses a strict regex
(`^(python|pypy)\d+\.\d+t?$`) to avoid false positives like `python3`
(versionless) or `python-config`.
- Unit tests in the module + integration tests with realistic JSON
fixtures, including chain-priority assertions (`pyvenv.cfg` beats
`build-details`, `build-details` beats `headers`).1 parent 53a78ed commit ab6d1d2
8 files changed
Lines changed: 674 additions & 1 deletion
File tree
- crates/pet-python-utils
- src
- tests
- unix/build_details
- python3.14/lib/python3.14
- python3.15a/lib/python3.15
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
21 | 24 | | |
22 | 25 | | |
23 | 26 | | |
| |||
0 commit comments