Skip to content

Commit 0d9c5b2

Browse files
authored
Merge pull request #183 from influxdata/tm/configure-cpython
feat: configure cpython source
2 parents 9e5e405 + c3aa651 commit 0d9c5b2

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed

guests/python/Justfile

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ SHA256_WASI_SDK_SYSROOT := "35172f7d2799485b15a46b1d87f50a585d915ec662080f005d99
1111

1212
PYTHON_VERSION_FULL := PYTHON_VERSION_MAJOR + "." + PYTHON_VERSION_MINOR + "." + PYTHON_VERSION_MICRO
1313

14+
# Configurable URLs for Python SDK downloads (with defaults)
15+
PYTHON_SDK_BASE_URL := env_var_or_default("PYTHON_SDK_BASE_URL", "https://github.com/brettcannon/cpython-wasi-build/releases/download")
16+
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")
17+
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")
18+
1419
DOWNLOADS_DIR := source_directory() / "downloads"
1520

1621
export PYO3_CROSS_PYTHON_VERSION := PYTHON_VERSION_MAJOR + "." + PYTHON_VERSION_MINOR
@@ -49,7 +54,7 @@ download-python-sdk:
4954
--tlsv1.2 \
5055
--location \
5156
--output "python-sdk.zip" \
52-
"https://github.com/brettcannon/cpython-wasi-build/releases/download/v{{PYTHON_VERSION_FULL}}/python-{{PYTHON_VERSION_FULL}}-wasi_sdk-{{WASI_SDK_VERSION_MAJOR}}.zip"
57+
"{{PYTHON_SDK_URL}}"
5358

5459
curl \
5560
--fail \
@@ -59,7 +64,7 @@ download-python-sdk:
5964
--tlsv1.2 \
6065
--location \
6166
--output "build-python-sdk.zip" \
62-
"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"
67+
"{{BUILD_PYTHON_SDK_URL}}"
6368

6469
echo "{{SHA256_PYTHON_SDK}} python-sdk.zip" | sha256sum -c
6570
echo "{{SHA256_PYTHON_SDK_BUILD}} build-python-sdk.zip" | sha256sum -c

guests/python/README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,35 @@ just build-release
1616
## Python Version
1717
We currently bundle [Python 3.14.0], [build for WASI](https://docs.python.org/3/library/intro.html#webassembly-platforms).
1818

19+
## Custom CPython Configuration
20+
You can configure the build to use a custom CPython source by setting the following environment variables:
21+
22+
23+
- `PYTHON_SDK_BASE_URL`: Base URL to download the Python WASI SDK artifacts. This
24+
should point to a location containing both the main SDK archive and the build
25+
artifacts archive.
26+
- `PYTHON_SDK_URL`: URL to download the main Python WASI SDK archive. This
27+
should point to an artifact containing the pre-built Python runtime and
28+
standard library for WASI. Will override `PYTHON_SDK_BASE_URL` if set.
29+
- `BUILD_PYTHON_SDK_URL`: URL to download the build artifacts archive. This
30+
should point to an artifact containing the compiled Python libraries (like
31+
`libpython3.14.a`, `libmpdec.a`, etc.) needed for static linking. Will override
32+
`PYTHON_SDK_BASE_URL` if set.
33+
34+
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).
35+
36+
Example usage:
37+
```console
38+
export PYTHON_SDK_URL="https://example.com/custom-python-sdk.zip"
39+
export BUILD_PYTHON_SDK_URL="https://example.com/custom-build-python-sdk.zip"
40+
just build-debug
41+
42+
# Or
43+
44+
export PYTHON_SDK_BASE_URL="https://example.com/custom-python-sdk-base/"
45+
just build-debug
46+
```
47+
1948
## Python Standard Library
2049
In contrast to a normal Python installation there are a few notable public[^public] modules **missing** from the [Python Standard Library]:
2150

0 commit comments

Comments
 (0)