Skip to content

Commit d4aa24f

Browse files
committed
slim down module size by excluding unecessary files
Signed-off-by: Joel Dice <joel.dice@fermyon.com>
1 parent b15ae01 commit d4aa24f

3 files changed

Lines changed: 9 additions & 2 deletions

File tree

Makefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
.PHONY: build
2-
build: target/config.txt
2+
build: target/config.txt target/lib
33
PYO3_CONFIG_FILE=$$(pwd)/target/config.txt cargo build --release --target=wasm32-wasi
44
wasi-vfs/target/release/wasi-vfs pack target/wasm32-wasi/release/python_wasi.wasm \
5-
--mapdir lib::$$(pwd)/cpython/builddir/wasi/install/lib \
5+
--mapdir lib::$$(pwd)/target/lib \
66
-o target/wasm32-wasi/release/python-wasi-vfs.wasm
77
PYTHONPATH=/py wizer target/wasm32-wasi/release/python-wasi-vfs.wasm \
88
--inherit-env true --wasm-bulk-memory true --allow-wasi --dir py \
@@ -12,3 +12,7 @@ target/config.txt:
1212
mkdir -p target
1313
cp config.txt target
1414
echo "lib_dir=$$(pwd)/cpython/builddir/wasi" >> $@
15+
16+
target/lib:
17+
mkdir -p $@
18+
rsync -a --exclude='*.a' --exclude='*.pyc' --exclude='*.whl' cpython/builddir/wasi/install/lib/python3.11 $@

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ This is an experiment to build a Spin Python SDK using CPython, wasi-vfs, and Py
99
- [wasi-sdk](https://github.com/WebAssembly/wasi-sdk) v16 or later
1010
- [Wizer](https://github.com/bytecodealliance/wizer) v1.6.0 or later
1111
- [Spin](https://github.com/fermyon/spin)
12+
- [rsync](https://rsync.samba.org/) -- used at build time for copying files around; we could replace this with something more portable, if desired
1213

1314
## Building and Running
1415

src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ struct HttpRequest<'a> {
1818
method: &'a str,
1919
uri: &'a str,
2020
headers: Vec<(&'a str, &'a str)>,
21+
// todo: this should be a byte slice, but make sure it gets converted to/from Python correctly
2122
body: Option<&'a str>,
2223
}
2324

@@ -36,6 +37,7 @@ impl IntoPy<PyObject> for HttpRequest<'_> {
3637
struct HttpResponse {
3738
status: u16,
3839
headers: Vec<(String, String)>,
40+
// todo: this should be a byte slice, but make sure it gets converted to/from Python correctly
3941
body: Option<String>,
4042
}
4143

0 commit comments

Comments
 (0)