singlestore-labs / python-wasi

Utilities for building CPython for the WASI platform
Apache License 2.0
97 stars 14 forks source link

How can python-wasi support external dependencies #12

Closed LijieZhang1998 closed 1 year ago

LijieZhang1998 commented 1 year ago

Hi,

I'm trying to run a piece python code that imports pymongo to connect my mongodb. Do you know what I should do to support this dependency? For now I got the following error. I didn't install this dependency anywhere because I don't know where and how I can install it so wasi-python.wasm can load it. Noticed this part in Docker file to include lzma package. But I'm not sure how to deal with pymongo package. I'm pretty new to wasm/wasi. Any help is appreciated.

Traceback (most recent call last):
  File "//./testfiles/ping.py", line 1, in <module>
    from pymongo.mongo_client import MongoClient
ModuleNotFoundError: No module named 'pymongo'
kesmit13 commented 1 year ago

If it is a pure Python package, you could install it to a directory using the same version of Python on your desktop machine, map that directory into your Wasm instance, then add the directory to your Python path in the instance. However, in this case, it wouldn't work because this package requires networking. Wasm currently doesn't support networking since that breaks the security sandbox. There will likely be ways of supporting networking in the future.