Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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: 7 additions & 7 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
matrix:
config:
- {
os: "ubuntu-24.04",
os: "ubuntu-latest",
arch: "amd64",
maturin_target: "x86_64",
wasiSDK: "x86_64-linux",
Expand All @@ -36,7 +36,7 @@ jobs:
targetDir: "target/release",
}
- {
os: "ubuntu-24.04",
os: "ubuntu-latest",
arch: "aarch64",
maturin_target: "aarch64",
wasiSDK: "x86_64-linux",
Expand Down Expand Up @@ -83,15 +83,15 @@ jobs:

- uses: actions/setup-python@v5
with:
python-version: "3.14.0"
python-version: "3.15"

- name: Install latest Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: wasm32-wasip2 wasm32-wasip3 ${{ matrix.config.target }}

- uses: Swatinem/rust-cache@v2
if: matrix.config.os == 'ubuntu-24.04' && matrix.config.arch == 'amd64'
if: matrix.config.os == 'ubuntu-latest' && matrix.config.arch == 'amd64'
with:
shared-key: "rust-cache-${{ hashFiles('./Cargo.lock') }}"
cache-on-failure: "false"
Expand Down Expand Up @@ -166,7 +166,7 @@ jobs:

checksums:
name: Generate checksums
runs-on: ubuntu-24.04
runs-on: ubuntu-latest
needs: release
steps:
- name: Set the release version (tag)
Expand Down Expand Up @@ -204,7 +204,7 @@ jobs:

sdist:
name: Build Python sdist
runs-on: ubuntu-24.04
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -226,7 +226,7 @@ jobs:
name: Update canary release
needs: [checksums, sdist]
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-24.04
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
fail-fast: false
matrix:
config:
- { os: "ubuntu-24.04", wasiSDK: "x86_64-linux" }
- { os: "ubuntu-latest", wasiSDK: "x86_64-linux" }
- { os: "macos-latest", wasiSDK: "arm64-macos" }
- { os: "windows-latest", wasiSDK: "x86_64-windows" }
runs-on: ${{ matrix.config.os }}
Expand Down Expand Up @@ -53,7 +53,7 @@ jobs:

- uses: actions/setup-python@v5
with:
python-version: "3.14.0"
python-version: "3.15"

- name: Test
shell: bash
Expand Down
25 changes: 12 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ wit-component = "0.258.0"
wasmparser = "0.258.0"
indexmap = "2.6.0"
heck = "0.5.0"
pyo3 = { version = "0.28.3", features = [
pyo3 = { version = "0.30.1", features = [
"abi3-py39",
"extension-module",
], optional = true }
Expand Down
2 changes: 1 addition & 1 deletion alt-build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ fn main() {
"libc.so.zst",
"libcomponentize_py_runtime_async.so.zst",
"libcomponentize_py_runtime_sync.so.zst",
"libpython3.14.so.zst",
"libpython3.15.so.zst",
"libwasi-emulated-getpid.so.zst",
"libwasi-emulated-mman.so.zst",
"libwasi-emulated-process-clocks.so.zst",
Expand Down
37 changes: 19 additions & 18 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,11 @@ const CLANG_EXECUTABLE: &str = "clang.exe";
#[cfg(not(target_os = "windows"))]
const CLANG_EXECUTABLE: &str = "clang";

// TODO: switch to upstream release per
// https://github.com/bytecodealliance/componentize-py/issues/215
const CPYTHON_SOURCE_TARBALL_URL: &str =
"https://github.com/dicej/cpython/tarball/v3.14.0-wasi-sdk-34-v2";
const CPYTHON_SOURCE_TARBALL_BASE_DIR: &str = "dicej-cpython-ff50203";
"https://www.python.org/ftp/python/3.15.2/Python-3.15.2.tgz";
const CPYTHON_SOURCE_TARBALL_BASE_DIR: &str = "Python-3.15.2";

const CPYTHON_BINARY_TARBALL_URL: &str = "https://github.com/dicej/cpython/releases/download/v3.14.0-wasi-sdk-34-v2/cpython-v3.14.0-wasi-sdk-34-v2.tar.zst";
const CPYTHON_BINARY_TARBALL_URL: &str = "https://github.com/dicej/cpython/releases/download/v3.15.2-wasi-sdk-34/cpython-v3.15.2-wasi-sdk-34.tar.zst";

static TARGETS: &[&str] = &["wasip2", "wasip3"];

Expand Down Expand Up @@ -70,7 +68,7 @@ fn stubs_for_clippy(out_dir: &Path) -> Result<()> {

let libraries = [
"libcomponentize_py_runtime.so.zst",
"libpython3.14.so.zst",
"libpython3.15.so.zst",
"libc.so.zst",
"threads/libc.so.zst",
"libwasi-emulated-mman.so.zst",
Expand Down Expand Up @@ -234,10 +232,10 @@ fn package_all_the_things(out_dir: &Path) -> Result<()> {
true,
)?;

compress(&cpython_wasi_dir, "libpython3.14.so", &library_dir, true)?;
compress(&cpython_wasi_dir, "libpython3.15.so", &library_dir, true)?;
}

let path = repo_dir.join("cpython/builddir/wasip2/install/lib/python3.14");
let path = repo_dir.join("cpython/builddir/wasip2/install/lib/python3.15");

if path.exists() {
let mut builder = Builder::new(Encoder::new(
Expand Down Expand Up @@ -348,9 +346,9 @@ fn maybe_make_cpython(target: &str, repo_dir: &Path, wasi_sdk: &Path) -> Result<
}

let cpython_wasi_dir = cpython_dir.join("builddir").join(target);
if !cpython_wasi_dir.join("libpython3.14.so").exists() {
if !cpython_wasi_dir.join("libpython3.15.so").exists() {
fs::create_dir_all(&cpython_wasi_dir)?;
if !cpython_wasi_dir.join("libpython3.14.a").exists() {
if !cpython_wasi_dir.join("libpython3.15.a").exists() {
let cpython_native_dir = repo_dir.join("cpython/builddir/build");
if !cpython_native_dir.join(PYTHON_EXECUTABLE).exists() {
fs::create_dir_all(&cpython_native_dir)?;
Expand Down Expand Up @@ -385,8 +383,9 @@ fn maybe_make_cpython(target: &str, repo_dir: &Path, wasi_sdk: &Path) -> Result<
run(Command::new("../../Tools/wasm/wasi-env")
.env(
"CONFIG_SITE",
"../../Tools/wasm/wasi/config.site-wasm32-wasi",
"../../Platforms/WASI/config.site-wasm32-wasi",
)
.env("HOSTRUNNER", "wasmtime")
.env(
"CFLAGS",
format!("--target=wasm32-{target} -fPIC -I{dir}/deps/include"),
Expand All @@ -406,6 +405,8 @@ fn maybe_make_cpython(target: &str, repo_dir: &Path, wasi_sdk: &Path) -> Result<
&format!("--prefix={dir}/install"),
"--disable-test-modules",
"--enable-ipv6",
"--enable-wasm-dynamic-linking",
"--without-system-libmpdec",
]))?;

// Write Modules/Setup.local to force-enable _sqlite3
Expand All @@ -417,14 +418,14 @@ fn maybe_make_cpython(target: &str, repo_dir: &Path, wasi_sdk: &Path) -> Result<
.args(["build_all", "install"]))?;
}

// Link libpython3.14.so - now includes libsqlite3.a
// Link libpython3.15.so - now includes libsqlite3.a
run(Command::new(wasi_sdk.join("bin/clang"))
.arg(format!("--target=wasm32-{target}"))
.arg("-shared")
.arg("-o")
.arg(cpython_wasi_dir.join("libpython3.14.so"))
.arg(cpython_wasi_dir.join("libpython3.15.so"))
.arg("-Wl,--whole-archive")
.arg(cpython_wasi_dir.join("libpython3.14.a"))
.arg(cpython_wasi_dir.join("libpython3.15.a"))
.arg("-Wl,--no-whole-archive")
.arg(cpython_wasi_dir.join("Modules/_hacl/libHacl_HMAC.a"))
.arg(cpython_wasi_dir.join("Modules/_hacl/libHacl_Hash_BLAKE2.a"))
Expand Down Expand Up @@ -454,7 +455,7 @@ fn write_setup_local(cpython_wasi_dir: &Path) -> Result<()> {
let deps_dir = cpython_wasi_dir.join("deps");

// The _sqlite3 module source files (relative to Modules/)
// These are the files that make up the _sqlite3 extension in CPython 3.14
// These are the files that make up the _sqlite3 extension in CPython 3.15
// Note: blob.c is required - it defines pysqlite_close_all_blobs and pysqlite_blob_setup_types
let include_dir = deps_dir.join("include");
let lib_dir = deps_dir.join("lib");
Expand Down Expand Up @@ -569,7 +570,7 @@ fn make_runtime(
-Clink-args=-Wl,--export-if-defined=__wasm_library_tls_info \
-Clink-args=-shared \
-Clink-args=-L{} \
-Clink-args=-lpython3.14 \
-Clink-args=-lpython3.15 \
-Clink-self-contained=n",
cpython_wasi_dir.to_str().unwrap()
),
Expand Down Expand Up @@ -604,15 +605,15 @@ fn make_runtime(
}

fn fetch_extract_gzip(url: &str, out_dir: &Path) -> Result<()> {
let response = reqwest::blocking::get(url)?;
let response = reqwest::blocking::get(url)?.error_for_status()?;
let decoder = flate2::read::GzDecoder::new(response);
let mut archive = tar::Archive::new(decoder);
archive.unpack(out_dir)?;
Ok(())
}

fn fetch_extract_zstd(url: &str, out_dir: &Path) -> Result<()> {
let response = reqwest::blocking::get(url)?;
let response = reqwest::blocking::get(url)?.error_for_status()?;
let decoder = zstd::Decoder::new(response)?;
let mut archive = tar::Archive::new(decoder);
archive.unpack(out_dir)?;
Expand Down
4 changes: 2 additions & 2 deletions examples/matrix-math/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ https://github.com/bytecodealliance/wasmtime/releases/tag/v38.0.0.
```
cargo install --version 38.0.0 wasmtime-cli
pip install componentize-py==0.25.0
curl -OL https://github.com/dicej/wasi-wheels/releases/download/v0.0.2/numpy-wasi.tar.gz
curl -OL https://github.com/dicej/wasi-wheels/releases/download/v0.0.3/numpy-wasi.tar.gz
tar xf numpy-wasi.tar.gz
```

## Running the demo

```
componentize-py -d ../../wit -w matrix-math componentize app -o matrix-math.wasm
componentize-py -d ../../wit -w matrix-math componentize --target wasm32-wasip3 app -o matrix-math.wasm
wasmtime run matrix-math.wasm '[[1, 2], [4, 5], [6, 7]]' '[[1, 2, 3], [4, 5, 6]]'
```

Expand Down
4 changes: 2 additions & 2 deletions pyo3-config.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
implementation=CPython
version=3.14
version=3.15
shared=true
abi3=false
lib_name=python3.14
lib_name=python3.15
pointer_width=32
build_flags=
suppress_build_script_link_lines=false
2 changes: 1 addition & 1 deletion runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ crate-type = ["cdylib"]
[dependencies]
anyhow = "1.0.91"
once_cell = "1.20.2"
pyo3 = { version="0.28.3", features = ["abi3-py312", "num-bigint"] }
pyo3 = { version = "0.30.1", features = ["abi3-py312", "num-bigint"] }
num-bigint = "0.4.6"
wit-bindgen = { version = "0.61.0", default-features = false, features = ["macros", "realloc", "async"] }
wit-dylib-ffi = { git = "https://github.com/bytecodealliance/wasm-tools", tag = "v1.258.0", features = ["async-raw"] }
Expand Down
4 changes: 2 additions & 2 deletions runtime/pyo3-config-clippy.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
implementation=CPython
version=3.14
version=3.15
shared=false
abi3=false
lib_name=python3.14
lib_name=python3.15
pointer_width=64
build_flags=
suppress_build_script_link_lines=false
10 changes: 5 additions & 5 deletions src/prelink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use crate::{
ComponentizePyConfig, ConfigContext, Library, Multithreading, RawComponentizePyConfig, Target,
};

static NATIVE_EXTENSION_SUFFIXES: &[&str] = &[".cpython-314-wasm32-wasi.so", ".abi3.so"];
static NATIVE_EXTENSION_SUFFIXES: &[&str] = &[".cpython-315-wasm32-wasi.so", ".abi3.so"];

/// Check if a file starts with the WASM magic bytes (`\0asm`).
fn is_wasm_file(path: &Path) -> bool {
Expand Down Expand Up @@ -71,10 +71,10 @@ pub fn bundled_libraries(target: Target) -> Result<Vec<Library>> {
dl_openable: false,
},
Library {
name: "libpython3.14.so".into(),
name: "libpython3.15.so".into(),
module: zstd::decode_all(Cursor::new(include_bytes!(concat!(
env!("OUT_DIR"),
"/wasip2/libpython3.14.so.zst"
"/wasip2/libpython3.15.so.zst"
))))?,
dl_openable: false,
},
Expand Down Expand Up @@ -153,10 +153,10 @@ pub fn bundled_libraries(target: Target) -> Result<Vec<Library>> {
dl_openable: false,
},
Library {
name: "libpython3.14.so".into(),
name: "libpython3.15.so".into(),
module: zstd::decode_all(Cursor::new(include_bytes!(concat!(
env!("OUT_DIR"),
"/wasip3/libpython3.14.so.zst"
"/wasip3/libpython3.15.so.zst"
))))?,
dl_openable: false,
},
Expand Down
4 changes: 3 additions & 1 deletion tests/componentize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,8 @@ fn matrix_math_example() -> anyhow::Result<()> {
"-w",
"matrix-math",
"componentize",
"--target",
"wasm32-wasip3",
"app",
"-o",
"matrix-math.wasm",
Expand Down Expand Up @@ -466,7 +468,7 @@ fn venv_path(path: &Path) -> PathBuf {

fn install_numpy(path: &Path) -> anyhow::Result<()> {
let bytes = reqwest::blocking::get(
"https://github.com/dicej/wasi-wheels/releases/download/v0.0.2/numpy-wasi.tar.gz",
"https://github.com/dicej/wasi-wheels/releases/download/v0.0.3/numpy-wasi.tar.gz",
)?
.error_for_status()?
.bytes()?;
Expand Down
Loading