Open ItsCubeTime opened 2 years ago
Thanks for the feature request! We are going to give the community 60 days from when this issue was created to provide 7 π upvotes on the opening comment to gauge general interest in this idea. If there's enough upvotes then we will consider this feature request in our future planning. If there's unfortunately not enough upvotes then we will close this issue.
You can check out this extension from community: https://marketplace.visualstudio.com/items?itemName=HardeepSingh.pyscript
Thanks for the response & triage π I will try to link this around to get some attention on the request π
For others reading, the Pyscript extension linked only provides syntax coloring, it doesnt really interpret the code in any way. It also requires changing the language type of html documents to a new "pyscript" language type (which then will remove all VS Codes other html specific language features, like JS, Emmet, html, css (etc)).
My motivation for putting the feature request here under VS Code Python was as I believe it might make most sense to actually use the regular CPython interpreter to provide the intellisense features you normally would (and just have that interpret the snippets of Python in the html files), rather than try and construct a new language server from the ground up based on these new technologies (for the sake of easier maintenance & sparing development effort overall). Then use that in combination with some "fake python modules"/pyi files to provide autocompletion for Brython/PyScript specific libraries respectively.
Thank you to everyone who upvoted this issue! Since the community showed interest in this feature request we will leave this issue open as something to consider implementing at some point in the future.
We do encourage people to continue π the first/opening comment as it helps us prioritize our work based on what the community seems to want the most.
Brython & PyScript are projects that enable Python in modern browsers, the latter of which has gained a lot of attraction from the Python community recently.
They both work by enabling the use of Python directly in html files without the need of cross compilation.
To give you a taste, here are some examples:
Brython example:
Brython is a Python interpreter written in JavaScript, with similar execution speed to that of CPython itself. It enables complete access to the "DOM", enabling it to interact with existing HTML elements as well as create new ones, it offers full access to JS declared objects (allowing you to use JS libraries and frameworks directly with Python) and supports the vast majority of the CPython STD (where only modules that simply cant run in a browser is unavailable, like the OS module which requires direct access to the computers file system or running OS dependent pre-compiled code that must run outside of the browser).
Brython has neglible load times thanks to extremely small package sizes as well as runtime performance comparable to that of CPython on desktop, making the technology useable for simpler websites. In addition to this it supports the full language syntax of Python itself.
PyScript
Just like Brython, PyScript is also enabled by an interpreter, which in this case runs with the help of WebAssembly, just like Brython, PyScript supports the entire language syntax of Python leveraging the more advanced features of the language.
Unlike Brython ,PyScript comes with a package manager for installing libraries from Pypy.org, known as "micropip", making it really convenient to use 3rd party libraries also on the client side. However PyScript also has significantly longer load times than that of Brython, making the technology more suitable for applications where longer load times are acceptable to be able to make use of potentially larger 3rd party packages on the client in a more convenient fashion.
Help wanted!
Both Brython and PyScript have lots of potential, (the latter of which also has a fast growing community at this time) and are in need of a stable & reliable language extension that enable code highlighting & autocompletion, especially for when writing Python code directly in the HTML files. With this feature request Im hoping to see support for Python in .html files (similar to that of JS in html files) in a way thats compatable with both projects as well as auto completion for project specific language features & libraries that both projects implement to allow for interoperability with common browser features (something that can probably be solved to a large extent with the help of "fake modules" or pyi files). Due to both projects closely replicating the behaviour of the CPython interpreter I can see it being viable to use existing language servers like PyLance to take care of most of he heavy lifting by simply enabling it to read relevant sections of the html files.
They are both fantastic efforts overall. Im here on hopes that the maintainers of this repo would find the projects interesting enough to add some form of support for them.
I can definetely see a possibility for community collaboration to make this a reality considering that both of these projects are to a large extent driven by open source contributors. I myself would gladly help contributing with CPython compatible pyi files for instance if we were to go down such a route.
Thanks for reading, have a nice day π