This is a follow-up of PR #806 and it's a big step forward towards solving issue #763. The basic idea is that at this stage I want to streamline the execution logic and make it as linear and easy to read/understand as possible. The diff is relatively big, but for the most part is just "shuffling code around". Svelte stores: the idea is to eventually kill of them, so that we can remove the dependency on svelte but also to avoid relying on so much global state, which makes things more complicated and error-prone (e.g., we have several issues related to using runtime when it's not ready yet). I killed addInitializer, addPostInitializer and the corresponding svelte stores tada. They are no longer needed since the relevant code is called directly from main.ts. I started to kill the usage of the runtimeLoaded svelte store: instead of relying on a global variable, I want to arrive at the point in which the runtime is passed as a parameter in all places where it's needed: pyscript.ts is now free of global state, but I couldn't kill it yet because it's used heavily by base.ts and pyrepl.ts. I will do it in another PR. Other misc changes: I added sanity checks (and corresponding tests!) which complain if you specify 0 or multiple runtimes. Currently we support having one and only one, so there is no point to pretend otherwise I modified the messages displayed by the loader, to be more informative from the user point of view.
PyScript
What is PyScript
Summary
PyScript is a framework that allows users to create rich Python applications in the browser using HTML's interface and the power of Pyodide, WASM, and modern web technologies.
To get started see the getting started tutorial.
For examples see here.
Longer Version
PyScript is a meta project that aims to combine multiple open technologies into a framework that allows users to create sophisticated browser applications with Python. It integrates seamlessly with the way the DOM works in the browser and allows users to add Python logic in a way that feels natural both to web and Python developers.
Try PyScript
To try PyScript, import the appropriate pyscript files into the <head> tag of your html page with:
<head>
<link rel="stylesheet" href="https://pyscript.net/latest/pyscript.css" />
<script defer src="https://pyscript.net/latest/pyscript.js"></script>
</head>
You can then use PyScript components in your html page. PyScript currently implements the following elements:
<py-script>: can be used to define python code that is executable within the web page. The element itself is not rendered to the page and is only used to add logic<py-repl>: creates a REPL component that is rendered to the page as a code editor and allows users to write executable code
Check out the the examples directory folder for more examples on how to use it, all you need to do is open them in Chrome.
How to Contribute
Read the contributing guide to learn about our development process, reporting bugs and improvements, creating issues and asking questions.
Resources
Notes
- This is an extremely experimental project, so expect things to break!
- PyScript has been only tested on Chrome at the moment.
Governance
The PyScript organization governance is documented in a separate repository.