You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Not sure what your thoughts are on this. I was attempting to bump some version numbers within the pyodide source with the hope that doing so may fix another issue (as described over at #441 (comment)).
Digging into things I realised just how difficult it is to update pyodide's dependencies given its strong reliance on patching very specific versions. My thought was, in the long term, don't we want Web Assembly + CPython to be a first party supported build target by the upstream libraries and tools? To get this rolling I created the following issue within the CPython bug tracker, not sure if that's the best way to go about things:
I imagine it would look like having certain parts of Python switched off if the compilation target was Web Assembly with Emscripten (just as you have done with your patches). The patches applied upstream would just need to not interfere with normal building.
Thanks for setting this up. Pyodide has largely stalled (for me, at least), as it's no longer a day job thing. But I wholeheartedly support this effort to upstream as much as we can.
(The latest example of these problems is actually that a 3.7 point release updated a bunch of tests to use threading, which hadn't previously. Since pyodide doesn't support threading, that's a major lift that hasn't even been done...)
@SimonBiggs, sorry for cross posting but what i have to say is more for pyodide side of things.
You said on BPO :
With respect to blocking when running Python as WASM, I have found running the WebAssembly CPython within a webworker and signalling data back and
forth causes there to be no UI issues.
that sounds very promising since it would not need to change python code to run on wasm and worker loading is faster than on main thread.
But i guess some RPC and fast serialization is needed there (see https://brionv.com/log/wp-content/uploads/2019/05/Wasm-RPC-thoughts.pdf and rust way) is there a consensus on that ?
my thoughts :
i guess a pip module settings things up and providing a standard communication channel for everyone to use could justify fixing the few build problems without "supporting a new platform".
from my experience it would need :
a site.py patching the theading and some corner cases in stdlib
a tool to package source code ( or use some android tools )
a module for asynchronous RPC python side and javascript side.
access to native input, UI and 3D ( i think emscripten started to bridge that for workers but i don't know status yet).
My personnal view is there's no point in pushing patches if no one can discover/test/use them
i mean by that : get Python sources, a compiler, read some docs (1 page maybe 2) and pip install some helper module to get something running. Nothing more.
Upstreaming patches in CPython would be nice, but there isn't that many of those and most are about skipping imports (e.g. threading for now). I imagine if we wanted to do it, we would need first to update to python 3.8 to be closer to upstream.
The issue is that we are currently locked on Python 3.7 by a somewhat old version of scipy (that's working partially), possibly among other reasons. And updating scipy would likely be better with latest emscripten with upstream LLVM #476 . There were some attempts but they are time consuming, and someone would need to be quite motivated to do it.
i like pyodide but it's too complicated to get on rails with it.
Yes, how to simplify it is certainly a relevant question for long term maintainability of the project. Using latest emscripten and hopefully avoiding to build a patched LLVM would certainly be one step in the right direction.
The issue is that we are currently locked on Python 3.7 by a somewhat old version of scipy (that's working partially)
Due to the currently large file size of scipy, I personally drop it and all that depends on it from my pyodide installation anyway. If it was viable I would be in favour of temporarily dropping SciPy in favour of improving the maintainability of pyodide in the short term.
I think Jupyter kernel messaging would be a brilliant standard to build on here. An ideal end point would be running JupyterLab with a Python WASM kernel running within a web worker. See https://github.com/deathbeds/jyve for a proof of concept.
As someone who would hate to see the work on this project go to waste, I'd suggest that it's much more important to have pyodide as a supported upstream build target than it is for pyodide to support scipy, especially since its load time makes for a lacking user experience anyway.
And updating scipy would likely be better with latest emscripten with upstream LLVM #476 . There were some attempts but they are time consuming, and someone would need to be quite motivated to do it.
If finding a way to use the latest emscripten and upstream LLVM would motivate the current maintainers to pursue this I'd be more than happy to dedicate my time to it. I'd also be willing to try to accommodate the list of requirements @pmp-p described if I can get some pointers with the parts I don't know as well, or just generally to simplify pyodide's build and installation processes.
It'd be an enormous waste if this project simply fell too far behind upstream and the next team was left to start from scratch. Getting the major parts moved upstream would provide some satisfying closure.
I'd suggest that it's much more important to have pyodide as a supported upstream build target than it is for pyodide to support scipy, especially since its load time makes for a lacking user experience anyway.
Yes, I agree that the currently scipy experience is not great (due LAPACK size #240) and because it's so large it also takes a while to build, making iteration speed slows as well. Currently scikit-learn, and statsmodels depend on them. I agree we should have an option to build without those. I was imprecise, officially scipy 0.17 only supports python 3.5 but since python is mostly backward compatible it works (maybe with a few deprecation warnings) for python 3.7. So the same should apply to 3.8. I'll try to update the scipy version.
Anyway, even assuming we update to CPython master and get all cpython/patches/ upstreamed (again that are fairly small), that's not going to solve the long term maintenance issue IMO:
there is ~1k LoC Python in pyodide_build/ with all the package build mechanism. That's likely remain as a separate package, which is fine.
there is ~300 LoC of Makefiles to setup the environment
and then various patches for different projects (including emsdk at present).
How to go from the current situation to one where WASM is indeed a CPython build target and once installed, one could do say python-wasm -m pip install numpy (as one can currently do for say for PyPy) to get the corresponding packages built is not entirely clear to me. For one thing because we cannot build C-extensions inside WASM VM, so one still has to have a plain python to build packages.
So maybe python -m pyodide_build install numpy (without being called from inside of the pyodide Makefile) is more realistic. But then for this second use case, would wasm becoming an officially supported CPython immediately help? Yes, it would be possible to distribute CPython builds for WASM, but because one wouldn't be able to use it to install other packages with C extensions it would be of limited use in the context of pyodide.
Maybe just CPython build with pyodide + micropip to pull packages with pure python wheels is a valid use case, in particular to allow iterating faster with the build.
For the rest of the packages in pyodide we need to be able to use some package repository (e.g. PyPi or conda-forge) to avoid re-implementing our own dependency resolution etc. However, even assuming they support wasm target one day, they have no way re-build all the repository in one go which would be necessary with the quickly moving emscripten and other wasm related tools.
So it's a challenge. I have not been following closely lately, maybe other projects have been working on some of it.
@rth If the end goal were to have wasm as an upstream build target for CPython together with the ability to install pure-Python packages via micropip, is the only problem to solve the fact that pyodide is currently built using old and patched versions of emsdk and LLVM?
Not to say that it isn't unsatisfying for the packages with C extensions to be maintained separately, but at least in regard to the goal of bringing Python to the web I'd consider it to be an important milestone.
at least in regard to the goal of bringing Python to the web I'd consider it to be an important milestone.
yes and no, i feel more like "bringing CPython to pyodide", as my question suggested "are you sure you got the right Python for the job ?" : there are other Python flavour available on wasm and maybe more suited "for the web" (size/faster startup/vm preemption/easier codebase ...).
Constructor is a tool which allows constructing an installer for a collection of conda packages. It solves needed packages using user-provided specifications, and bundles those packages. It can currently create 3 kinds of installers, which are best thought of as delivery vehicles for the bundled packages. There are shell installers, MacOS .pkg installers, and Windows .exe installers. Each of these will create an environment on the end user's system that contains the specs you provided, along with any necessary dependencies. These installers are similar to the Anaconda and Miniconda installers, and indeed constructor is used to create those installers.
conda-pack is a command line tool for creating relocatable conda environments. This is useful for deploying code in a consistent environment, potentially in locations where python or conda isn't already installed.
work on this would generally be welcome if someone wanted to pick it up from where I left off or even start over. That said, I'm not working on this at present nor plan to.
Should add the LLVM toolchain in conda-forge already supports WebAssembly as a target and many things have been moving that way over the past few years.
I think we can close this. We are trying to upstream all patches that we can, in particular @dalcde has been doing a lot it for emscripten. It's a continuous process, so there is probably no need to keep a separate issue about it.
For the integration with conda, this should probably be discussed in a dedicated issue. There is #795
Activity
mdboom commentedon Apr 14, 2020
Thanks for setting this up. Pyodide has largely stalled (for me, at least), as it's no longer a day job thing. But I wholeheartedly support this effort to upstream as much as we can.
(The latest example of these problems is actually that a 3.7 point release updated a bunch of tests to use threading, which hadn't previously. Since pyodide doesn't support threading, that's a major lift that hasn't even been done...)
pmp-p commentedon Apr 14, 2020
Hi mdboom, SimonBiggs
@SimonBiggs, sorry for cross posting but what i have to say is more for pyodide side of things.
You said on BPO :
that sounds very promising since it would not need to change python code to run on wasm and worker loading is faster than on main thread.
But i guess some RPC and fast serialization is needed there (see https://brionv.com/log/wp-content/uploads/2019/05/Wasm-RPC-thoughts.pdf and rust way) is there a consensus on that ?
my thoughts :
i guess a pip module settings things up and providing a standard communication channel for everyone to use could justify fixing the few build problems without "supporting a new platform".
from my experience it would need :
It would sound a lot like the beeware - briefcase pipeline work ( thinking of wasm/wasi as another iOS or android special case ) https://beeware.org/project/projects/tools/briefcase/
My personnal view is there's no point in pushing patches if no one can discover/test/use them
i mean by that : get Python sources, a compiler, read some docs (1 page maybe 2) and pip install some helper module to get something running. Nothing more.
i like pyodide but it's too complicated to get on rails with it. Though i'm quite sure it can run Panda3D http://rdb.name/panda3d-webgl/editor.html or run some Brython samples https://brython.info/demo.html?lang=en
Side question : on the long term are you sure you got the right Python for the job ?
rth commentedon Apr 14, 2020
Upstreaming patches in CPython would be nice, but there isn't that many of those and most are about skipping imports (e.g. threading for now). I imagine if we wanted to do it, we would need first to update to python 3.8 to be closer to upstream.
The issue is that we are currently locked on Python 3.7 by a somewhat old version of scipy (that's working partially), possibly among other reasons. And updating scipy would likely be better with latest emscripten with upstream LLVM #476 . There were some attempts but they are time consuming, and someone would need to be quite motivated to do it.
Yes, how to simplify it is certainly a relevant question for long term maintainability of the project. Using latest emscripten and hopefully avoiding to build a patched LLVM would certainly be one step in the right direction.
SimonBiggs commentedon Apr 14, 2020
Due to the currently large file size of scipy, I personally drop it and all that depends on it from my pyodide installation anyway. If it was viable I would be in favour of temporarily dropping SciPy in favour of improving the maintainability of pyodide in the short term.
SimonBiggs commentedon Apr 14, 2020
I think Jupyter kernel messaging would be a brilliant standard to build on here. An ideal end point would be running JupyterLab with a Python WASM kernel running within a web worker. See https://github.com/deathbeds/jyve for a proof of concept.
eulertour commentedon Apr 15, 2020
As someone who would hate to see the work on this project go to waste, I'd suggest that it's much more important to have pyodide as a supported upstream build target than it is for pyodide to support scipy, especially since its load time makes for a lacking user experience anyway.
If finding a way to use the latest emscripten and upstream LLVM would motivate the current maintainers to pursue this I'd be more than happy to dedicate my time to it. I'd also be willing to try to accommodate the list of requirements @pmp-p described if I can get some pointers with the parts I don't know as well, or just generally to simplify pyodide's build and installation processes.
It'd be an enormous waste if this project simply fell too far behind upstream and the next team was left to start from scratch. Getting the major parts moved upstream would provide some satisfying closure.
rth commentedon Apr 15, 2020
Yes, I agree that the currently scipy experience is not great (due LAPACK size #240) and because it's so large it also takes a while to build, making iteration speed slows as well. Currently scikit-learn, and statsmodels depend on them. I agree we should have an option to build without those. I was imprecise, officially scipy 0.17 only supports python 3.5 but since python is mostly backward compatible it works (maybe with a few deprecation warnings) for python 3.7. So the same should apply to 3.8. I'll try to update the scipy version.
Anyway, even assuming we update to CPython master and get all cpython/patches/ upstreamed (again that are fairly small), that's not going to solve the long term maintenance issue IMO:
How to go from the current situation to one where WASM is indeed a CPython build target and once installed, one could do say
python-wasm -m pip install numpy(as one can currently do for say for PyPy) to get the corresponding packages built is not entirely clear to me. For one thing because we cannot build C-extensions inside WASM VM, so one still has to have a plain python to build packages.So maybe
python -m pyodide_build install numpy(without being called from inside of the pyodide Makefile) is more realistic. But then for this second use case, would wasm becoming an officially supported CPython immediately help? Yes, it would be possible to distribute CPython builds for WASM, but because one wouldn't be able to use it to install other packages with C extensions it would be of limited use in the context of pyodide.Maybe just CPython build with pyodide + micropip to pull packages with pure python wheels is a valid use case, in particular to allow iterating faster with the build.
For the rest of the packages in pyodide we need to be able to use some package repository (e.g. PyPi or conda-forge) to avoid re-implementing our own dependency resolution etc. However, even assuming they support wasm target one day, they have no way re-build all the repository in one go which would be necessary with the quickly moving emscripten and other wasm related tools.
So it's a challenge. I have not been following closely lately, maybe other projects have been working on some of it.
eulertour commentedon Apr 16, 2020
@rth If the end goal were to have wasm as an upstream build target for CPython together with the ability to install pure-Python packages via micropip, is the only problem to solve the fact that pyodide is currently built using old and patched versions of emsdk and LLVM?
Not to say that it isn't unsatisfying for the packages with C extensions to be maintained separately, but at least in regard to the goal of bringing Python to the web I'd consider it to be an important milestone.
pmp-p commentedon Apr 19, 2020
yes and no, i feel more like "bringing CPython to pyodide", as my question suggested "are you sure you got the right Python for the job ?" : there are other Python flavour available on wasm and maybe more suited "for the web" (size/faster startup/vm preemption/easier codebase ...).
if that can help anybody to bring pyodide to 3.8, i've setup a CI for both android and webassembly targeting CPython 3.8.2here https://github.com/pmp-p/pydk and relevant wasm patches are here https://github.com/pmp-p/pydk/tree/master/sources.wasm/Python-3.8.2
rth commentedon May 9, 2020
I have opened #646 with a list of ideas we could implement to reduce the size and load time of the main pyodide package in a minimal configuration.
Also #645 should allow optionally skipping the build of all larger scientific packages (and CLAPACK).
westurner commentedon Sep 26, 2020
re: conda-forge WASM build target, CPython WASM patches, pyodide conda package
Here's the conda-forge python-feedstock meta.yml:
[arm64]preprocessing selector[wasm]/[emscripten]/ ?[wasm]Here's the patch that added support for
[arm64]builds to conda-forge:"Initial Drone support"
Initial Drone support conda-forge/conda-smithy#1069
Add support for
[wasm]builds to conda-forgeAdditional resources:
https://conda-forge.org/docs/maintainer/infrastructure.html#compilers-and-runtimes
https://github.com/conda-forge/miniforge/blob/master/build_miniforge.sh
Adding a WebAssembly platform conda/conda#7619
https://github.com/conda/constructor
https://github.com/conda/conda-pack
Emscripten & WASI & POSIX emscripten-core/emscripten#9479
Add emscripten conda-forge/staged-recipes#2507
https://github.com/conda-forge/llvmdev-feedstock/blob/master/recipe/meta.yaml
https://github.com/conda-forge/llvmdev-feedstock/blob/master/recipe/build.sh
https://github.com/iodide-project/pyodide/blob/master/Makefile
build.sh->makerth commentedon Feb 12, 2021
I think we can close this. We are trying to upstream all patches that we can, in particular @dalcde has been doing a lot it for emscripten. It's a continuous process, so there is probably no need to keep a separate issue about it.
For the integration with conda, this should probably be discussed in a dedicated issue. There is #795