sagemathinc / cowasm-python

CoWasm-Python: WebAssembly Python for Servers and Browsers
6 stars 0 forks source link

the zipfile cpython module does not work #4

Open williamstein opened 2 years ago

williamstein commented 2 years ago

It fails all tests in the test suite, and trying to use zipfile to make a simple zip file results in a broken empty zip.

I'm extra motivated to fix this so that the asset bundling code for the standard cpython library can run as 100% WASM, rather than having to use python-native.

williamstein commented 1 year ago

UPDATE. Right now a lot of tests pass, but also many fail. Unzip does seem to work.

Here is a simple example illustrating that creating a zip file is broken as before. The size of the entry is wrong.

~/cowasm/packages/cpython$ python-wasm
Python 3.11.0 (main, Oct 27 2022, 10:03:11) [Clang 15.0.3 (git@github.com:ziglang/zig-bootstrap.git 0ce789d0f7a4d89fdc4d9571 on wasi
Type "help", "copyright", "credits" or "license" for more information.
>>> import zipfile; zipfile.ZipFile('spam.zip', 'w').write('README.md')
>>> ^D
~/cowasm/packages/cpython$ ls -l spam.zip
-rw-r--r--  1 wstein  staff  1896 Oct 30 14:16 spam.zip
~/cowasm/packages/cpython$ mkdir x
~/cowasm/packages/cpython$ cd x
~/cowasm/packages/cpython/x$ unzip ../spam.zip 
Archive:  ../spam.zip
README.md:  ucsize 1780 <> csize 0 for STORED entry
         continuing with "compressed" size value
 extracting: README.md               
~/cowasm/packages/cpython/x$ more README.md 
~/cowasm/packages/cpython/x$ 
~/cowasm/packages/cpython/x$ ls -l README.md 
-rwx------  1 wstein  staff  0 Sep 20 21:26 README.md
~/cowasm/packages/cpython/x$