From 7fc120fec435b18e69c38c808a4384c8575e2793 Mon Sep 17 00:00:00 2001 From: tim maloney Date: Tue, 18 Nov 2025 12:46:51 -0800 Subject: [PATCH 1/2] feat: configure cpython source --- guests/python/Justfile | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/guests/python/Justfile b/guests/python/Justfile index 5f249b6..b6eba37 100644 --- a/guests/python/Justfile +++ b/guests/python/Justfile @@ -11,6 +11,11 @@ SHA256_WASI_SDK_SYSROOT := "35172f7d2799485b15a46b1d87f50a585d915ec662080f005d99 PYTHON_VERSION_FULL := PYTHON_VERSION_MAJOR + "." + PYTHON_VERSION_MINOR + "." + PYTHON_VERSION_MICRO +# Configurable URLs for Python SDK downloads (with defaults) +PYTHON_SDK_BASE_URL := env_var_or_default("PYTHON_SDK_BASE_URL", "https://github.com/brettcannon/cpython-wasi-build/releases/download") +PYTHON_SDK_URL := env_var_or_default("PYTHON_SDK_URL", PYTHON_SDK_BASE_URL + "/v" + PYTHON_VERSION_FULL + "/python-" + PYTHON_VERSION_FULL + "-wasi_sdk-" + WASI_SDK_VERSION_MAJOR + ".zip") +BUILD_PYTHON_SDK_URL := env_var_or_default("BUILD_PYTHON_SDK_URL", PYTHON_SDK_BASE_URL + "/v" + PYTHON_VERSION_FULL + "/_build-python-" + PYTHON_VERSION_FULL + "-wasi_sdk-" + WASI_SDK_VERSION_MAJOR + ".zip") + DOWNLOADS_DIR := source_directory() / "downloads" export PYO3_CROSS_PYTHON_VERSION := PYTHON_VERSION_MAJOR + "." + PYTHON_VERSION_MINOR @@ -49,7 +54,7 @@ download-python-sdk: --tlsv1.2 \ --location \ --output "python-sdk.zip" \ - "https://github.com/brettcannon/cpython-wasi-build/releases/download/v{{PYTHON_VERSION_FULL}}/python-{{PYTHON_VERSION_FULL}}-wasi_sdk-{{WASI_SDK_VERSION_MAJOR}}.zip" + "{{PYTHON_SDK_URL}}" curl \ --fail \ @@ -59,7 +64,7 @@ download-python-sdk: --tlsv1.2 \ --location \ --output "build-python-sdk.zip" \ - "https://github.com/brettcannon/cpython-wasi-build/releases/download/v{{PYTHON_VERSION_FULL}}/_build-python-{{PYTHON_VERSION_FULL}}-wasi_sdk-{{WASI_SDK_VERSION_MAJOR}}.zip" + "{{BUILD_PYTHON_SDK_URL}}" echo "{{SHA256_PYTHON_SDK}} python-sdk.zip" | sha256sum -c echo "{{SHA256_PYTHON_SDK_BUILD}} build-python-sdk.zip" | sha256sum -c From c3aa6516f3512ea299032786c42cebb915f5e2ab Mon Sep 17 00:00:00 2001 From: tim maloney Date: Tue, 18 Nov 2025 22:03:15 -0800 Subject: [PATCH 2/2] docs: add section for configuring cpython source --- guests/python/README.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/guests/python/README.md b/guests/python/README.md index b91201b..143fe4c 100644 --- a/guests/python/README.md +++ b/guests/python/README.md @@ -16,6 +16,35 @@ just build-release ## Python Version We currently bundle [Python 3.14.0], [build for WASI](https://docs.python.org/3/library/intro.html#webassembly-platforms). +## Custom CPython Configuration +You can configure the build to use a custom CPython source by setting the following environment variables: + + +- `PYTHON_SDK_BASE_URL`: Base URL to download the Python WASI SDK artifacts. This + should point to a location containing both the main SDK archive and the build + artifacts archive. +- `PYTHON_SDK_URL`: URL to download the main Python WASI SDK archive. This + should point to an artifact containing the pre-built Python runtime and + standard library for WASI. Will override `PYTHON_SDK_BASE_URL` if set. +- `BUILD_PYTHON_SDK_URL`: URL to download the build artifacts archive. This + should point to an artifact containing the compiled Python libraries (like + `libpython3.14.a`, `libmpdec.a`, etc.) needed for static linking. Will override + `PYTHON_SDK_BASE_URL` if set. + +If these environment variables are not set, the build will use the default URLs pointing to the official [CPython WASI build releases](https://github.com/brettcannon/cpython-wasi-build/releases). + +Example usage: +```console +export PYTHON_SDK_URL="https://example.com/custom-python-sdk.zip" +export BUILD_PYTHON_SDK_URL="https://example.com/custom-build-python-sdk.zip" +just build-debug + +# Or + +export PYTHON_SDK_BASE_URL="https://example.com/custom-python-sdk-base/" +just build-debug +``` + ## Python Standard Library In contrast to a normal Python installation there are a few notable public[^public] modules **missing** from the [Python Standard Library]: