Skip to content

scripts/update_python_zip.py: build python3XY.zip from vcpkg's python3 port - #7101

Merged
Fedr merged 4 commits into
masterfrom
python-zip-from-vcpkg
Oct 12, 2026
Merged

Fedr merged 4 commits into
masterfrom
python-zip-from-vcpkg

Conversation

@Fedr

@Fedr Fedr commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Adds scripts/update_python_zip.py, which builds python3XY.zip, the pure-Python standard library of an embedded interpreter, from the CPython sources of vcpkg's python3 port. Distribution steps call it to bundle a standard library that matches the Python vcpkg builds, instead of storing the zip in git. thirdparty/python/python312.zip and the workflows are not changed here.

update_python_zip.py [--vcpkg-tag TAG] [--output PATH]
  • --vcpkg-tag: the vcpkg release tag. Default: vcpkg_version from .github/workflows/config.yml.
  • --output: a zip file, or a directory that gets python3XY.zip. Default: the current directory.

What it does:

  1. Reads ports/python3 at that vcpkg tag: version, source SHA512 and patch list.
  2. Downloads python/cpython v<version>, the same archive vcpkg_from_github uses, and checks its SHA512 against the port's.
  3. Applies the port's patches restricted to Lib/. Today only 0018-fix-sysconfig-include.patch touches Lib/sysconfig.py.
  4. Leaves out what python.org's embeddable package leaves out: test, tests, idlelib, tkinter, turtledemo, ensurepip, venv, turtle.py, site-packages.
  5. Compiles the way the embeddable package does: -OO, unchecked-hash .pyc, file names relative to Lib. It writes the .pyc and data files into the zip.

The script needs that Python minor version. If it runs under another one and uv is on PATH, it re-runs itself with uv run --python <X.Y>. It also needs git (for git apply) and network access to GitHub.

For vcpkg 2026.07.29 it builds a 3.79 MB, 596-entry zip from CPython 3.12.13. The committed thirdparty/python/python312.zip is python.org's 3.12.10. Loaded by vcpkg's python.exe/python312.dll 3.12.13 from a folder holding only that zip, json, sysconfig, logging, typing, argparse, unittest, subprocess and xml.dom.minidom import from it. The extension modules (_socket, _ssl, _sqlite3, ...) are not part of the zip; the distribution has to ship them as files.

Why not download the zip from python.org. python.org publishes the Windows embeddable packages (the source of python3XY.zip) only while a Python series gets bug-fix releases. 3.12 moved to security-fix-only releases after 3.12.10, and from 3.12.11 on python.org ships only the source tarballs. So 3.12.10 is the last 3.12 with python-3.12.x-embed-*.zip, which is why the committed zip was stuck there, and why there is nothing to download for vcpkg's 3.12.13:

Version python.org files
3.12.10 installers plus python-3.12.10-embed-amd64.zip, -embed-arm64.zip, -embed-win32.zip
3.12.11 Python-3.12.11.tgz / .tar.xz only
3.12.13 (vcpkg 2026.07.29) Python-3.12.13.tgz / .tar.xz only

A downloaded zip would also lack the vcpkg port's patches to Lib/ (today 0018-fix-sysconfig-include.patch). And a newer series (3.13, 3.14) would have embeddable packages only until it, too, moves to security-fix releases. The script builds from the same source tarball python.org publishes, checked against the port's SHA512, in the embeddable package's format: the same excluded packages, -OO, and unchecked-hash .pyc.

🤖 Generated with Claude Code

… vcpkg bumps

thirdparty/python/python312.zip came from python.org's embeddable package
(3.12.10), while python312.dll comes from vcpkg (3.12.13). The new
scripts/update_python_zip.py reads the python3 port at a vcpkg tag,
downloads that CPython source (checked against the port's SHA512),
applies the port's patches to Lib/, leaves out what the embeddable package
leaves out, and compiles it the same way (-OO, unchecked-hash .pyc).
vcpkg-auto-update.yml runs it in every vcpkg bump PR.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The PSF license of CPython v3.12.13 is contained verbatim in the existing
Python section of THIRD-PARTY-NOTICES.txt.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Fedr
Fedr requested a review from MaxRayskiy October 10, 2026 12:27
@Grantim

Grantim commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

since we have a script to build zip should we really store it in git history, or better just build it on distribution?

… time

Per review, python3XY.zip is not stored in git: distribution steps build it
with this script. python312.zip, its readme, the license pin and
vcpkg-auto-update.yml are back to master. The script takes --vcpkg-tag
(default: config.yml's vcpkg version) and --output (a zip file, or a
directory that gets python3XY.zip; default: the current directory).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Fedr Fedr changed the title Windows: build python312.zip from vcpkg's python3 port, regenerate on vcpkg bumps scripts/update_python_zip.py: build python3XY.zip from vcpkg's python3 port Oct 12, 2026
@Fedr
Fedr merged commit 7b9d336 into master Oct 12, 2026
34 checks passed
@Fedr
Fedr deleted the python-zip-from-vcpkg branch October 12, 2026 12:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants