Skip to content

feat(python): install python.org's signed Windows build with --signed - #304

Merged
CalvinAllen merged 3 commits into
mainfrom
feat/python/signed-builds
Nov 13, 2026
Merged

CalvinAllen merged 3 commits into
mainfrom
feat/python/signed-builds

Conversation

@CalvinAllen

Copy link
Copy Markdown
Contributor

Description

On Windows, dtvem installs python-build-standalone's build of Python, whose python.exe is not Authenticode-signed. python.org signs every Windows binary it ships with a Python Software Foundation certificate. This adds an opt-in way to install that signed build instead, for the versions python.org shipped Windows binaries for:

dtvem install python 3.12.10 --signed   # python.org's build
dtvem install python 3.12 --signed      # newest 3.12.x with a python.org build (3.12.10)
dtvem list-all python                   # Signed column
dtvem list python                       # Build column: "python.org, signed" / "python-build-standalone, not signed"

Without --signed, nothing changes: same manifest entry, same URL, same download path.

Type of Change

  • New feature (non-breaking change which adds functionality)
  • CI/CD or build process change

Related Issues

None.

Changes Made

Mirror (scripts/mirror-binaries)

  • Every python.org build is also published at python/<version>/python.org/<platform>.tar.gz. collectJobs now dedupes on the metadata key instead of version+platform, so python-build-standalone keeps the default location and python.org's build still gets its own. Versions python-build-standalone lacks keep getting python.org's build at the default location, as before. Existing R2 objects are not touched (mirror-sync runs --sync-only).
  • New PythonInstallManagerSource for windows-amd64 from 3.14 on. From 3.14, python.org's per-component MSIs carry no OpenPGP signature, so the MSI path can't verify them. This source repacks the full-install zips python.org's install manager uses, checked against the SHA-256 in python.org's index-windows.json (the same level of trust as the NuGet SHA-512 check). MSIs (OpenPGP) still cover 3.5–3.13 amd64, and pythonarm64 NuGet packages cover arm64.

Manifest (scripts/generate-manifests-from-r2, schemas/manifest.schema.json, src/internal/manifest)

  • The generator labels each Python entry with build (python-build-standalone or python.org, from the metadata's source URL) and nests the python.org build under the default entry's alternates. Released CLIs parse the manifest with plain json.Unmarshal, so they ignore both fields and keep installing the entry's own url (covered by a test that parses the new shape with the old struct).
  • When a source URL's extension isn't in R2 (a repacked zip), the generator probes R2 for the real one. Entries whose source extension exists in R2 are unchanged.
  • Manifest assembly is now a pure function with tests. mirror-tool.yml gets a separate "Test manifest generator" job, so the existing job's name, and any required check on it, is unchanged.
  • The CLI's manifest cache gains a format number. A cache written by an older CLI (which dropped the new fields when it re-saved the manifest) is fetched again instead of hiding the signed builds for up to 24 hours.

CLI

  • dtvem install python <version> --signed, for single and bulk installs. A version with no python.org build is refused, naming the nearest version that has one, rather than installing an unsigned build. A partial version resolves to the newest version with a signed build. After a signed install, dtvem warns when newer releases on that line have no signed build and may carry security fixes the installed version lacks. A signed download is checked against the manifest's SHA-256.
  • --signed is refused for other runtimes and off Windows.
  • Each install records its build in .dtvem-build.json in the version's directory. For installs made before this change, dtvem list falls back to the default build of that version in the manifest built into dtvem (default downloads don't change).
  • list-all's check marks now call tui.GetCheckMark(). tui.CheckMark is empty until the styles initialise, so the existing "installed" marker never showed.

Docs: README section "🔏 Signed Python Builds (Windows)" and CLAUDE.md.

Testing

Test Environment

  • OS: Windows 11
  • Go Version: 1.25.3 (toolchain), module go 1.23
  • dtvem Version: this branch

Test Steps

  1. Unit tests for the mirror sources (paired jobs, the install-manager index including "next" links and filtering, SHA-256 and full-build checks), manifest assembly, the manifest/cache types, the Python provider and the cmd helpers.
  2. MIRROR_NETWORK_TESTS=1 go test -run Network_InstallManager: 14 x64 releases (3.14.0–3.15.2) found in python.org's index. The 3.14.0 build was repacked, and its python.exe and python314.dll are Valid, signed by the Python Software Foundation.
  3. The 3.9.13 build already in the mirror (assembled from MSIs) keeps a valid PSF signature on python.exe and python39.dll.
  4. End to end, with this branch's CLI in a throwaway DTVEM_ROOT: the manifest cache was seeded with a python.org alternate for 3.14.0, served from a local server.
    • install python 3.14.0 --signed installs it, and Get-AuthenticodeSignature on the installed python.exe reports Valid, CN=Python Software Foundation.
    • list shows python.org, signed, and list-all marks 3.14.0, 3.12.10 and 3.9.13 as signed.
    • install python 3.12.12 --signed is refused and names 3.12.10.
    • install python 3.11 --signed (no signed 3.11 in the seeded manifest), node --signed and a second signed install are refused. The bulk install path behaves the same way.

Test Results

✗ Python 3.12.12 has no signed (python.org) build for windows-amd64; the nearest version with one is 3.12.10
→ Install the signed build of 3.12.10 with: dtvem install python 3.12.10 --signed
→ Or install Python 3.12.12 without --signed to get its default build, which is not signed

golangci-lint: 0 issues. All tests pass except TestGlobalVersion_NoConfigFile and TestGlobalVersion_RuntimeNotInConfig in internal/config, which fail the same way on unmodified main on the machine I tested on.

I didn't run a real install without --signed. Unit tests cover that it picks the same entry and downloads it the same way.

Checklist

  • My code follows the Google Go Style Guide
  • I have run golangci-lint run and fixed all issues (includes gofmt, govet, and 40+ linters)
  • I have run go mod tidy to clean up dependencies
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes (go test ./...) (only the two internal/config tests above fail, and they fail on main too)
  • I have commented my code, particularly in hard-to-understand areas
  • I have updated the documentation (README.md, CONTRIBUTING.md, etc.) if needed
  • My changes generate no new warnings or errors
  • I have checked my code works on multiple platforms (Windows, macOS, Linux) if applicable (Windows only locally; CI covers the rest, and --signed is refused off Windows)
  • I have added appropriate error handling
  • I have followed conventional commit format in my commit messages

Breaking Changes

N/A. Default installs and released CLIs are unaffected.

Additional Notes

  • Nothing is signed until the workflows run. After merge, mirror-sync builds the python.org-location archives (about 180 the first time; later runs only add what's missing). Then generate-manifests-from-r2 writes the labels and alternates. Until then, --signed reports that the manifest lists no signed builds.
  • Trade-off: python.org ships no Windows binaries for security-only releases (3.12.11 onward, for example), so a signed build can be older than the newest release on its line. dtvem warns when it is.
  • No claims about endpoint protection: the docs say the build is signed, nothing about how security software treats it.

Every python.org build the mirror assembles is now also published at
python/<version>/python.org/<platform>.tar.gz, alongside the version's
default build. collectJobs dedupes on the metadata key rather than
version and platform, so python-build-standalone keeps the default
location and python.org's build still gets its own. Versions
python-build-standalone lacks keep getting python.org's build at the
default location, as before.

From 3.14 on python.org's per-component MSIs carry no OpenPGP
signature, so windows-amd64 builds from 3.14 come from the zips
python.org's install manager installs, verified against the SHA-256 in
python.org's index-windows.json.
…ernates

The manifest generator labels each Python entry with the build it is
(python-build-standalone or python.org, from the source URL in its
metadata) and nests the python.org build under the default entry's
alternates. Released CLIs ignore both fields and install the same URL
as before.

The generator now probes R2 for a binary's extension when the source
URL's extension is not there (a repacked install-manager zip), and its
manifest assembly is a pure function with tests, which the mirror tool
workflow now runs.

The CLI's manifest types gain Build and Alternates. Its cache files
gain a format number, and a cache written by an older CLI, which dropped
the new fields, is fetched again.
On Windows, dtvem install python <version> --signed installs
python.org's own build, Authenticode-signed by the Python Software
Foundation, instead of python-build-standalone's unsigned one. A
version python.org shipped no Windows build for is refused, naming the
nearest version that has one; a partial version resolves to the newest
version with a signed build, and dtvem warns when newer releases on that
line have none. Bulk installs from runtimes.json take the flag too.

Each install records its build in .dtvem-build.json. dtvem list shows
which build each install is and whether it is signed, and dtvem list-all
marks the versions with a signed build. list-all's check marks now
initialise their style first; the installed marker was always empty.
@CalvinAllen
CalvinAllen merged commit 711e1eb into main Nov 13, 2026
22 checks passed
@CalvinAllen
CalvinAllen deleted the feat/python/signed-builds branch November 13, 2026 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant