Skip to content

Package the Python SDK as a wheel - #4519

Draft
noise64 wants to merge 5 commits into
python-agentsfrom
python-sdk-wheel
Draft

noise64 wants to merge 5 commits into
python-agentsfrom
python-sdk-wheel

Conversation

@noise64

@noise64 noise64 commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Part of GOL-1852. Stacked on #4518 (PY-03), which is stacked on #4516 (PY-02). PY-05 comes next.

This PR packages the Python SDK as one host-independent wheel, golem-py-sdk, imported as golem. The Rust assembler reads the wheel directly, without host Python.

  • sdks/python/pyproject.toml builds the wheel with hatchling. The wheel contains src/golem with py.typed. It also contains the prepared assets as golem/_prepared and golem/_compatibility.json, which records the componentize-py revision of the prepared assets.
  • python-sdk-prepare now writes compatibility.json. The new python-sdk-wheel task sets SOURCE_DATE_EPOCH. Without it, the archive timestamps follow the file mtimes and the wheel bytes change between checkouts.
  • golem_python_assembler::read_sdk_wheel reads the ZIP. It rejects unsafe or duplicate paths and checks every file against RECORD in both directions (sha256 and size). It rejects a wheel with another distribution name, another SDK version or another componentize-py revision before it extracts the prepared assets and before it imports any application code. After it extracts the prepared assets, it checks that their identity, the SHA-256 of their manifest, is PREPARED_IDENTITY. The assembler owns this value. The manifest names the digests of the world bindings, the standard library, the adapter and every runtime library, so a set that is internally valid but prepared for another world or runtime fails, even when it comes from the same componentize-py revision. read_prepared applies the same check to a target/prepared directory. The SDK version and the revision are constants of the assembler crate. A unit test checks that the revision equals the pins in Cargo.toml and Makefile.toml.
  • A component built from the wheel is byte-identical to a component built from the source tree. A test checks this, and also checks eight corrupt or mismatched wheels and two internally valid wrong-profile sets against an unmodified control.

Limits: SDK_VERSION comes from the assembler crate version, but cargo make set-version does not update sdks/python/pyproject.toml (0.0.0). A released assembler would reject a wheel built from the tree until the release sets both. The wheel has no license notices yet, so it is not publishable, and its layout is not frozen until GOL-1349 attribution is agreed. Only Linux builds were checked. The final upload size of a component is not measured yet. The CLI does not link the assembler yet (PY-05). Golem CI does not run the assembler integration tests, because they need the prepared assets.

Verification

This head, 91f926c, merges the new #4518 head into the previous head bcc09df and adds one commit: PREPARED_IDENTITY and COMPONENTIZE_PY_REVISION name the assets of componentize-py cad25ee. The pin test now expects one componentize-py line in Cargo.toml, because the wit-component patch no longer names the componentize-py repository. Checks on this head:

  • The prepared assets come from the componentize-py binary at cad25ee, built with the pinned SQLite tarball from a local cache (the same SHA-256). cargo make python-sdk-prepare did not run, because sqlite.org is not reachable from the build host. Two prepares gave the same manifest identity, a120875a…0234. PREPARED_IDENTITY is that value. The previous identity, b1d3997f…, differs only in the blob of libcomponentize_py_runtime.so, whose strings differ only in .llvm.<n> symbol suffixes.
  • uv build --wheel with SOURCE_DATE_EPOCH=315532800: two builds gave the same wheel bytes. An install into a new virtual environment and import golem, with py.typed and _prepared/manifest.json present: pass.
  • python -I -m unittest discover -s tests in sdks/python: pass.
  • cargo test -p golem-python-assembler --tests and --doc, cargo clippy -p golem-python-assembler --all-targets -- -D warnings and cargo fmt -p golem-python-assembler -- --check: pass. A wheel built with the previous assets (componentize-py 58d479e) fails builds_from_the_sdk_wheel with the revision error, before it is rebuilt.
  • ruff format --check: pass. ruff check: fails with the known findings BLE001 (twice, in _registry.py) and S102 (in tests/test_declarations.py).

CI: pull requests run no Golem tests. A missing result is not a pass.

@blacksmith-sh

blacksmith-sh Bot commented Nov 17, 2026

Copy link
Copy Markdown

Found 6 test failures on Blacksmith runners:

Failures

Test View Logs
agent: in-place sed with backup exceeded 15 seconds/
agent: in-place sed with backup exceeded 15 seconds
View Logs
agent: replace across files exceeded 15 seconds/
agent: replace across files exceeded 15 seconds
View Logs
agent: sed delete and insert lines exceeded 15 seconds/
agent: sed delete and insert lines exceeded 15 seconds
View Logs
agent: sed print a line range exceeded 15 seconds/
agent: sed print a line range exceeded 15 seconds
View Logs
agent: write a file with a heredoc exceeded 15 seconds/
agent: write a file with a heredoc exceeded 15 seconds
View Logs
agent: write a file with an expanding heredoc exceeded 15 seconds/
agent: write a file with an expanding heredoc exceeded 15 seconds
View Logs

Fix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

PREPARED_IDENTITY and COMPONENTIZE_PY_REVISION name the assets that
componentize-py 58d479e prepares. The assembler's dev-dependencies
repeated normal dependencies and are removed.
COMPONENTIZE_PY_REVISION and PREPARED_IDENTITY name componentize-py
cad25ee and its prepared assets. The workspace now pins componentize-py
once, because wit-component comes from the wasm-tools fork.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant