From 5caaeb0ba4142451debb4b0f3e1f6af0c944571d Mon Sep 17 00:00:00 2001 From: Brett Jia Date: Tue, 28 Jul 2026 14:42:32 -0400 Subject: [PATCH 1/4] cosmo: bundle a standalone python.standalone.com alongside python.com Appends lib/ and licenses/ to a copy of python.com's own zip store, so the resulting python.standalone.com runs from a single file with no sibling directory needed. Relies on the __COSMOPOLITAN__ /zip/lib landmark added in the cmake-buildsystem's getpath portable-prefix patch. Rides along in the existing cosmo release archives, no new artifact or CI wiring. --- scripts/build_cosmo.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/scripts/build_cosmo.sh b/scripts/build_cosmo.sh index 0683c165..83c6cffd 100755 --- a/scripts/build_cosmo.sh +++ b/scripts/build_cosmo.sh @@ -332,6 +332,14 @@ function build_python () { cd ${BUILDDIR} ${WORKDIR}/pyclean -v ${python_install_dir} + + # bundle lib/ and licenses/ into a copy of python.com's own zip store + # so it runs standalone with no sibling files + cd ${python_install_dir} + cp ./bin/python.com ./bin/python.standalone.com + zip -qr9 ./bin/python.standalone.com lib licenses + cd ${BUILDDIR} + mv ${python_install_dir} python-${python_distro_ver}-${PLATFORM}-${ARCH} tar -czf ${WORKDIR}/python-${python_distro_ver}-${PLATFORM}-${ARCH}.tar.gz python-${python_distro_ver}-${PLATFORM}-${ARCH} zip ${WORKDIR}/python-${python_distro_ver}-${PLATFORM}-${ARCH}.zip $(tar tf ${WORKDIR}/python-${python_distro_ver}-${PLATFORM}-${ARCH}.tar.gz) From 0e4f311b9024b5e5817619f00968ae6ba09635b2 Mon Sep 17 00:00:00 2001 From: Brett Jia Date: Tue, 28 Jul 2026 14:59:29 -0400 Subject: [PATCH 2/4] cosmo: verify python.standalone.com in CI Runs the same version/sysconfig/import/pip checks against python.standalone.com after copying it out to an empty temp dir, so the standalone build is verified to work with no sibling files present rather than just trusting it builds. --- scripts/launch_test.sh | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/scripts/launch_test.sh b/scripts/launch_test.sh index fe3a2d72..79914406 100755 --- a/scripts/launch_test.sh +++ b/scripts/launch_test.sh @@ -177,6 +177,7 @@ function run_test () { unzip ${FULL_DISTRO}.zip cd ${FULL_DISTRO} chmod +x ./bin/python.com + chmod +x ./bin/python.standalone.com fi PYTHON_EXE=python.com ;; @@ -193,6 +194,29 @@ function run_test () { fi echo "::endgroup::" + + if [[ "${OS}" == "cosmo" ]]; then + echo "::group::Standalone Python ${python_distro_ver}" + + # move the single-file build out of the extracted distribution so it + # has no sibling files, proving it's actually standalone + STANDALONE_DIR=$(mktemp -d) + cp ${WORKDIR}/${FULL_DISTRO}/bin/python.standalone.com ${STANDALONE_DIR}/ + cd ${STANDALONE_DIR} + chmod +x ./python.standalone.com + + ./python.standalone.com --version + ./python.standalone.com -m sysconfig + ./python.standalone.com ${WORKDIR}/scripts/test.py + ./python.standalone.com -m pip + + if [[ "${RUN_TESTS}" == "true" ]]; then + ./python.standalone.com -m test -v -ulargefile,network,decimal,cpu,subprocess,urlfetch,tzdata --timeout 60 + fi + + cd ${WORKDIR} + echo "::endgroup::" + fi } run_test From ade5ed20b3e51e59eb6f204bfbc29007b6e4c1e5 Mon Sep 17 00:00:00 2001 From: Brett Jia Date: Thu, 30 Jul 2026 15:15:40 -0400 Subject: [PATCH 3/4] remove cosmo archives from bundle they can't be used for anything at runtime anyways --- scripts/build_cosmo.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/build_cosmo.sh b/scripts/build_cosmo.sh index 2aab6944..691a1a0f 100755 --- a/scripts/build_cosmo.sh +++ b/scripts/build_cosmo.sh @@ -333,9 +333,14 @@ function build_python () { ${WORKDIR}/pyclean -v ${python_install_dir} + cd ${python_install_dir} + + # remove archives - they can't be used to build native extensions anyways + rm -rf ./lib/.aarch64/ + rm -f ./lib/libpython*.a + # bundle lib/ and licenses/ into a copy of python.com's own zip store # so it runs standalone with no sibling files - cd ${python_install_dir} cp ./bin/python.com ./bin/python.standalone.com zip -qr9 ./bin/python.standalone.com lib licenses cd ${BUILDDIR} From eb7b890b2bdea969b711ff745192aa706061e2b8 Mon Sep 17 00:00:00 2001 From: Brett Jia Date: Thu, 30 Jul 2026 15:22:34 -0400 Subject: [PATCH 4/4] keep cosmo archives in overall bundle, exclude from standalone Standalone zip store doesn't need them since they can't build native extensions there anyway, but the full tar/zip bundle should still ship them. --- scripts/build_cosmo.sh | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/scripts/build_cosmo.sh b/scripts/build_cosmo.sh index 691a1a0f..4b1441d9 100755 --- a/scripts/build_cosmo.sh +++ b/scripts/build_cosmo.sh @@ -335,14 +335,11 @@ function build_python () { cd ${python_install_dir} - # remove archives - they can't be used to build native extensions anyways - rm -rf ./lib/.aarch64/ - rm -f ./lib/libpython*.a - # bundle lib/ and licenses/ into a copy of python.com's own zip store # so it runs standalone with no sibling files + # archives excluded - they can't be used to build native extensions anyways cp ./bin/python.com ./bin/python.standalone.com - zip -qr9 ./bin/python.standalone.com lib licenses + zip -qr9 ./bin/python.standalone.com lib licenses -x "lib/.aarch64/*" "lib/libpython*.a" cd ${BUILDDIR} mv ${python_install_dir} python-${python_distro_ver}-${PLATFORM}-${ARCH}