Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
472f775
Create a `_shared` module
brettcannon May 6, 2026
ae91c98
Merge remote-tracking branch 'upstream' into wasi-package
brettcannon May 6, 2026
15503a3
Attempt at getting `lib/` working
brettcannon Jun 3, 2026
db0bff7
Ignore "/dist/"
brettcannon Jun 3, 2026
b97d997
Get `lib/` working
brettcannon Jun 3, 2026
0808516
Add some caching
brettcannon Jun 3, 2026
353cf3c
Log what's going on
brettcannon Jun 4, 2026
99a8eb5
Fix an over-zealous substitution
brettcannon Jun 9, 2026
02870c2
Centralize context in an object
brettcannon Jun 9, 2026
b91761f
Make calculating if a debug build was used easier
brettcannon Jun 9, 2026
1cf9836
Run `ruff format`
brettcannon Jun 9, 2026
347e950
Add comment to clarify debug check for Python 3.13 and older
brettcannon Jun 9, 2026
6748280
Put the files into a subdirectory that records the Python version and…
brettcannon Jun 10, 2026
de141e8
Add the man page
brettcannon Jun 10, 2026
4c53d56
Symlink man page
brettcannon Jun 11, 2026
c5f1a65
Get symlinks working
brettcannon Jun 11, 2026
6048670
Fix the `clean` and `build` commands
brettcannon Jul 9, 2026
19899cd
Get `wasmtime.toml` copied over
brettcannon Jul 9, 2026
1b5b8e7
Copy `python.wasm`
brettcannon Jul 9, 2026
feef36d
Copy `pythonN.Md-config`
brettcannon Jul 9, 2026
32f2bd0
Get the wasmtime script working
brettcannon Jul 10, 2026
fbf38fe
`ruff format`
brettcannon Jul 10, 2026
4f69a2a
Get at the WASI build version easily
brettcannon Jul 10, 2026
fd0464e
Remove reproducible build comments from _package.py
brettcannon Jul 10, 2026
b7c618f
Add archiving
brettcannon Jul 15, 2026
5ff44ba
Ignore dist/
brettcannon Jul 15, 2026
ff35f02
Merge branch 'main' into wasi-package
brettcannon Jul 15, 2026
fe5c640
Add quiet mode for pythoninfo commands in main function
brettcannon Jul 15, 2026
d2b5418
Fix archive function to correctly store mtime argument
brettcannon Jul 15, 2026
3742dcb
Update gather function to use dynamic Python versioning in logs
brettcannon Jul 15, 2026
7406160
Format wasmtime_script for better readability
brettcannon Jul 15, 2026
1cf4769
Update archive function log message for clarity
brettcannon Jul 15, 2026
cb0f034
Add comment to clarify use of `xz -T`
brettcannon Jul 16, 2026
5ed0e89
Merge remote-tracking branch 'upstream' into wasi-package
brettcannon Jul 22, 2026
1c28ad8
Reformat
brettcannon Jul 22, 2026
612174b
Make all imports lazy
brettcannon Jul 22, 2026
7b475a5
`ruff check`
brettcannon Jul 22, 2026
f89df22
Plug a hole where the lack of a WASI SDK didn't raise an exception
brettcannon Jul 22, 2026
abc9ea4
Actually delete the generated `Setup.local`
brettcannon Jul 22, 2026
3789b64
Fix archive function to use the correct file name and set working dir…
brettcannon Jul 22, 2026
d97c44f
Make symlinks relative
brettcannon Jul 22, 2026
d9cd409
Add error handling for multiple or missing WASI SDKs
brettcannon Jul 22, 2026
f2214f9
Fix build interpreter to read build details from the correct file path
brettcannon Jul 22, 2026
8222bf4
Enhance archive function to support SOURCE_DATE_EPOCH
brettcannon Jul 22, 2026
8c77179
`ruff format`
brettcannon Jul 22, 2026
7883611
Add `lib-dynload` to get rid of a warning when launching the REPL
brettcannon Jul 22, 2026
28126f4
`ruff format`
brettcannon Jul 22, 2026
d14bb0d
Merge branch 'main' into wasi-package
brettcannon Jul 22, 2026
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
Prev Previous commit
Next Next commit
Run ruff format
  • Loading branch information
brettcannon committed Jun 9, 2026
commit 1cf98360b8ba34fe56e33c69852d9eece69f0849
15 changes: 8 additions & 7 deletions Platforms/WASI/_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,7 @@ def wrapper(context):
working_dir = getattr(context, context_attr)
separator()
_shared.log("📁", os.fsdecode(working_dir))
if (
clean_ok
and context.clean
and working_dir.exists()
):
if clean_ok and context.clean and working_dir.exists():
_shared.log("🚮", "Deleting directory (--clean)...")
shutil.rmtree(working_dir)

Expand Down Expand Up @@ -136,7 +132,10 @@ def configure_build_python(context, working_dir):
if context.setup_local_path.read_bytes() == LOCAL_SETUP_MARKER:
_shared.log("👍", f"{context.setup_local_path} exists ...")
else:
_shared.log("⚠️", f"{context.setup_local_path} exists, but has unexpected contents")
_shared.log(
"⚠️",
f"{context.setup_local_path} exists, but has unexpected contents",
)
else:
_shared.log("📝", f"Creating {context.setup_local_path} ...")
context.setup_local_path.write_bytes(LOCAL_SETUP_MARKER)
Expand Down Expand Up @@ -284,4 +283,6 @@ def clean_contents(context):

if context.setup_local_path.exists():
if context.setup_local_path.read_bytes() == LOCAL_SETUP_MARKER:
_shared.log("🧹", f"Deleting generated {context.setup_local_path} ...")
_shared.log(
"🧹", f"Deleting generated {context.setup_local_path} ..."
)
15 changes: 10 additions & 5 deletions Platforms/WASI/_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
# ❌ share/man/man1/
# ☐ python.wasm


def pythonXY(context, support_debug=False):
"""Calculate the "pythonX.Y" part of a path.

Expand Down Expand Up @@ -80,7 +81,7 @@ def stdlib_files(context):
file_path = pathlib.Path(root) / file
details = (
lib_python(context) / file_path.relative_to(lib_dir),
file_path
file_path,
)
lib_files.append(details)
return lib_files
Expand All @@ -100,7 +101,10 @@ def pkgconfig_files(context):
(pkgconfig / f"python{major}.pc", misc_dir / "python.pc"),
(pkgconfig / f"python-{major}.{minor}.pc", misc_dir / "python.pc"),
(pkgconfig / f"python3-embed.pc", misc_dir / "python-embed.pc"),
(pkgconfig / f"python-{major}.{minor}-embed.pc", misc_dir / "python-embed.pc"),
(
pkgconfig / f"python-{major}.{minor}-embed.pc",
misc_dir / "python-embed.pc",
),
]


Expand All @@ -113,9 +117,10 @@ def filename_stem(context):

def copy_files(files, base):
for dest, src in files:
target = base / dest
target.parent.mkdir(parents=True, exist_ok=True)
src.copy(target)
target = base / dest
target.parent.mkdir(parents=True, exist_ok=True)
src.copy(target)


def package(context):
dist = context.checkout / "dist"
Expand Down
35 changes: 23 additions & 12 deletions Platforms/WASI/_shared.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
__lazy_modules__ = ["json", "os", "subprocess", "sysconfig", "tempfile", "tomllib"]
__lazy_modules__ = [
"json",
"os",
"subprocess",
"sysconfig",
"tempfile",
"tomllib",
]
import functools
import json
import os
Expand All @@ -10,7 +17,6 @@


class Context:

def __init__(self):
self.here = pathlib.Path(__file__).parent

Expand Down Expand Up @@ -50,7 +56,9 @@ def cross_build_path(self):
@functools.cached_property
def build_python_path(self):
# Build platform can also be found via `config.guess`.
return self.cross_build_path / sysconfig.get_config_var("BUILD_GNU_TYPE")
return self.cross_build_path / sysconfig.get_config_var(
"BUILD_GNU_TYPE"
)

@functools.cached_property
def build_python_interpreter(self):
Expand Down Expand Up @@ -94,14 +102,14 @@ def wasi_build_details(self):
@functools.cached_property
def wasi_sdk_path(self):
if wasi_sdk_path := self._wasi_sdk_path:
if not wasi_sdk_path.exists():
raise ValueError(
"WASI SDK not found; "
"download from "
"https://github.com/WebAssembly/wasi-sdk and/or "
"specify via $WASI_SDK_PATH or --wasi-sdk"
)
return wasi_sdk_path
if not wasi_sdk_path.exists():
raise ValueError(
"WASI SDK not found; "
"download from "
"https://github.com/WebAssembly/wasi-sdk and/or "
"specify via $WASI_SDK_PATH or --wasi-sdk"
)
return wasi_sdk_path

with (self.here / "config.toml").open("rb") as file:
config = tomllib.load(file)
Expand Down Expand Up @@ -134,7 +142,10 @@ def wasi_sdk_path(self):
# Starting with WASI SDK 25, a VERSION file is included in the root
# of the SDK directory that we can read to warn folks when they are using
# an unsupported version.
if wasi_sdk_path and (version_file := wasi_sdk_path / "VERSION").is_file():
if (
wasi_sdk_path
and (version_file := wasi_sdk_path / "VERSION").is_file()
):
version_details = version_file.read_text(encoding="utf-8")
found_version = version_details.splitlines()[0]
# Make sure there's a trailing dot to avoid false positives if somehow the
Expand Down