-
-
Notifications
You must be signed in to change notification settings - Fork 36
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
Supporting JS/webgpu as a backend for e.g. PyScript #407
Comments
I briefly played with PyScipt and webgpu yesterday, and have some more insights into what's needed. Added notes in the top post. |
We could consider creating a none-any wheel that packs all the binaries for all platforms... But it seems like a big concession |
I wonder if we can create |
Hi Almar. I'm interested in contributing towards making wgpu-py usable inside pyodide. (which I think would make it work inside PyScript too) I have to start somewhere, so decided to look into this question first. Looking at the source code for micropip, it uses packaging.tags.sys_tags() to match against the allowed wheel names. Running that in the pyodide repl at https://pyodide.org/en/stable/console.html gives me:
The According to https://github.com/pypi/warehouse/blob/c6c4033477feca74aee226d9f3b27f445d1aa964/warehouse/forklift/legacy.py#L107PyPi only allows platform tags for windows, linux, macOS, or any This means that if you want to have the wheel installable with micropip inside pyodide from PyPi, the most specific you can get is This would still do the right thing in nearly all occasions, as it would prefer the more specific platform tag if available. The only gotcha is that Until there is official platform support for emscripten/wasm as a platform in PyPi, the only other option completely in your hands is building the wheel for emscripten in CI per release, and tell people to host it themselves or use a GitHub release url as the source to micro pip from. Also a very acceptable option in my opinion. I would not be surprised if the pyodide team would be happy enough to include it as part of their distribution when mature enough as it should be a very small python only wheel. They have a lot of infrastructure for this sort of thing already. |
For the async issue: Can we not implement the sync versions by calling the async javascript function, and immediately awaiting in using pyodide's javascript interop/marshalling? I haven't made my way through the entire spec yet, but I haven't come across anything that requires an action to happen in between an async method being called and it being resolved. |
Implementing the js canvas should be pretty trivial using https://pyodide.org/en/stable/usage/api/js-api.html#js-api-pyodide-canvas |
any progression on this? |
From our end this does not have priority. Although in the process of stabilizing/finalizing the API, we are also thinking about #391, which is (oddly enough) a crucial part to enable the path to the browser. |
With PyScript most of wgpu should be runnable in a browser. If we can translate out API to WebGPU calls, people can use WebGPU via Python in a browser, which seems like a pretty big thing!
Since we follow the WebGPU IDL spec quite closely, this should not be that hard, though there are some cases to take into account.
I briefly looked into this. Some hurdles to take are:
none-any.whl
or awasm32.whl
. Even though we don't have any wasm in it, havingnone-any.whl
can accidentally be installed on a desktop and we don't want that.Future
in js, we cannot implement our sync version of the async method. I find this the scariest hurdle. (I hope I'm overlooking something that still allows us to do that.)jswebgpu
backend. Can partially autogenerate this. I don't expect this to be the hardest part.jscanvas
gui backend if we want to render stuff.Sub-goals to achieve:
wgpu
and displaying the version numer.The text was updated successfully, but these errors were encountered: