Comments (6)
I just had a wild idea: we could optionally iterate over all known modules during pre-initialization and import them one by one (skipping any not currently supported like ssl
). Not sure how much bloat that would add to the resulting component, but it would theoretically address this issue.
from componentize-py.
With no imports, cli.wasm
ended up being 33mb. After importing everything it was 43mb. Not too bad!
from componentize-py.
Yeah, that's not bad.
You probably already know this, but for anyone else reading: you can also import third-party packages (e.g. NumPy) the same way.
from componentize-py.
Thanks for reporting this, @kyleconroy. This sort of a duplicate of #23, but with a twist: wasmtime-py
can't currently handle composed components (i.e. components that contain subcomponents), which is what wasi-virt
generates, so the solution I proposed in that issue won't work until/unless wasmtime-py
gains support for subcomponents.
An alternative approach would be to modify the sandbox example to allow access to a host-provided filesystem via wasi:filesystem
, but then we hit another wasmtime-py
limitation: no support for WASI (i.e. the wasmtime-wasi
crate is only available for use in the Rust API for Wasmtime, not the Python one). It would certainly be possible to write a pure Python wasi:filesystem
implementation that works with wasmtime-py
, but it wouldn't be a quick task.
In short, we'd need to address this on both the componentize-py
and wasmtime-py
sides, and it will be a substantial amount of work. I don't expect I'll have time for it anytime soon, but I'd be happy to mentor anyone who wants to take a stab at it.
from componentize-py.
You know, I was thinking the same thing as a workaround. Just add an import for every known module in the standard library. I can try that out and see how big the component becomes.
from componentize-py.
BTW, wasm-tools strip -a
can reduce the component size quite a bit if desired.
from componentize-py.
Related Issues (20)
- pyo3_runtime.PanicException: internal error: entered unreachable code HOT 3
- Running component without WASI HOT 2
- Run MyPy on all test code and bindings HOT 1
- Running example HOT 3
- Question: Current types limitation HOT 6
- Matrix-math example - ImportError... HOT 4
- List errors which might be raised in function docstrings
- Make the types generated for WIT resources context managers
- feature: add zlib to cpython build HOT 1
- Generated component has dependency on wasi:cli/[email protected] HOT 14
- Create more actionable error for disallowed name for a Python module
- Broken http example: import error from poll_loop.py: StreamErrorClosed HOT 1
- Matrix-math example - no world named `matrix-math` in package HOT 4
- Unresolved symbols when building from source HOT 2
- Type checking fails when records are defined in a world with functions HOT 1
- Issue encountered when trying to execute app.wasm using wasmtime HOT 3
- ImportError with NumPy when running matrix_math example HOT 8
- Http example doesn't work with Wasmtime 21.0.1 HOT 3
- [bug] zlib support required by widely used python modules HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from componentize-py.