Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions guests/python/Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link

Copilot AI Nov 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new environment variables PYTHON_SDK_BASE_URL, PYTHON_SDK_URL, and BUILD_PYTHON_SDK_URL should be documented so users know they can configure custom download locations. Consider adding a section to guests/python/README.md under the "Build" section or to CONTRIBUTING.md explaining these configuration options and their use cases (e.g., using custom mirrors, air-gapped environments).

Suggested change
# Configurable URLs for Python SDK downloads (with defaults)
# Python SDK download URL configuration
#
# The following environment variables can be set to customize the download locations for the Python WASM SDK:
# - PYTHON_SDK_BASE_URL: Base URL for Python SDK releases (default: official GitHub release)
# - PYTHON_SDK_URL: Full URL for the pre-built Python SDK zip file
# - BUILD_PYTHON_SDK_URL: Full URL for the build Python SDK zip file
#
# These variables are useful for:
# - Using custom mirrors or internal artifact repositories
# - Building in air-gapped or restricted network environments
# - Overriding the default download source for testing or reliability
#
# Example usage:
# export PYTHON_SDK_BASE_URL="https://my-mirror.local/python-wasi"
# just build-release
#

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks copilot!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I personally feel this is sufficiently described in the README as well, so the doc here seems a bit redundant. But I leave that up to you.

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
Expand Down Expand Up @@ -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 \
Expand All @@ -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
Expand Down
29 changes: 29 additions & 0 deletions guests/python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could mention PYTHON_SDK_BASE_URL too, which is useful esp. when you fork https://github.com/brettcannon/cpython-wasi-build since it will "just work" (i.e. the two sub-URLs are correctly derived for your fork as well).


- `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]:

Expand Down