Skip to content

cpython: ship the standard library so the runtime can import re/json#818

Open
brandonpayton wants to merge 1 commit into
mainfrom
gascity/kd-1mr/kd-mt3u-restore-broader-cpython-stdlib-runtime-support
Open

cpython: ship the standard library so the runtime can import re/json#818
brandonpayton wants to merge 1 commit into
mainfrom
gascity/kd-1mr/kd-mt3u-restore-broader-cpython-stdlib-runtime-support

Conversation

@brandonpayton

Copy link
Copy Markdown
Member

Purpose

Restore broader CPython stdlib runtime support (kd-mt3u): make import re/json
(and the rest of the pure-Python stdlib) work on Kandelo.

Root cause

The cpython package built and shipped only python.wasmbuild-cpython.sh
never ran make install, and package.toml declared a single output. The stdlib
lived only in the source tree, so the shipped runtime had no lib/python3.13 on
sys.path
: import re failed with ModuleNotFoundError (and json, which
imports re, failed through it). This is a genuine packaging gap (confirmed by the
kd-y9oo audit that #810's cpython build-script sweep was mechanical, not a removal).

Fix

  • build-cpython.sh: after building python.wasm, package lib/python3.13 (source
    Lib, minus the test suite and GUI-only tkinter/idlelib/turtledemo) into
    python-stdlib.zip and install it as a package output.
  • package.toml: declare the new cpython-stdlib output; build.toml: revision 1→2.
  • Formula/cpython.rb: install python.wasm + unzip the stdlib into the keg and set
    PYTHONHOME so the bottle's python finds re/json; test imports re/json/zlib/base64
    with a json round-trip + re match.
  • demo/import-smoke.ts: Node runtime smoke for representative stdlib imports.

Verification

Built cpython 3.13.3; packaged the stdlib zip (4.3M); unzipped to a clean prefix and
ran the Node smoke (import-smoke.ts) against that shipped layout + PYTHONHOME:

IMPORT_SMOKE_PASSre, json, zlib, os, functools, enum, collections, datetime, base64, hashlib, textwrap, argparse all import; json.dumps/loads round-trip and
re.match verified. This also empirically settles the kd-y9oo caveat: import zlib = ok on the target. Outcome lists: test-runs/kd-mt3u/stdlib-node-smoke/.
Browser/published-bottle acceptance tracks kd-yuef.

Coordination

Overlaps PR #810 (kd-p3hr), which also adds cpython.rb and edits build-cpython.sh.
Same shape as the ruby↔#814 conflict — cpython should be owned here and #810's cpython
reconciled (its build-script sweep is mechanical per kd-y9oo). Flagged to the coordinator.

Bead: kd-mt3u (initiative: homebrew-all; follow-up of kd-p3hr)

🤖 Generated with Claude Code

The cpython package built only python.wasm; build-cpython.sh never installed the
stdlib, so the shipped runtime had no lib/python3.13 on sys.path and `import re`
(and json, which imports re) failed with ModuleNotFoundError. The stdlib existed
only in the source tree.

- build-cpython.sh: after building python.wasm, package lib/python3.13 (from the
  source Lib, excluding the test suite and GUI-only tkinter/idlelib/turtledemo)
  into python-stdlib.zip and install it as a package output.
- package.toml: declare the new cpython-stdlib output (python-stdlib.zip).
- build.toml: bump revision 1 -> 2 (new output).
- Formula/cpython.rb: install python.wasm + unzip the stdlib into the keg and set
  PYTHONHOME so the bottle's python finds re/json; test imports re/json/zlib/base64
  with a json round-trip + re match.
- demo/import-smoke.ts: Node runtime smoke for representative stdlib imports.

Verified under Node (shipped stdlib-zip layout + PYTHONHOME): re/json/zlib/os/
functools/enum/collections/datetime/base64/hashlib/textwrap/argparse all import;
json round-trip + re match pass. Also confirms the cpython target keeps zlib.

Bead: kd-mt3u. Overlaps PR #810's cpython.rb/build-cpython.sh (kd-p3hr); reconcile
like ruby->#814 so cpython is owned here — flagged to coordinator.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
brandonpayton added a commit that referenced this pull request Jul 1, 2026
…b-less runtime

This branch's cpython build shipped only python.wasm with no stdlib packaged, so the
runtime could not import re/json (json imports re). PR #818 (kd-mt3u) fixes this by
shipping lib/python3.13 as a package output. Per coordinator decision (kd-mt3u owns
cpython): revert packages/registry/cpython/build-cpython.sh to origin/main and delete
this branch's homebrew/kandelo-homebrew/Formula/cpython.rb so #818's cpython is the
sole owner. This branch no longer touches CPython vs main; its other language runtimes
(perl/php/erlang/texlive) are unchanged.

This branch's resolver-contract / arch edits to build-cpython.sh are preserved for a
follow-up (test-runs/kd-mt3u/810-reconcile/810-cpython-build-arch-edits.patch).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown

Phase B-1 matrix build status — pr-818-staging

ABI v16. 67 built, 0 failed, 67 total.

Package Arch Status Sha
libcurl wasm32 built b01be826
libcxx wasm32 built bd2dd5a6
libcxx wasm64 built 926cfc96
libpng wasm32 built 25e56ef0
libxml2 wasm32 built eb77d16a
libxml2 wasm64 built 9743c3c9
openssl wasm32 built 296793ae
openssl wasm64 built b53a16d9
sqlite wasm32 built 93b98c80
sqlite wasm64 built 7079a1ac
zlib wasm32 built 4543740c
zlib wasm64 built 4ccf5221
bc wasm32 built 0c54e287
bzip2 wasm32 built 614536d6
coreutils wasm32 built e1a33298
curl wasm32 built ecbc3967
dash wasm32 built 4f2caf8b
diffutils wasm32 built 34f174f8
dinit wasm32 built 97a7849b
fbdoom wasm32 built 3799bb5e
file wasm32 built 535dd689
findutils wasm32 built 4b727dbf
gawk wasm32 built 92e5184d
git wasm32 built 42b4d1cb
grep wasm32 built fd4d79fa
gzip wasm32 built 8f54d8ac
kandelo-sdk wasm32 built ba15af22
kernel wasm32 built 917959d2
less wasm32 built 7f3184f8
lsof wasm32 built 4dc5ae5b
m4 wasm32 built 5fbbe8b3
make wasm32 built 57a6d854
mariadb wasm32 built 9ed4aa94
mariadb wasm64 built eaf29411
modeset wasm32 built d9f12284
msmtpd wasm32 built 23172a3a
nano wasm32 built 763f56f8
ncurses wasm32 built a7862ee0
netcat wasm32 built 57bdd0cd
nginx wasm32 built 933bdcd3
php wasm32 built e047ea3c
posix-utils-lite wasm32 built 2aec933c
sed wasm32 built 9d958a03
spidermonkey wasm32 built ef0ac7d5
tar wasm32 built 050e7cb3
tcl wasm32 built ee9ae67a
unzip wasm32 built b176c19f
userspace wasm32 built a9e013a2
vim wasm32 built 8194ff88
wget wasm32 built 378dca44
xz wasm32 built 763b854c
zip wasm32 built 1c834314
zstd wasm32 built bcd693e5
bash wasm32 built d435c352
mariadb-test wasm32 built 74e71062
mariadb-vfs wasm32 built 85427981
mariadb-vfs wasm64 built 6c3ac528
nethack wasm32 built 5b7fc658
node wasm32 built cdad27ac
spidermonkey-node wasm32 built 6d8dc738
vim-browser-bundle wasm32 built ef862c6f
nethack-browser-bundle wasm32 built d4992e6b
rootfs wasm32 built ae3df667
shell wasm32 built 61c3bb81
lamp wasm32 built f5445d80
node-vfs wasm32 built 75f6e69a
wordpress wasm32 built 1c1bcff5

Auto-generated; replaced on each push. Raw data in the publish-status workflow artifact.

brandonpayton added a commit that referenced this pull request Jul 1, 2026
…s bottle

This branch's perl.rb staged the runtime by globbing the source tree, which
could not include the generated XSLoader.pm (never produced by `make perl`), so
File::Spec failed. PR #821 (kd-k7zy) fixes this end to end: it generates the
core-module runtime, packages it as perl-runtime.zip, statically links the core
XS (Kandelo wasm has no dlopen), and fixes the target -fno-strict-aliasing
miscompile -- File::Spec/POSIX/Cwd/XSLoader all load (Node-verified).

Per coordinator decision (kd-k7zy owns Perl, same resolution as ruby->#814 /
cpython->#818): revert packages/registry/perl/build-perl.sh to origin/main and
delete this branch's homebrew/kandelo-homebrew/Formula/perl.rb so #821's perl is
the sole owner. This branch no longer touches Perl vs main; php/erlang/texlive
are unchanged. #810's build-perl.sh delta was purely the resolver-contract
refactor, which #821 already carries, so nothing is preserved separately.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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