-
Notifications
You must be signed in to change notification settings - Fork 219
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Running in a browser with Pyodide #550
Comments
Another constraint I forgot to mention is that Javascript APIs only allow fetching text files synchronously, while binary files need to be fetched async in the main thread (or in a webworker where request can be sync). I'm not sure if you have a lot if binary files in the API of it's mostly text/json etc based. |
Thanks for the mention. The goal of the
This issue is solved in latest version of pyodide-http. I added an example of fetching binary data in the main thread here: https://github.com/koenvo/pyodide-http/blob/main/tests/pyscript.html . This is solved here: https://github.com/koenvo/pyodide-http/blob/main/pyodide_http/_core.py#L47 A proper way to solve fetching binary data in the main thread is by using |
Thank you for helping! there has been a bunch of internal discussion at the Internet Archive about how to work with pyodide and javascript in general (the async issue and requests). |
Hi! I tried to modify an example @jjjake made a couple weeks back - now it works with networking. I haven't tested everything, but here is a demo: https://archive.org/~merlijn/pyia/pyodide-demo.html The main problem seems to be that the I haven't tried to perform any write actions, but it seems like this can work. I wrote this to stub out the call that sets the http adapter:
|
Following a discussion on Twitter, there was interest in seeing what it takes to run this package in the browser with Pyodide (which among other things would allow calling the Python API from JavaScript).
So for instance, if you try to install it from PyPI in the Pyodide REPL,
you would get an error about missing wheel for docopt, since Pyodide only supports installation from wheels currently. This can be worked around by installing the dependencies explicitly,
which is sufficient to import the package.
If you actually try to use it you would get an error when trying to make an HTTP request,
The error is
SSLError("Can\'t connect to HTTPS URL because the SSL module is not available.")
So the solution is either to,
I'm not familiar with the internetarchive Python package, from a cursory glance I would say that given that you use the requests API quite extensively, it would take some work to make it work in Pyodide with these alternative versions of requests (and probably improving one of those libraries) but it's not impossible.
Now as to whether this makes sense as a replacement for a JS library, hard to say as I don't know your use case well.
If you have any questions let me know.
The text was updated successfully, but these errors were encountered: