Comments (22)
After weeks of busy routines I finally have the time to try to tinker with Nuitka and the Emscripten Compiler... And no avail, everything that needs the Python Runtime won't work (Nuitka, Cython, Pyrex, I only tried these 3).. But I found RPython, basicly it have a translator/transpiler that can translate/transpile a subset of python "staticly" to C without the Python runtime. By staticly means it can't be dynamic (one variable can only be one type, no lambda, only higher order functions, etc) and it surprisingly able to be compiled with emcc (Emscripten). Although the produced llvm give an error about unresolved symbol when executed in WebAssembly:
warning: unresolved symbol: pypy_debug_tracebacks
Even though I know this is Nuitka Github Repo but I want to ask for your help @kayhayen and any Pythonista who are fluent in C that came accross because I think this is the right idea to bring Python to the Web (performance wise). Compiling the full CPython or any other Python Runtime will make the download size very large and bringing many problems.
from nuitka.
Thanks for reporting. I do not mind reading good things about PyPy, which is behind RPython. I think it is good for what it does. I actually once contributed a small patch to it, a decade ago. :)
I am putting this to unsupported then, leaving the question tag, so people will find it.
from nuitka.
Although RPython will be the fastest subset of python for compilation, but it feels like it won't be that easy to target it to wasm. The current viable one is actually MicroPython, there are working POC for it
https://github.com/numworks/epsilon/tree/master/python
https://github.com/pmp-p/micropython-ports-wasm
But I am more interested in RPython performance wise, but if it is too complex to be targeted to wasm maybe we can search for another alternative like MicroPython.
from nuitka.
Nuitka depends on "libpython" to work. If you can load that, it's fine, but I doubt it.
from nuitka.
libpython is a C library right? isn't Webassembly compiles a LLVM compatible code (and its dependencies) to byte code? I want to try this
from nuitka.
@rafi16jan Go ahead, you are welcome.
from nuitka.
Meh, cannot assign you, but consider yourself in charge until you give up @rafi16jan
from nuitka.
Ok, I'll report
from nuitka.
Can you (or maybe the right question is, do you have time :D) to give us newbies guide/advice to debug this RPython and the C source it generated. We younglings aren't like you guys that can understand C the same way we understand Python. It's heaven and earth to us (maybe hell). We're generation that aren't used to compile things, unless it is java or .net haha
from nuitka.
Not enough time for Nuitka as it stands.
from nuitka.
Ok I understand
from nuitka.
Hm, rpython+wasm is an interesting option.
warning: unresolved symbol: pypy_debug_tracebacks
Try grepping the rpython/pypy source code for that function to see where it's defined and find out why it isn't being compiled/linked properly. From the name, I'm guessing you could replace it with an empty function with the same signature, at the cost of breaking tracebacks.
from nuitka.
@rafi16jan I know a bit of C, Iām willing to help.
from nuitka.
Maybe we can ask on the PyPy mailing list.
from nuitka.
@CrazyPython Nice, where do we start?
from nuitka.
@wolfv Sorry for tagging you hehe, how's your experience with the new MicroPython javascript port?
from nuitka.
It's quite straightforward nowadays to compile to webassembly. you just need to know which functions to export.
Nowadays you should also be able to find libpython compiled to webassembly. however, it will be much larger than micropython (which is the big advantage). MicroPython compiled is only ~200kb, so in the same range as modern JS frameworks.
from nuitka.
@wolfv Is there already a way to interact with DOM or WebAPIs? Because I ask another port to WASM what's the difference between his port and the official port, he promises that he will add DOM interaction and even asyncio support with requestAnimationFrame. Take a look at this
from nuitka.
Not related to Nuitka, but I have make an ES6 Module of the official MicroPython WASM port. https://www.npmjs.com/package/micropython
@appcypher @ids1024 @CrazyPython
from nuitka.
Nuitka depends on "libpython" to work. If you can load that, it's fine, but I doubt it.
@kayhayen libpython3.8.a is (now) easy to build with clang 10 ( emsdk tot-upstream ) and i did not find any problem running standard stdlib python code in repl.
https://pmp-p.github.io/python-next/test.html patches here https://github.com/pmp-p/pydk/tree/master/sources.em
If anyone would like to experiment Nuitka on that lib i'm ready to help ( i'm on gitter and freenode )
@rafi16jan i made the asyncio micropython DOM support compatible with cpython too with the same module see the test page above.
from nuitka.
@pmp-p @rafi16jan @wolfv @CrazyPython , i am a very experienced C/C++ programmer , i will be there for help for any C/C++ related things
from nuitka.
@pmp-p @rafi16jan @wolfv @CrazyPython , i am a very experienced C/C++ programmer , i will be there for help for any C/C++ related things
Great! Months ago I've successfully fork RPython to be able to compile to WASM. Please give any feedback here https://github.com/rafi16jan/rpython-wasm
I would like to see someone continue the work since I'm busy with other things right now, also pardon me if there's bad C code since I'm very bad at C and strong typed languages in general
from nuitka.
Related Issues (20)
- [BUG] --jobs options with negative values is not working on nuitka 2.4 HOT 3
- use onefile failed to run, how to check this error? HOT 1
- [Question] Does Nuitka support multiprocessing? (Yes) HOT 2
- [BUG] Can't import python native ssl module (ImportError) HOT 2
- Can't run the compiled spacy application: No module named 'spacy.lexeme' HOT 5
- cannot import gssapi library properly
- `anyio`'s `to_process.run_sync` breaks after compilation by nuitka HOT 3
- AttributeError: 'nuitka_resource_reader_files' object has no attribute 'suffix' HOT 2
- Multicore execution - Do Binaries compiled by Nuitka, run concurrently unlike Phyton? HOT 2
- Please add Anti injection to the Nutika exe to prevent dlls to be injected into it like pyshell and more HOT 2
- Nuitka Module Importing External Numba .so file
- Nuitka should test for requirements (like dependency tree walker) before starting build HOT 1
- Executable built from Nuitka running in free-threaded python binary results in GIL'ed executable binary
- Free-threaded Python Support (no-gil)
- Segmentation fault with keras. regression problem? 2.1.6 works but 2.4.5 has segmentation fault.
- No such file or directory. Compiling with nuitka and nicegui. sad_face.svg
- Compilng with MSVC Build Tools 14.41.34120, too much warning C4391: 'char _sat_sub_i8(char,char)': incorrect return type for intrinsic function, expected 'unsigned char' is occurred. in Windows. HOT 7
- Error after compiling with multiprocessing
- coremltools package gives fatal error on MacOS
- SCONS-linker crashes at linking stage with error UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe5 in position 184714: invalid continuation byte HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
š Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ššš
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ā¤ļø Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nuitka.