From 06046233a536abf3ed3c3bac320575bdbf6c5d9b Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Tue, 9 Jun 2026 09:24:59 -0600 Subject: [PATCH] remove `cpython` submodule; download tarball in `build.rs` instead This should make it easier to publish this crate to crates.io without including a full copy of CPython. --- .gitmodules | 3 --- build.rs | 17 ++++++++++++++++- cpython | 1 - 3 files changed, 16 insertions(+), 5 deletions(-) delete mode 100644 .gitmodules delete mode 160000 cpython diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index b668272a..00000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "cpython"] - path = cpython - url = https://github.com/dicej/cpython diff --git a/build.rs b/build.rs index da3faac1..a6d9d6da 100644 --- a/build.rs +++ b/build.rs @@ -36,6 +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_TARBALL_URL: &str = "https://github.com/dicej/cpython/tarball/v3.14.0-wasi-sdk-30"; +const CPYTHON_TARBALL_BASE_DIR: &str = "dicej-cpython-0e13686"; + fn main() -> Result<()> { println!("cargo:rerun-if-changed=build.rs"); @@ -290,7 +295,17 @@ fn add(builder: &mut Builder, root: &Path, path: &Path) -> Result<() } fn maybe_make_cpython(repo_dir: &Path, wasi_sdk: &Path) -> Result<()> { - let cpython_wasi_dir = repo_dir.join("cpython/builddir/wasi"); + let cpython_dir = repo_dir.join("cpython"); + if !cpython_dir.exists() { + let url = &env::var("CPYTHON_TARBALL_URL").unwrap_or_else(|_| CPYTHON_TARBALL_URL.into()); + let base_dir = &env::var_os("CPYTHON_TARBALL_BASE_DIR") + .unwrap_or_else(|| CPYTHON_TARBALL_BASE_DIR.into()); + println!("cargo:warning=downloading CPython source code from {url}..."); + fetch_extract(url, repo_dir)?; + fs::rename(repo_dir.join(base_dir), &cpython_dir)?; + } + + let cpython_wasi_dir = cpython_dir.join("builddir/wasi"); if !cpython_wasi_dir.join("libpython3.14.so").exists() { fs::create_dir_all(&cpython_wasi_dir)?; if !cpython_wasi_dir.join("libpython3.14.a").exists() { diff --git a/cpython b/cpython deleted file mode 160000 index 0e13686d..00000000 --- a/cpython +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 0e13686da8bb881b059d35e23c32bcd2e6440099