vmware-labs / webassembly-language-runtimes

Wasm Language Runtimes provides popular language runtimes (Ruby, Python, …) precompiled to WebAssembly that are tested for compatibility and kept up to date when new versions of upstream languages are released
Apache License 2.0
327 stars 27 forks source link

feat: Add libs/bzip2 to WLR #95

Closed assambar closed 1 year ago

assambar commented 1 year ago

This only builds the library. The accompanying binaries used signals and file ownership, which are not available on WASI.

Here is a sample release - https://github.com/assambar/webassembly-language-runtimes/releases/tag/libs%2Fbzip2%2F1.0.8%2B20230424-ffa3f41

Also, managed to build python with this and test it

wasmtime --mapdir /::$(pwd) bin/python.wasm
Python 3.11.3 (tags/v3.11.3:f3909b8, Apr 24 2023, 11:57:12) [Clang 15.0.7 ] on wasi
Type "help", "copyright", "credits" or "license" for more information.
>>> import bz2

>>> dir(bz2)
['BZ2Compressor', 'BZ2Decompressor', 'BZ2File', '_MODE_CLOSED', '_MODE_READ', '_MODE_WRITE', '__all__', '__author__', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', '_builtin_open', '_compression', 'compress', 'decompress', 'io', 'open', 'os']

>>> bz2.compress(bytes('hello there', 'utf-8'))
b'BZh91AY&SY\xe0\xed\xb01\x00\x00\x02\x11\x80@\x00\x02D\x94\x00 \x001\x0c\x00\xd3G\xa2\x10Eu;\xe2\xeeH\xa7\n\x12\x1c\x1d\xb6\x06 '

>>> cc = bz2.compress(bytes('hello there', 'utf-8'))

>>> bz2.decompress(cc)
b'hello there'