Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
120 commits
Select commit Hold shift + click to select a range
fb5b531
Bench: Add Cython (pure and typed) and numba columns to the TypedPyth…
b-re-w Oct 3, 2026
b159f27
TypedPython: decode cl.exe output in the console code page
b-re-w Oct 29, 2026
460a267
Merge pull request #351 from thisisthepy/feat/typedpython-msvc-output…
b-re-w Oct 29, 2026
2a75e57
TypedPython: publish the package to PyPI by trusted publishing
b-re-w Oct 29, 2026
6eb83b1
Merge pull request #355 from thisisthepy/feat/typedpython-pypi
b-re-w Oct 29, 2026
a59096f
TypedPython: @compiled is the only mark; drop the '# typedpython: com…
b-re-w Oct 29, 2026
f702f48
TypedPython: no PyPI publishing; the wheel ships with the GitHub Rele…
b-re-w Oct 29, 2026
66a1410
Merge pull request #356 from thisisthepy/feat/typedpython-no-pypi
b-re-w Oct 29, 2026
cca2ef5
TypedPython tests: child processes install the compiled builtin thems…
b-re-w Oct 29, 2026
cc14724
Merge pull request #357 from thisisthepy/feat/typedpython-drop-module…
b-re-w Oct 29, 2026
0e54f8e
Feat: replace # typedpython: parallel comment with @compiled(parallel…
b-re-w Oct 31, 2026
cf96f26
Merge pull request #359 from thisisthepy/feat/typedpython-compiled-pa…
b-re-w Oct 31, 2026
8824385
Feat: add per-function @compiled(fastmath=True) opt-in (#332)
b-re-w Oct 31, 2026
1463c75
Merge pull request #360 from thisisthepy/feat/typedpython-fastmath
b-re-w Oct 31, 2026
2b1bac3
TypedPython: TSan test ignores races against new_threadstate reusing …
b-re-w Oct 31, 2026
5d81106
Merge pull request #361 from thisisthepy/feat/tsan-new-threadstate
b-re-w Oct 31, 2026
371e967
Test: Make mid() loop heavier in test_eval_breaker to avoid CI timing…
b-re-w Nov 1, 2026
185965c
Merge pull request #362 from thisisthepy/feat/tp-eval-breaker-flake
b-re-w Nov 1, 2026
c14d264
Feat: Switch notebook-e2e native-image CI to Maven Central and stage …
b-re-w Nov 1, 2026
c92c58b
Merge pull request #363 from thisisthepy/feat/phase-a-native-image-ci
b-re-w Nov 1, 2026
afec35c
Fix: Point Gradle toolchain resolution at GRAALVM_HOME in native-imag…
b-re-w Nov 4, 2026
83a7d0b
Merge pull request #364 from thisisthepy/feat/fix-native-image-ci-too…
b-re-w Nov 4, 2026
5b7ac9d
TypedPython: cache generated C for the pypackpack compile slot (#113)
b-re-w Nov 4, 2026
c50b53d
Merge pull request #365 from thisisthepy/feat/tp-c-cache
b-re-w Nov 4, 2026
831174c
Fix: Disable Gradle toolchain auto-detect in native-image CI so Liber…
b-re-w Nov 4, 2026
5464619
Merge pull request #366 from thisisthepy/feat/disable-toolchain-autod…
b-re-w Nov 4, 2026
693252c
Fix: Require BellSoft vendor for JDK 25 native-image toolchain (#251)
b-re-w Nov 4, 2026
7add3ea
Merge pull request #367 from thisisthepy/feat/bellsoft-vendor-native-…
b-re-w Nov 4, 2026
986c736
TypedPython: narrow GCC fastmath to reassociation and FMA contract (#…
b-re-w Nov 5, 2026
decc90e
Feat: add macosArm64 and linuxX64 Kotlin/Native desktop targets (#191)
b-re-w Nov 5, 2026
9394936
Merge pull request #370 from thisisthepy/feat/kn-desktop-targets
b-re-w Nov 5, 2026
5d93fe9
TypedPython test: ignore a probe that succeeds only after the call re…
b-re-w Nov 5, 2026
8ccfda4
TypedPython: fill a fresh New's slots by direct release stores (#125)
b-re-w Nov 5, 2026
6f7b669
TypedPython: MSVC fastmath enables FMA contraction only (#368)
b-re-w Nov 5, 2026
eb17d99
TypedPython: emit-c CLI and manifest for pypackpack's compile slot (#…
b-re-w Nov 5, 2026
c44a7d9
Merge pull request #371 from thisisthepy/feat/tp-new-fixed-direct
b-re-w Nov 5, 2026
23262de
Merge pull request #369 from thisisthepy/feat/tp-gcc-fastmath
b-re-w Nov 5, 2026
9975a41
Merge pull request #372 from thisisthepy/feat/tp-emit-c
b-re-w Nov 5, 2026
8f27c26
Feat: add TypedPythonEmitCTask and manifest v1 mapper in Gradle plugi…
b-re-w Nov 7, 2026
c8ad08c
Merge pull request #373 from thisisthepy/feat/tp-emit-c-gradle
b-re-w Nov 7, 2026
3c2ed3d
Feat(gradle-plugin): register emitTypedPythonC from pythonBindings DS…
b-re-w Nov 7, 2026
a148c07
Merge pull request #374 from thisisthepy/feat/tp-emit-c-plugin-wiring
b-re-w Nov 7, 2026
e01d422
Publish the library, KSP processor and Gradle plugin to Maven Central…
b-re-w Nov 7, 2026
8fa5a33
maven-central: install uv for the typedpython-gate bundle (#375)
b-re-w Nov 7, 2026
71e4598
Merge pull request #376 from thisisthepy/feat/maven-central-publish
b-re-w Nov 7, 2026
cf90930
Release: bump to 3.15.0-alpha03, the first Maven Central release (#377)
b-re-w Nov 7, 2026
88bf6a1
Merge pull request #378 from thisisthepy/feat/release-alpha03
b-re-w Nov 7, 2026
ac5e0dd
Publish python-multiplatform-compose to Maven Central; drop stale And…
b-re-w Nov 7, 2026
684d3f1
Merge pull request #380 from thisisthepy/feat/publish-compose-central
b-re-w Nov 7, 2026
aade0f8
AGENTS 7: what counts as the owner's decision (shared rule)
b-re-w Nov 7, 2026
6cf78d2
Merge pull request #381 from thisisthepy/feat/owner-decision-rule
b-re-w Nov 7, 2026
9e0718b
AGENTS 3, 10: clean up on merge; agents only check compilation
b-re-w Nov 7, 2026
b48ac32
Merge pull request #382 from thisisthepy/feat/agent-build-rule
b-re-w Nov 7, 2026
7638d75
Merge remote-tracking branch 'origin/develop' into feat/bench-cython-…
b-re-w Nov 7, 2026
9507e6d
Merge pull request #384 from thisisthepy/feat/bench-cython-numba
b-re-w Nov 7, 2026
6eae2c4
TypedPython: record benchmark output identity in CI and index the dif…
b-re-w Nov 12, 2026
2815a65
Merge pull request #385 from thisisthepy/feat/tp-bench-outputs
b-re-w Nov 12, 2026
4c714cb
Plugin: iOS consumer wiring can stage the project's free-threaded 3.1…
b-re-w Nov 12, 2026
e066013
Docs: the last pip install example becomes uv pip install (#136)
b-re-w Nov 12, 2026
e308e7e
Merge pull request #388 from thisisthepy/feat/docs-rules-cleanup
b-re-w Nov 12, 2026
c30ff17
TypedPython: tests for three or more list parameters on free-threaded…
b-re-w Nov 12, 2026
89e9bfa
TypedPython: lock three or more list parameters on free-threaded buil…
b-re-w Nov 12, 2026
f64c1bc
Python3: public finalize() and flush(), one-argument eval(expression)…
b-re-w Nov 12, 2026
f16e5f2
Compose host: add macosArm64 and linuxX64 Kotlin/Native desktop targe…
b-re-w Nov 12, 2026
99f7cc1
TypedPython CI: dispatch input race_mutant runs the race mutant tests…
b-re-w Nov 12, 2026
a028e1c
Plugin: iOS consumer wiring is 3.15t only, no freeThreaded switch (#328)
b-re-w Nov 12, 2026
bffb9bf
build-ft-mobile: build free-threaded CPython for x86_64 Android too (…
b-re-w Nov 12, 2026
58ba011
CI: build free-threaded CPython 3.15t for wasm32-emscripten with pthr…
b-re-w Nov 12, 2026
f0e74d3
TypedPython: drop the ob_mutex scheme; pure functions read 3+ lists e…
b-re-w Nov 12, 2026
cfcd15d
TypedPython: the two-list limit test covers functions with effects; p…
b-re-w Nov 12, 2026
82fb5bf
Desktop embeds free-threaded CPython 3.15t only; the free-threaded fa…
b-re-w Nov 12, 2026
d4c8f64
Merge pull request #397 from thisisthepy/feat/wasm-ft-build
b-re-w Nov 12, 2026
2f9267d
Merge pull request #396 from thisisthepy/feat/android-ft-x86_64
b-re-w Nov 12, 2026
ce23f67
Merge remote-tracking branch 'origin/feat/desktop-ft-default' into fe…
b-re-w Nov 12, 2026
4963a4f
Merge pull request #393 from thisisthepy/feat/compose-kn-desktop-targets
b-re-w Nov 12, 2026
b96aa73
Android, androidNative and iOS embed free-threaded CPython 3.15t (#32…
b-re-w Nov 12, 2026
92e35d3
Merge pull request #392 from thisisthepy/feat/interpreter-shutdown
b-re-w Nov 12, 2026
e3133bc
Merge remote-tracking branch 'origin/develop' into feat/tp-multilock
b-re-w Nov 12, 2026
ba29734
Tests: assert 3.15t behaviour where four tests asserted GIL-build or …
b-re-w Nov 12, 2026
bc9a2e3
Merge pull request #398 from thisisthepy/feat/desktop-ft-default
b-re-w Nov 13, 2026
be0fe86
Merge remote-tracking branch 'origin/develop' into feat/mobile-ft-sta…
b-re-w Nov 13, 2026
7c39eba
Docs: record the first 3.15t desktop CI run and what changed from 3.1…
b-re-w Nov 13, 2026
5513111
Merge pull request #400 from thisisthepy/feat/ft-315-docs
b-re-w Nov 13, 2026
c5d5046
Merge pull request #389 from thisisthepy/feat/tp-multilock
b-re-w Nov 13, 2026
1ff3e3e
TypedPython test: count a probe's late success in the buffer size che…
b-re-w Nov 13, 2026
5af19ab
CI: run the Gradle plugin's unit tests in desktop.yml (#403)
b-re-w Nov 13, 2026
1ae08b1
TypedPython: move New's argument references into the slots; borrow lo…
b-re-w Nov 13, 2026
6aab55f
TypedPython: the copy-instead-of-move mutant is an object-like switch…
b-re-w Nov 13, 2026
d524f45
TypedPython test: the array-copy handler test stays under one poll in…
b-re-w Nov 13, 2026
9376f96
Merge pull request #402 from thisisthepy/feat/tp-probe-late
b-re-w Nov 13, 2026
9ea48a2
TypedPython tests: hold the two race mutants' windows open in the mut…
b-re-w Nov 13, 2026
e2b7910
Compose: Bind the fork's design systems in the Compose fixtures (#408)
b-re-w Nov 13, 2026
ee1ee7c
CI: probe embedding the 3.15t wasm build without main (#175)
b-re-w Nov 13, 2026
156cb66
TypedPython: read the Python frame depth once per wrapper call (#125)
b-re-w Nov 13, 2026
305378e
Merge pull request #404 from thisisthepy/feat/ci-plugin-tests
b-re-w Nov 13, 2026
2bca2c8
Merge pull request #411 from thisisthepy/feat/wasm-ft-embed-probe
b-re-w Nov 13, 2026
6b71798
Merge pull request #407 from thisisthepy/feat/tp-406-test
b-re-w Nov 13, 2026
8d416ee
Merge remote-tracking branch 'origin/develop' into feat/mobile-ft-sta…
b-re-w Nov 13, 2026
9bcc2f8
Merge remote-tracking branch 'origin/develop' into feat/tp-alloc-pres…
b-re-w Nov 13, 2026
63e534f
Merge pull request #395 from thisisthepy/feat/tp-ci-race-mutant
b-re-w Nov 13, 2026
41dbc75
Merge remote-tracking branch 'origin/develop' into feat/tp-399-mutants
b-re-w Nov 13, 2026
cee0b92
Merge pull request #405 from thisisthepy/feat/tp-alloc-preserving
b-re-w Nov 13, 2026
0bd7bc4
Merge remote-tracking branch 'origin/develop' into feat/design-system…
b-re-w Nov 13, 2026
0dabd42
Merge pull request #409 from thisisthepy/feat/tp-399-mutants
b-re-w Nov 13, 2026
802e2dd
Merge remote-tracking branch 'origin/develop' into feat/tp-depth-once
b-re-w Nov 13, 2026
d0ce2e9
Design 4.3.4 바: the per-call depth step is 4.3.3b (#412)
b-re-w Nov 13, 2026
10bad50
Merge pull request #412 from thisisthepy/feat/tp-depth-once
b-re-w Nov 13, 2026
83d77b6
Merge remote-tracking branch 'origin/develop' into feat/design-system…
b-re-w Nov 14, 2026
6b29e8b
Chore(compose): bump compose-libraries and composeExtended to 1.11.1-…
b-re-w Nov 14, 2026
141f26f
Docs: guide and README state CPython 3.15 and the 3.15t-only desktop …
b-re-w Nov 14, 2026
e0ceb46
Merge pull request #387 from thisisthepy/feat/mobile-ft-staging
b-re-w Nov 14, 2026
371f713
CI: development tests run only by hand, in one ci.yml, one run at a t…
b-re-w Nov 14, 2026
d6132fe
Merge pull request #421 from thisisthepy/feat/ci-dispatch-only
b-re-w Nov 14, 2026
00d328d
Merge remote-tracking branch 'origin/develop' into feat/design-system…
b-re-w Nov 14, 2026
d83d11e
Feat(compose): bump compose-libraries to 1.11.1-ext.4 and fold compan…
b-re-w Nov 14, 2026
b6baf35
Merge pull request #410 from thisisthepy/feat/design-systems-408
b-re-w Nov 14, 2026
2c46c73
Merge remote-tracking branch 'origin/develop' into feat/guide-ft-315
b-re-w Nov 14, 2026
d9359bc
Docs: guide and README_ko state Android and iOS also embed 3.15t (#418)
b-re-w Nov 14, 2026
8ab2610
Merge pull request #419 from thisisthepy/feat/guide-ft-315
b-re-w Nov 14, 2026
ab27dc8
Release: sync from 8ab26109344bc58fd164863f72e49a341420b1a3 8ab2610
github-actions[bot] Nov 14, 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
14 changes: 10 additions & 4 deletions .github/scripts/ft-mobile/build-android.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
#!/usr/bin/env bash
# Build free-threaded CPython (--disable-gil) for aarch64-linux-android with
# CPython's own tooling (Platforms/Android). Usage: build-android.sh [VERSION]
# CPython's own tooling (Platforms/Android). Usage: build-android.sh [VERSION] [HOST]
# HOST is aarch64-linux-android (default) or x86_64-linux-android.
# Needs ANDROID_HOME (SDK with cmdline-tools/latest) and a JDK 17, 21 or 25.
set -euo pipefail
here="$(cd "$(dirname "$0")" && pwd)"
# shellcheck source=common.sh
source "$here/common.sh"

PY_VERSION="${1:-3.15.0}"
HOST=aarch64-linux-android
HOST="${2:-aarch64-linux-android}"
case "$HOST" in
aarch64-linux-android) elf_arch="ARM aarch64" ;;
x86_64-linux-android) elf_arch="x86-64" ;;
*) echo "unsupported HOST: $HOST" >&2; exit 2 ;;
esac
: "${ANDROID_HOME:?ANDROID_HOME must point at the Android SDK}"

src="$(fetch_source "$PY_VERSION")"
Expand Down Expand Up @@ -55,9 +61,9 @@ require_gil_disabled "$check/prefix/include/python${minor}t/pyconfig.h"
lib="$(ls "$check"/prefix/lib/libpython${minor}t*.so* 2>/dev/null | head -n 1 || true)"
[ -n "$lib" ] || die "no libpython${minor}t*.so in the package"
log "ok: $lib"
file "$lib" | tee /dev/stderr | grep -q 'ARM aarch64' || die "$lib is not an aarch64 ELF"
file "$lib" | tee /dev/stderr | grep -q "$elf_arch" || die "$lib is not an $elf_arch ELF"
[ -d "$check/prefix/lib/python${minor}t" ] || die "no lib/python${minor}t in the package"

cp "$archive" "$FT_OUT/"
echo "Android archive:" >> "${GITHUB_STEP_SUMMARY:-/dev/null}"
echo "Android archive ($HOST):" >> "${GITHUB_STEP_SUMMARY:-/dev/null}"
record_sha256 "$FT_OUT/$(basename "$archive")"
303 changes: 303 additions & 0 deletions .github/scripts/ft-wasm/build-wasm.sh

Large diffs are not rendered by default.

167 changes: 167 additions & 0 deletions .github/scripts/ft-wasm/embed-probe.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
// Embedding probe for the free-threaded wasm32-emscripten archive (#175 step 2, agent proposal).
//
// Usage: node embed-probe.mjs <archive root>
//
// Reaches CPython the way python-multiplatform does: python.mjs is loaded as a module factory
// with noInitialRun (main is never called), and everything goes through Module.wasmExports on the
// JS main thread. Prints one line per check, "[x] PASS|FAIL: detail", and a final
// FT-WASM-EMBED-PROBE-OK only when every check passed. A hang is not caught here; the caller
// wraps this in `timeout` and reads the last "[x]" line it printed.
//
// Node only. Node's main thread uses a real Atomics.wait; a browser's main thread busy-waits and
// services proxied calls, so this probe says nothing about the browser.
import fs from "node:fs";
import path from "node:path";
import { pathToFileURL } from "node:url";

const root = path.resolve(process.argv[2] ?? "");
if (!process.argv[2] || !fs.existsSync(path.join(root, "python.mjs"))) {
console.log(`[setup] FAIL: usage: node embed-probe.mjs <archive root containing python.mjs>, got '${process.argv[2]}'`);
process.exit(2);
}

let failed = false;
const pass = (id, detail) => console.log(`[${id}] PASS: ${detail}`);
const fail = (id, detail) => { failed = true; console.log(`[${id}] FAIL: ${detail}`); };
const finish = () => {
if (failed) { console.log("FT-WASM-EMBED-PROBE-FAILED"); process.exit(1); }
console.log("FT-WASM-EMBED-PROBE-OK");
process.exit(0); // the pthread Workers would otherwise keep the process alive
};

// Same reason as cpython.mjs: with no main there is no WebAssembly.promising frame, so a
// JSPI-suspending syscall import would throw SuspendError.
delete WebAssembly.promising;
delete WebAssembly.Suspending;

const libDir = fs.readdirSync(path.join(root, "lib")).find((d) => /^python3\.\d+t$/.test(d));
if (!libDir) { fail("a", `no lib/python3.<minor>t in ${root}`); finish(); }
const minor = libDir.replace(/^python/, "");

// ---- a. load the factory without main -----------------------------------------------------------
let M;
try {
const { default: EmscriptenModule } = await import(pathToFileURL(path.join(root, "python.mjs")).href);
M = await EmscriptenModule({
noInitialRun: true,
thisProgram: `${root}/bin/python${minor}`,
arguments: [],
preRun(Module) {
globalThis.Module = Module;
// Minimum of node_entry.mjs: mount the host filesystem (the archive is read through
// NODEFS) except the three directories Emscripten owns, then set the environment.
for (const dir of fs.readdirSync("/").filter((d) => !["dev", "lib", "proc"].includes(d)).map((d) => "/" + d)) {
Module.FS.mkdirTree(dir);
Module.FS.mount(Module.FS.filesystems.NODEFS, { root: dir }, dir);
}
Module.FS.chdir(root);
Object.assign(Module.ENV, process.env);
delete Module.ENV.PATH;
Module.ENV.PYTHONHOME = root;
},
});
const mem = M.wasmMemory;
if (!mem) throw new Error("Module.wasmMemory is undefined (the EXPORTED_RUNTIME_METHODS patch did not take effect)");
if (!M.wasmExports) throw new Error("Module.wasmExports is undefined (the EXPORTED_RUNTIME_METHODS patch did not take effect)");
if (!(mem.buffer instanceof SharedArrayBuffer)) throw new Error("wasmMemory.buffer is not a SharedArrayBuffer");
pass("a", `wasmMemory.buffer is a SharedArrayBuffer, ${mem.buffer.byteLength / 65536} pages`);
} catch (e) {
fail("a", String(e && e.stack || e));
finish();
}
const E = M.wasmExports;
// A fresh view each time: a shared memory's old buffer keeps its old length after growth.
const u8 = () => new Uint8Array(M.wasmMemory.buffer);
const u32 = () => new Uint32Array(M.wasmMemory.buffer);
const exported = (name) => {
let v = E[name];
if (v === undefined) v = M["_" + name];
if (v === undefined) throw new Error(`CPython export '${name}' not found on wasmExports or Module`);
return v;
};
const addrOf = (name) => { const v = exported(name); return v instanceof WebAssembly.Global ? v.value : v; };

// ---- b. memory import checks A1 / A2 ------------------------------------------------------------
// Hand-assembled modules importing intrinsics.memory (what Kotlin/Wasm's import is named) and
// exporting load(i32) -> i32 = i32.load. A1 imports a non-shared memory (what Kotlin 2.4.20-Beta2
// emits); A2 a shared one with maximum 65536 pages (what a post-link patch would emit).
const head = [0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00];
const typeSec = [0x01, 0x06, 0x01, 0x60, 0x01, 0x7f, 0x01, 0x7f];
const importPrefix = [0x01, 0x0a, ...Buffer.from("intrinsics"), 0x06, ...Buffer.from("memory"), 0x02];
const tail = [0x03, 0x02, 0x01, 0x00, 0x07, 0x08, 0x01, 0x04, 0x6c, 0x6f, 0x61, 0x64, 0x00, 0x00,
0x0a, 0x09, 0x01, 0x07, 0x00, 0x20, 0x00, 0x28, 0x02, 0x00, 0x0b];
const mod = (limits) => new Uint8Array([...head, ...typeSec,
0x02, importPrefix.length + limits.length, ...importPrefix, ...limits, ...tail]);
const A1 = mod([0x00, 0x00]);
const A2 = mod([0x03, 0x00, 0x80, 0x80, 0x04]);
try {
let a1;
try {
new WebAssembly.Instance(new WebAssembly.Module(A1), { intrinsics: { memory: M.wasmMemory } });
a1 = "instantiated";
} catch (e) {
a1 = e instanceof WebAssembly.LinkError ? "LinkError" : `other:${e && e.name}`;
if (a1 === "LinkError") console.log(` A1 message: ${e.message}`);
}
if (a1 !== "LinkError") throw new Error(`A1 (non-shared import) expected LinkError, got ${a1}`);
const a2 = new WebAssembly.Instance(new WebAssembly.Module(A2), { intrinsics: { memory: M.wasmMemory } });
const addr = addrOf("Py_Version");
const viaLoad = a2.exports.load(addr) >>> 0;
const viaHeap = u32()[addr >>> 2];
if (viaLoad !== viaHeap) throw new Error(`A2.load(${addr}) = ${viaLoad} but HEAPU32 = ${viaHeap}`);
pass("b", `A1 non-shared import: LinkError; A2 shared import (max 65536): instantiated; A2.load(&Py_Version=${addr}) = 0x${viaLoad.toString(16)} equals HEAPU32`);
} catch (e) {
fail("b", String(e && e.stack || e));
}

// ---- c. embedding without main, threads, gc in a worker -----------------------------------------
const cstr = (s) => {
const bytes = Buffer.from(s + "\0");
const p = E.malloc(bytes.length);
if (!p) throw new Error("malloc returned 0");
u8().set(bytes, p);
return p;
};
const script = `
import gc, os, sys, threading
assert sys._is_gil_enabled() is False, "GIL is enabled at the start"
sizes = {}
def reader(i):
with open(os.__file__) as f:
n = len(f.read())
print(f"embed-probe thread {i} read {n} chars of os.py", flush=True)
sizes[i] = n
threads = [threading.Thread(target=reader, args=(i,)) for i in range(4)]
for t in threads:
t.start()
for t in threads:
t.join(timeout=120)
alive = [t.name for t in threads if t.is_alive()]
assert not alive, f"threads still running: {alive}"
assert len(sizes) == 4 and len(set(sizes.values())) == 1, sizes
assert sys._is_gil_enabled() is False, "GIL was re-enabled by the threads"
collected = []
gc_thread = threading.Thread(target=lambda: collected.append(gc.collect()))
gc_thread.start()
gc_thread.join(timeout=120)
assert not gc_thread.is_alive() and collected, "gc.collect() in a worker thread did not finish"
print(f"embed-probe gc.collect() in a worker thread returned {collected[0]}", flush=True)
assert sys._is_gil_enabled() is False, "GIL was re-enabled by gc"
`;
try {
E.Py_Initialize();
pass("c1", "Py_Initialize returned");
const tstate = E.PyEval_SaveThread();
pass("c2", `PyEval_SaveThread returned ${tstate} (main thread detached)`);
const gil = E.PyGILState_Ensure();
const code = cstr(script);
console.log(" running the thread script (a hang here is caught by the caller's timeout)");
const rc = E.PyRun_SimpleString(code);
E.free(code);
E.PyGILState_Release(gil);
if (rc !== 0) throw new Error(`PyRun_SimpleString returned ${rc} (Python traceback, if any, is above)`);
pass("c3", "4 threads read os.py, joined, GIL stayed off, gc.collect() ran in a worker thread; PyGILState_Release returned");
} catch (e) {
fail("c", String(e && e.stack || e));
}
finish();
42 changes: 42 additions & 0 deletions .github/scripts/ft-wasm/smoke.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Smoke test for the free-threaded wasm32-emscripten build (#175), run by build-wasm.sh
# under node. Prints one line starting with FT-WASM-SMOKE-OK, which the script greps for;
# any failed assertion exits non-zero instead.
import sys
import sysconfig
import threading

assert sys.platform == "emscripten", sys.platform
assert sysconfig.get_config_var("Py_GIL_DISABLED") == 1, "not a free-threaded build"
assert sys._is_gil_enabled() is False, "the GIL is enabled at run time"

N_THREADS = 4
N_ITER = 200_000
results = [None] * N_THREADS


def work(i):
total = 0
for k in range(N_ITER):
total += k * (i + 1)
results[i] = (threading.get_ident(), total)


threads = [threading.Thread(target=work, args=(i,)) for i in range(N_THREADS)]
for t in threads:
t.start()
for t in threads:
t.join(timeout=120)
alive = [t.name for t in threads if t.is_alive()]
assert not alive, f"threads still running after join: {alive}"

expected = [(i + 1) * N_ITER * (N_ITER - 1) // 2 for i in range(N_THREADS)]
got = [r[1] if r else None for r in results]
assert got == expected, f"results {got} != {expected}"
idents = {r[0] for r in results}
assert len(idents) == N_THREADS, f"expected {N_THREADS} distinct thread idents, got {idents}"
assert threading.get_ident() not in idents, "a worker ran on the main thread"
# Importing threading must not have re-enabled the GIL.
assert sys._is_gil_enabled() is False, "the GIL was re-enabled during the run"

print(f"FT-WASM-SMOKE-OK gil={sys._is_gil_enabled()} threads={N_THREADS} "
f"abiflags={sys.abiflags} version={sys.version.split()[0]}")
83 changes: 83 additions & 0 deletions .github/scripts/release/central-bundle.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#!/usr/bin/env bash
# Builds the Maven Central deployment of python-multiplatform: every component, signed, in one zip.
# .github/scripts/release/central-bundle.sh <out.zip> [--throwaway-key]
# Run from the repository root. Reads MAVEN_GPG_PRIVATE_KEY and MAVEN_GPG_PASSPHRASE (Gradle signs
# in memory, gradle/central-publishing.gradle.kts). --throwaway-key makes a key for this run only,
# for a dry run that must prove signing works without the release key. Without either, the bundle is
# unsigned and the script says so; Central would refuse it.
# Writes build/central-staging (a Maven layout) and <out.zip>; uploads nothing, see central-upload.sh.
set -euo pipefail
out="${1:?usage: central-bundle.sh <out.zip> [--throwaway-key]}"
mode="${2:-}"
root="$(pwd)"
staging="$root/build/central-staging"
version="$(sed -nE 's/^pythonVersion=(.*)$/\1/p' gradle.properties)-$(sed -nE 's/^libraryVersionSuffix=(.*)$/\1/p' gradle.properties)"

# Not under the repository: gpg-agent's socket path must stay under about 100 characters.
verify_home="$(mktemp -d)"
chmod 700 "$verify_home"
trap 'rm -rf "$verify_home"' EXIT

if [[ "$mode" == "--throwaway-key" ]]; then
GNUPGHOME="$verify_home" gpg --batch --quiet --passphrase '' --quick-generate-key \
"python-multiplatform dry run <dry-run@invalid>" rsa3072 sign 1d
MAVEN_GPG_PRIVATE_KEY="$(GNUPGHOME="$verify_home" gpg --batch --pinentry-mode loopback --passphrase '' --armor --export-secret-keys)"
export MAVEN_GPG_PRIVATE_KEY MAVEN_GPG_PASSPHRASE=""
elif [[ -n "${MAVEN_GPG_PRIVATE_KEY:-}" ]]; then
GNUPGHOME="$verify_home" gpg --batch --quiet --import <<< "$MAVEN_GPG_PRIVATE_KEY"
fi
signed=false
[[ -n "${MAVEN_GPG_PRIVATE_KEY:-}" ]] && signed=true

mkdir -p "$root/.cache"
rm -rf "$staging"
# Gradle reads the key from the environment; the plugin build is a separate build but inherits it.
./gradlew --console=plain publishAllToCentralStaging 2>&1 | tee "$root/.cache/central-gradle.log" || { echo "error: gradle failed (pipe status ${PIPESTATUS[0]})" >&2; exit 1; }

# What Central checks first: every module has pom + jar/klib/zip, sources and javadoc where it is a
# jar publication, and (signed) a good .asc beside every file.
fail=0
while IFS= read -r pom; do
dir="$(dirname "$pom")"; base="$(basename "$pom" .pom)"
ver="$(basename "$dir")"; art="$(basename "$(dirname "$dir")")"
[[ "$ver" == "$version" ]] || { echo "error: $pom is not at $version" >&2; fail=1; }
grep -q '<url>https://github.com/thisisthepy/python-multiplatform</url>' "$pom" || { echo "error: $pom has no project url" >&2; fail=1; }
grep -q '<licenses>' "$pom" && grep -q '<developers>' "$pom" && grep -q '<scm>' "$pom" || { echo "error: $pom lacks licenses, developers or scm" >&2; fail=1; }
if ! grep -q '<packaging>pom</packaging>' "$pom"; then
[[ -e "$dir/$base-javadoc.jar" ]] || { echo "error: $art has no javadoc jar" >&2; fail=1; }
[[ -e "$dir/$base-sources.jar" ]] || { echo "error: $art has no sources jar" >&2; fail=1; }
fi
done < <(find "$staging" -name '*.pom')
# An AAR must carry the native libraries of this pythonVersion only. A Copy-staged jniLibs tree once
# kept libpython3.14.so beside libpython3.15.so after a version bump. libpython3.so (the stable-ABI
# stub) carries no minor version and is allowed.
py_mm="$(sed -nE 's/^pythonVersion=([0-9]+\.[0-9]+).*$/\1/p' gradle.properties)"
while IFS= read -r aar; do
stale="$(unzip -Z1 "$aar" | grep -E '(^|/)lib(multiplatform_)?python[0-9]+\.[0-9]+[^/]*\.so$' | grep -vE "(^|/)lib(multiplatform_)?python${py_mm//./\\.}(t)?\.so$" || true)"
[[ -z "$stale" ]] || { echo "error: $aar carries native libraries for another python than $py_mm:" >&2; echo "$stale" >&2; fail=1; }
done < <(find "$staging" -name '*.aar')
if $signed; then
while IFS= read -r f; do
case "$f" in *.asc|*.md5|*.sha1|*.sha256|*.sha512) continue ;; esac
[[ -e "$f.asc" ]] || { echo "error: $f is not signed" >&2; fail=1; continue; }
GNUPGHOME="$verify_home" gpg --batch --quiet --verify "$f.asc" "$f" 2>/dev/null || { echo "error: bad signature on $f" >&2; fail=1; }
done < <(find "$staging" -type f -not -name 'maven-metadata*')
else
echo "warning: no signing key, the bundle is unsigned and Central will refuse it" >&2
fi
(( fail == 0 )) || exit 1

echo "== left out of the bundle (not built on this machine)"
grep -h "CENTRAL-SKIPPED" "$root/.cache/central-gradle.log" || echo "(none)"
echo "== coordinates in the bundle"
find "$staging" -name '*.pom' | while IFS= read -r pom; do
rel="${pom#"$staging"/}"; ver="$(basename "$(dirname "$rel")")"; art="$(basename "$(dirname "$(dirname "$rel")")")"
grp="$(dirname "$(dirname "$(dirname "$rel")")" | tr / .)"
echo "$grp:$art:$ver"
done | sort

mkdir -p "$(dirname "$out")"
out="$(cd "$(dirname "$out")" && pwd)/$(basename "$out")"
rm -f "$out"
(cd "$staging" && zip -qr "$out" . -x 'maven-metadata*' '*/maven-metadata*')
echo "== bundle $out ($(find "$staging" -type f | wc -l | tr -d ' ') files)"
68 changes: 68 additions & 0 deletions .github/scripts/release/central-upload.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#!/usr/bin/env bash
# Uploads a bundle made by central_bundle.py to the Sonatype Central Portal and waits for its
# validation.
#
# Usage: central-upload.sh <bundle.zip> <deployment name> [USER_MANAGED|AUTOMATIC]
#
# Reads CENTRAL_TOKEN_USERNAME and CENTRAL_TOKEN_PASSWORD, the two halves of a Central Portal
# user token (central.sonatype.com, View Account, Generate User Token). The Portal API takes
# them as a bearer token of base64("<username>:<password>").
#
# USER_MANAGED (the default) stops after validation: the deployment waits in the Portal under
# Deployments until someone presses Publish or Drop, so a person looks at it before it becomes
# permanent. AUTOMATIC publishes as soon as validation passes. Either way nothing published to
# Central can be changed or removed afterwards.
#
# Exits 0 when the deployment is VALIDATED (USER_MANAGED) or PUBLISHING/PUBLISHED (AUTOMATIC),
# 1 when it FAILED, printing the Portal's errors, and 2 on a usage or network error.
set -euo pipefail

API="https://central.sonatype.com/api/v1/publisher"

bundle="${1:?usage: central-upload.sh <bundle.zip> <deployment name> [USER_MANAGED|AUTOMATIC]}"
name="${2:?usage: central-upload.sh <bundle.zip> <deployment name> [USER_MANAGED|AUTOMATIC]}"
type="${3:-USER_MANAGED}"
case "$type" in USER_MANAGED|AUTOMATIC) ;; *) echo "error: publishing type '$type'" >&2; exit 2 ;; esac
[[ -s "$bundle" ]] || { echo "error: no bundle at $bundle" >&2; exit 2; }
[[ -n "${CENTRAL_TOKEN_USERNAME:-}" && -n "${CENTRAL_TOKEN_PASSWORD:-}" ]] || {
echo "error: CENTRAL_TOKEN_USERNAME and CENTRAL_TOKEN_PASSWORD must hold a Central Portal user token" >&2
exit 2
}

token="$(printf '%s:%s' "$CENTRAL_TOKEN_USERNAME" "$CENTRAL_TOKEN_PASSWORD" | base64 | tr -d '\n')"
auth="Authorization: Bearer $token"

encoded_name="$(python3 -I -c 'import sys, urllib.parse; print(urllib.parse.quote(sys.argv[1]))' "$name")"
echo "==> uploading $bundle as '$name' ($type)"
id="$(curl --fail-with-body --silent --show-error --retry 3 \
--header "$auth" \
--form "bundle=@$bundle" \
"$API/upload?publishingType=$type&name=$encoded_name")"
echo "deployment $id"

# Validation of a large bundle takes minutes; give it an hour.
for _ in $(seq 1 120); do
status="$(curl --fail-with-body --silent --show-error --retry 3 --request POST \
--header "$auth" "$API/status?id=$id")"
state="$(python3 -I -c 'import json, sys; print(json.load(sys.stdin)["deploymentState"])' <<< "$status")"
echo "state $state"
case "$state" in
VALIDATED)
if [[ "$type" == USER_MANAGED ]]; then
echo "validated; publish or drop it at https://central.sonatype.com/publishing/deployments"
exit 0
fi
;;
PUBLISHING|PUBLISHED)
echo "publishing; it appears on https://repo1.maven.org/maven2/org/thisisthepy/ within about 30 minutes"
exit 0
;;
FAILED)
python3 -I -c 'import json, sys; print(json.dumps(json.load(sys.stdin).get("errors"), indent=2))' <<< "$status" >&2
exit 1
;;
esac
sleep 30
done
echo "error: deployment $id is still $state after an hour; see https://central.sonatype.com/publishing/deployments" >&2
exit 2
Loading