* Fix#1899 - Expose pyscript.js_modules as module
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Fix#1899 - Make import as smooth as in polyscript
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* PyTerminal - expose the reference through the element
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* Fix make fmt changing Python files
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* add tests for select options
* add classes to support select and options management
* fix add methond and implement clear on options
* fix optionsproxy.add
* fix select.add method
* add test adding a second option to select
* add tests around adding options in multiple flavors
* add test to add an option by passing the option it wants to be added before
* complete test around adding options
* add select to add test on remove
* add tests and support for selected item
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Andrea Giammarchi <andrea.giammarchi@gmail.com>
* Fix broken links, and put community information at the top of our README.
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This MR shows errors and exit in these conditions:
* multiple `<py-config>` or `<mpy-config>` found on the page
* both `<py-config>` and `<script type="py" config="file.toml">` found on main
* different `<script type="py" config="a.toml">` and `<script type="py" config="b.toml">` configs found on main
* added a *py-editor* plugin based on *codemirror*
* use a `<script type="py-editor">` wrapper to bootstrap code
* tested that all is good via smoke-test in test/py-editor.html
* Patch js.document out of the box
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* Expose js_modules via pyscript module
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Improve the readme in two ways:
- remove the mention to <py-repl>, and shows a quick summary of the various ways of running Python code
- add a link to the google calendar which contains the community calls
* add tests to verify if we show an error banner when users load from latest
* add deprecation manager to take care of showing a notification in case script src is being loaded from latest
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* make sure deprecation warning also register onWorker
* restore tests for banner in worker
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* add a wait selector when testing banner since worker seems to take too long to render in CI
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Fix test_deprecate_loading_scripts_from_latest: I think that the
previous failure was because we actually TRIED to execute the js from
latest/core.js and it conflicted with our local copy.
But to trigger the warning is enough to have a script pointing to
pyscript.net/latest, there is no need to execute it: modify it with
type="ignore-me" and an URL which doesn't exist.
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Antonio Cuni <anto.cuni@gmail.com>
* bye bye when
* fix create to drop parent and actually pass the other arguments through
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* update types
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* Re-add CHANGELOG.md from the tip of "classic" into root of the repository. Tidy
the formatting in CHANGELOG.md. Update the PR template to reflect the new
location of the CHANGELOG.md.
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Replace with specific version.
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* add base test for input value field
* add value property to Element
* add test for non supported element
* prevent users to set value attribute on elements that do not support it
* add test for setting value on collections
* add value property to collection and add more tests
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
pre-commit.ci has been disabled for a while.
This PR ensures that all the files has been validated/formatted by pre-commit, to avoid spurious diffs in subsequent PRs.
During the process, ruff broke the code because it removed an "unused" import which was actually used.
A linter which breaks my code is a linter which I cannot trust, so I just removed it. I re-enabled isort instead.
* blacked
* More robust code for display, with tests
Display now includes more robust controls when checking
the input target parameters, with appropriate exception raised
(i.e. ValueError or TypeError) whether target is either
an empty string, or a not-string, not-None type, respectively.
The TypeError aligns with other similar behaviour with other Pyton
functions (e.g. str.split with integer separator).
Also, now display raises a ValueError whether the target element
is not found or not existing.
All changes are supported by tests.
* traceback lines in check_py_error & removed clones
check_py_error function now automatically includes
check of the traceback in console errors.
This way tests in basic and display have been refactored,
and lots of duplicated code removed.
* removed useless console check lines.
If check_py_errors function is running, those
console log lines are useless to check.
This re-enables CI tests on every PR 🎉.
This uses make test-integration, which runs tests sequentially.
In theory, we also have test-integration-parallel but it seems to be very flaky: many tests randomly timeout. I didn't spend too much time investigating this, it's probably worth its own investigation in a separate PR, but for now it's important to re-enable CI tests, even if they are a bit slower.
This PR re-enables tests on `worker`s. Highlights:
* by default, each test is run twice: the main thread version uses `<script type="py">`, the worker version automatically turn the tags into `<script type="py" worker>`
* you can tweak the settings per-class by using the `@with_execution_thread` decorator. In particular, `@with_execution_thread(None)` is for those tests which don't care about it (e.g., `test_py_config.py`)
* inside each class, there might be some test which should be run only in the main thread (because it doesn't make sense to test it in a worker). For those, I introduced the `@only_main` decorator
* we might introduce `@only_worker` in the future, if needed
* `@skip_worker` is for those tests which currently pass on main but not on workers. These are meant to be temporary, and eventually they should all be fixed
During the process, I tweaked/improved/fixed/deleted some of the existing tests. Some of them were at risk of being flaky and I made them more robust, others depended on some very precise implementation detail, and I made them more generic (for example, `test_image_renders_correctly` relied on pillow to render an image with a very specific string of bytes, and it broke due to the recent upgrade to pyodide 0.24.1)
I also renamed all the skip messages to start with `NEXT`, so that they are easier to grep.
Clean up a bit the testsuite and integration tests.
Highlights:
- Some of the @skipped tests just worked -- I unskipped them
- some worked after some small tweak to adapt to the new pyscript next
- some are still skipped, but I tweaked the skip message to be more precise and descriptive
- Moreover, I killed/removed the ones which no longer make sense in the context of pyscript next; in particular, I removed all the ones which tested Element (which is now gone) and the one which tested py-config features which are no longer needed (e.g., multiple interpreters).
The testsuite passes locally.
* move integration tests pyscriptjs/tests/integration ->pyscript.core/tests/integration
* add information in regards to how to run integration tests to README
* fix fake server build paths
* fix paths to build and run tests. The change of path before integration tests is a glitch maybe due to pytest cache?
* remove test files created by mistake
* update readme with latest changes
---------
Co-authored-by: Fabio Pliger <fpliger@anaconda.com>
* add pyweb
* build
* add test file
* fix pydom example code
* remove old reference to js
* temporarily comment out query functions on BaseElement while rearranging code to reuse the same underlying logic accross PyDom and other elements
* add temp TODO comment to content as it breaks with template elements
* update pydom example to define code on external file
* fix name type while renaming document -> dom
* add real pydom test files
* add classes to dom scope
* __len__ to ElementCollection
* fix some of the old tests
* rename test from test_query_by_class to test_getitem_by_class
* change test for read and write multiple elements
* add find method to BaseElement
* fix remaining tests
* add Collection Tests
* add equality to Collection
* add test for collection style manipulation
* fix getter for style property and rename style related attribute from pop to remove
* add single element creation test
* remove append on BaseElement and add body and head to dom
* add test_create_element_child to verify child creation
* add children getter property to Element
* remove old code
* remove more old code, change style attribute from visibility to visible and now default getters on collection to return a list with the value of an attribute for every element in the collection
* remove more old code and add possibility to customize test flags via url
* add support to pass Js and pydom.Element elements to when decorator
* remove methods related to input type of elements until we have a better design for it
* rename _element to _js
* add test_when decorator with a ElementCollection input
* when decorator now supporte pydom.ElementCollection as input
* update pyscript.js
* remove useless variable from when decorator
* remove base.py from pyweb
* add nodes for append collection test and add better feedback on successes vs failure
* add tests and fix code for support of append Element and ElementCollection
* manage access to content attribute when tagname is template
* fix comment
---------
Co-authored-by: Fabio Pliger <fpliger@anaconda.com>
* restore HTML code in display module
* restore when decorator code in event_handling module
* add when and HTML at pyscript import level
* add test for display with HTML
* add quick manual test for when
---------
Co-authored-by: Fabio Pliger <fpliger@anaconda.com>
* bring Makefile to root folder
* add back the print to console when pyscript is ready
* fix build path on tests, link to core.js and overall timeout since it now loads faster
* fix and mark some tests accordingly
* change default timeout to 20s
* review tests and skip what is a known regression
* more tests review until pycondif and skip what is a known regression
* fix pyodide version used on tests
* remove display from config test since it's not testing anything more than console already tests and display as its own tests
* disable config tests that rely on the banner
* skip REPL tests since it's not included in pyscript NEXT
* skip PyTerminal tests since it's not included in pyscript NEXT
* skip more tests relying on Element
* Fix wrong script type from py-script to py
* review more tests related to attributes and add test for worker
* skip spashscreen tests
* wrap up reviews on remaining tests
* update core
* update display tests to use import
* fix more tests and skip some that have known issues
* skip other 2 tests that fail because the test framework injects values that cause the config to fail
* fix getPySrc test due to changed interface
* another round of fixes and commenting on specific tests
---------
Co-authored-by: Fabio Pliger <fpliger@anaconda.com>
* updated MicroPython to latest in order to have `globals` API available
* reduced code around helpers for both MicroPython and Pyodide as now these are more aligned
* updated all dependencies and brought in latest [coincident/window](https://github.com/WebReflection/coincident#coincidentwindow) goodness to any `xworker`, preserving the `sync` previous behavior
* using [@ungap/structured-clone/json](https://github.com/ungap/structured-clone#tojson) as *coincident* default `parse` and `stringify` utility to allow recursive and more complex data to travel back from the *Worker* (forward data is still fully [structured clone algorithm compatible](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm))
* renamed all *plugin/s* references to *custom/s* as plugin as a word was too misleading
* changed *custom types* helpers logic to allow any single node to have its own version of the interpreter wrapper, and all the extra fields it carries with it, including a way to augment every interpreter execution, among as every worker code execution
* created a `custom` folder where I've landed the very first `pyscript.js` custom type
* created an exhaustive test page to demonstrate the current abilities of *PyScript Next* among its ability to expose utilities that can be used to create *PyScript* plugins
* Add ci for next
* Install deps from the right folder and build the project
* Rename CI job for test next
* Remove all things pyscriptjs
* Remove ESLint job
* Fix#1512 - Improve worker tests + update Pyodide
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* patched an issue with wasmoon randomly asking to resolve proxy references
* simplified pyodide and micropython dance by grouping their common utilities together
* created an integration test around a worker to main thread input between MicroPython and Lua
* commented some weird bugs / funny behaviors around both MicroPython and Pyodide
* other minor clean ups
* kill unwrapped_remote (#1490)
* kill unwrapped_remote
* linting
* don't use callKwargs for python plugins
* fix tests and improve types
* Bringing PyScript.next PoC to the main project
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
---------
Co-authored-by: Madhur Tandon <20173739+madhur-tandon@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* Error html to root of docs
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* Add 'xterm' attribute in py-config using new validation
* Use screen reader mode
* Add `xtermReady` promise to allow users to away xterm.js init
* Guard against initializing a tag twice
* Add tests and doc
* Upgrade to Pyodide 0.23.2
* Update changelog
* Use @param decorator to fix kmeans examlpe
* Separate zz_example tests to run sequentially
* Remove pytest.raises from pyscript_src_not_found test, use check_js_errors instead
* Add 'check_js_errors' to wait_for_pyscript
* remove PyWidget and py-register-widget
* refactor py-list as Plugin
* add newline
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* fix eslint
* handle case if src not supplied
* move inside if
* - Remove src attribute for py-list
- Re-implement as a Python plugin
- Remove pylist.py from examples directory
- Remove PyListPlugin as one of the default ones
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* move PyItem and PyList classes to the plugin
* clean up PyListTemplate and PyItemTemplate from pyscript module
* fix linting
* use PyList instead of PyListTemplate instead
* fix example for todo-pylist
* re-enable and improve test
* move py-list plugin to examples
* fix py-list plugin link
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Before this PR, the following test passed:
def test_pyscript_hello(self):
self.pyscript_run(
"""
<script type="py">
raise Exception("hello")
</script>
""")
What happens is that we intercept the Python exception and display a nice banner on the DOM, but the test itself passes. This is error prone: if we have Python exceptions on the page, the test should fail by default, and we should have a way to silence it in case those exceptions are expected.
This PR treats Python errors as we treat JS errors: unhandled exceptions cause the test to fail, but you can silence them by calling self.check_py_errors(), exactly as you can call self.check_js_errors().
* test for no cors headers
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* fix tests
* suggested changes
* disable directly
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* add error message
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* improve test
* improve error message
* remove py-config tag from cors test
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* Add new _event_handling.py file with @when decorator
* @when decorate is in pyscript package namespace/_all__
* Write tests in new test_event_handling.py
* Add docs for @when decorator
------------
Co-authored-by: Mariana Meireles <marian.meireles@gmail.com>
The goal of this MR is to unobtrusively allow the usage of `<script type="py">`, `<script type="pyscript">` or `<script type="py-script">` tags instead of `<py-script>` for all those case where the layout in custom elements get parsed and breaks users' expectations (including our SVG based tests).
* always same listener, for easy removal and reduce RAM
* avoid duplicated entries for smaller library outcome
* use XPath to crawl all attributes names instead of CSS
* Updated the instructions for setting up the documentation environment to be clearer
* Expanded on setting up the development and documentation environments.
Moved the documentation section to its own section as it's behavior and purpose is different from the development environment.
* Added alternative to git upstream
Indented list instead of using
* Add 'Using a Local Dev Server' to Getting Started Docs (#1400)
* Added alternative to git upstream
Indented list instead of using
Updated the test environment section
cleaned up "reviewing your work" section to make it easier to read.
* added "setting up environment" changes to changelog
* reverted additions to changelog
---------
Co-authored-by: Jeff Glass <glass.jeffrey@gmail.com>
This PR adds support for optionally running pyodide in a web worker:
- add a new option config.execution_thread, which can be `main` or `worker`. The default is `main`
- improve the test machinery so that we run all tests twice, once for `main` and once for `worker`
- add a new esbuild target which builds the code for the worker
The support for workers is not complete and many features are still missing: there are 71 tests which are marked as `@skip_worker`, but we can fix them in subsequent PRs.
The vast majority of tests fail because js.document is unavailable: for it to run transparently, we need the "auto-syncify" feature of synclink.
Co-authored-by: Hood Chatham <roberthoodchatham@gmail.com>
Co-authored-by: Madhur Tandon <20173739+madhur-tandon@users.noreply.github.com>
* Add `validateConfigParameter` and `validateConfigParameterFromArray` functions to validate user-provided parameters from py-config
* Add units tests for `validateConfigParameter` and `validateConfigParameterFromArray`
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* Add docs to repl with attr src
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Fix path errors on Windows systems
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Fix path errors on Windows systems
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
In the future this should help us leak fewer names into the pyscript
namespace.
Rather than assigning to the pyscript module from JavaScript, we
mount a separate private JS module with the extra names needed by
PyScript. I moved a bit more interpeter intialization into
remote_interpreter.
I added a deprecation warning for `pyscript.js`: the proper way to
access `js` is `import js`.
---------
Co-authored-by: Antonio Cuni <anto.cuni@gmail.com>
Switch to using the new version of synclink with support for same thread syncify (and also correct types).
Uses syncify to replace one use of `_unwrapped_remote`.
* remove pys-on* and py-on* attributes
* update changelog
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* fix eslint
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
- Previously, if the message appeared on the console immediately before the call to self.wait_for_console(), the call would hang forever until the timeout. Now, it returns immediately.
- `wait_for_pyscript` now logs the time actually taken for waiting
- `wait_for_pyscript` takes a `timeout` argument so that we can tweak it on a test-by-test basis
* Add docs to repl with attr src
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* load code from the attr src of py-repl
* load code from the attr src of py-repl
* load code from the attr src of py-repl
* load code from the attr src of py-repl
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Resolves pyscript#1313 and pyscript#1314. On top of pyscript#1318.
The point of these tests is to define the execution order of Tasks
that are scheduled in <py-script> tags: first all the py-script tags
are executed and their related lifecycle events. Once all of this
is done, we schedule any enqueued tasks.
To delay the execution of these tasks, we use a custom event loop for
pyExec with this defer behavior. Until schedule_deferred_tasks is called,
we defer tasks started by user code. schedule_deferred_tasks starts all
deferred user tasks and switches to immediately scheduling any further
user tasks.
Turns off:
- no-explicit-any (we need to handle any return values from runPython)
- no-unsafe-assignment (noisy and pointless)
And resolves all but two remaining ones. The last two lints regard access to private Pyodide variables and so:
- they are not easy to work around without an upstream Pyodide patch
- they should trigger linter and require explicit override
This is some refactoring I did on the way towards resolving pyscript#1313.
I added a new _run_pyscript Python function which executes the code
inside a context manager that sets the display target. We can then
return a JS object wrapper directly from Python.
I moved the "installation" of the pyscript module to loadInterpreter,
and pyimport pyscript_py there and give it a type. This avoids a bunch
of creating and deleting of proxies for pyscript_py and allows us to
give it a type once and for all.
I also did some minor logic cleanup in a few places.
* Deprecate py-mount attribute, with comments as to when it was deprecated
* Add changelog entry for deprecation
* Fix 'unused' examples that used py-mount (handtrack and mario)
This is a first step towards loading more stuff simultaneously rather
than sequentially.
The functional part of this is pretty small: call `calculateFetchPaths` and
then `Promise.all(fetchPaths.map(loadFileFromURL));`. I also transposed the
return type of `calculateFetchPaths` since it's more convenient to consume
this way.
I redid the logic in `calculateFetchPaths` a bit. I renamed `src/plugins/fetch.ts`
to `calculateFetchPaths.ts` since the file performs no fetching. I also
renamed `loadFromFile` to `loadFileFromURL`.
Followup to pyscript#1232. Closes pyscript#1226.
Use node to make a manifest of the src/python dir and then use an esbuild
plugin to resolve an import called `pyscript_python_package.esbuild_injected.json`
to an object indicating the directories and files in the package folder.
This object is then used to govern runtime installation of the package.
They were disabled by PR #1157 but without any discussion or consensus, so I guess it was a mistake. Personally I found them very useful and AFAIK we never had a problem of people abusing them, so I don't see why they should be disabled (#1311)
* removed unnecessary getAttribute
* removed unnecessary shadow and ShadowDOM in general, as it was never used
* dropped redundant constructor
* removed unnecessary usage of the label element
* fixed redundant always-same buttons IDs
* Fix markdown
Add event-handlers.md
* Address changes from Jeff + Antonion and add it to index
* how tos don't exist anymore theyre now guides
* Restore p on contributing
* Adding changelog
* Aadd space
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
---------
Co-authored-by: Carmelo <carmelofiorello@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* Set pre-commit autoupdate to quarterly
Weekly autoupdate creates a lot of noise
* Update .pre-commit-config.yaml
Co-authored-by: Christian Clauss <cclauss@me.com>
---------
Co-authored-by: Christian Clauss <cclauss@me.com>
* Fix tests running on osx + remove auto-gen where doesnt make sense
* Linting
* Adds a changelog
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* Unvendor toml package
* Fix many ESlint errors
For mysterious reasons, these errors appear on my branch #1262 even
though they are not related to changes there. The eslint config seems
a bit unstable.
Anyways this fixes them.
* Put back Record
* Fix typescript compilation
* Fix lints
* Try @iarna/toml instead
* Fix import
* Use @ltd/j-toml
* Update test
* Use toml-j0.4
* Some changes
* Fix toml import
* Try adding eslint gha job
* Add forgotten checkout action
* Force CI to run
* Blah
* Fix
* Revert changes to github workflow
* Fix lints
* wget toml-j0.4 type definitions
* Add toml-j types workaround to eslint workflow
* Apply formatter
* Use @hoodmane/toml-j0.4
* Import from @hoodmane/toml-j0.4
* Added Pull request template
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
---------
Co-authored-by: you@example.com <you@example.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
precommit.ci seems to have different results than when I run eslint
locally. At least at first glance, github seems to behave the same
as local. So this turns off eslint in pre-commit.ci and turns it on
in gha.
The path logic here assumes that the tests are being run from inside
the pyscriptjs directory. It is better to compute releative to `Path(__file__)`
so that it does not depend on the working directory
* Apply prettier to css, js, html, md, ts, and yml
As a followup I will add prettier to the .pre-commit config.
This patch is 100% generated by prettier.
I used a forked version of prettier that understands the
py-script tag.
See https://github.com/hoodmane/pyscript-prettier-precommit
for more info.
* Apply old pre-commit
* Revert some problems
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Revert some changes
* More changes
* Fix pre-commit
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* split interpreter class
* add new files
* add newlines
* disable eslint for run
* remove usage of interpreter from unit test
* delete fakeinterpreter class
* fix unit tests
* add comments
* remove interpreter.ts and pyodide.ts files
* suggested changes
* Fix syntax errors in html files
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* Add test reporter
* Fix indendation
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* Improves repl id output
* Fix tests for new REPL output ids
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Add new REPL tests
* Pre commit linting
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Remove mistake
* Fixing tests that i didn't notice were broken?
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* upgrade to pyodide 0.22.1
* pin bokeh in panel examples
* fix typo
* fix tests by using custom bokeh wheel
* fix bokeh interactive test
* adhere to new loadPackage API
* Allow disabling splashscreen
* Move disabled to if statement
* Add docs for py-splashscreen and test for logging
* Add entry to changelog
* Address Jeff's comments
* Rename disabled option to enabled and set to true by default
* Fix logic and tests
* Uncomment test
* Fix test
* Move the info in /pyscriptjs/README.md to /docs/development/developing.md
* developing.md: Markdown linting
* Fixing docs issue #1033
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* setting-up-environment.md: Markdown Linting
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* fix exception not thrown in event handler
* fix implicit display test
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* add plugins testing utils module
* add plugins manager fixture and init plugins tests helper in conftest
* add _custom_elements attribute to pyscript.Plugin to allow plugins to track the CE they register
* add test for py_tutor
* remove unrelated code from prims js script
* ensure a Plugin always has the app attribute and improve tests
* add tests for py_tutor create_code_section
* implement PluginsManager reset and add teardown on plugins_manager fixture to clean it up after a test
* add test to check if plugin has been registered
* add docstrings to new tests
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* add docstrings to plugins tester
* add changes from main
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* lint
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* add todo to add remaining PluginsManager lifecycle events
Co-authored-by: Fabio Pliger <fpliger@anaconda.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* Add beforePyScriptExec, afterPyScriptExec lifecycle hooks
* Add stdiodirector plugin for `output`, `stderr` attributes of py-script tag
* Add docs on `output` and `stderr` attributes of py-script tag
* Tests
* Removed output deprecation warning for `output` attribute
* Add createSingularWarning(), with createDeprecationWarning as alias
* Show deprecation banner
* Add test for deprecation warning
* Remove deprecated elements
* Add entry in changelog
* Update test_style
* Remove random color rule
* Add PR link to changelog
* Add files via upload
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* replace unnecessary elements from hello_world example and replace with py-tutor tag
* add py_tutor plugin
* port altair example
* add code for more granular tutor mode
* add support for including modules source in pytutor
* remove js dependencies in hello_world
* put antigravity on a diet ;)
* use py-tutor on antigravity example
* use py-tutor on d3 example
* use py-tutor on bokeh example
* use py-tutor on bokeh_interactive example
* fix issue when module_paths is undefined
* remove prism js dependency leftovers
* ooops, really remove prism js dependency leftovers
* port follium example to pytutor
* port pymarkdown and matplotlib example to pytutor
* port message_passing and numpy_convas_fractals examples to pytutor
* port the panel complex examples to pytutor
* port the panel complex examples to pytutor
* port last examples to py-tutor
* remove prism
* remore most debugging logs and replace log with info
* add new d3.py file
* add comments to connect method
* clean pyscript class from logs
* revert class pySrc attribute
* add check_tutor_generated_code to test code inspector plugin in examples
* add doctsting to PyTutor connect
* add check for tutor code inspection on all examples
* Update pyscriptjs/src/plugins/python/py_tutor.py
fix template indentation
Co-authored-by: Fábio Rosado <fabioglrosado@gmail.com>
* Update examples/todo-pylist.html
fix typo (stray = )
Co-authored-by: Fábio Rosado <fabioglrosado@gmail.com>
* fix pymarkdown example
Co-authored-by: Fabio Pliger <fpliger@anaconda.com>
Co-authored-by: Fábio Rosado <fabioglrosado@gmail.com>
* fix wrong console method and unescape the tag content before running markdown on it
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* add markdown plugin example test
* add PyMarkdown minimal test
* remove commented code
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* remove import of console from pyscript
* remove unused imports
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Fabio Pliger <fpliger@anaconda.com>
* Deprecate pyscript output attribute
* Update code blocks so they work
* Small tweaks to styling and use html to warning
* Fix broken test from bad conflict resolution
* lowercase pyodide
* Rewrite the get started tutorial using the ice cream demo
* Update docs/tutorials/getting-started.md
Co-authored-by: Antonio Cuni <anto.cuni@gmail.com>
* Address Antonio's comments
Co-authored-by: Antonio Cuni <anto.cuni@gmail.com>
* Fix antigravity
* Add test
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* kill the PyScript class and the weird pyscript instance; from the user point of view its functionalities are still available as pyscript.*, but pyscript is not the module, not the instance of PyScript
* simplify the code in _set_version_info, while I'm at it
* start to implement DeprecatedGlobal
* DeprecatedGlobal.__getattr__
* don't show the same warning twice
* DeprecatedGlobal.__call__
* make it possible to specify a different warning message for every global
* WIP: carefully use DeprecatedGlobal to show reasonable warning messages depending on which name you are accessing to. More names to follow
* deprecate more names
* deprecate private names
* depreacte direct usage of console and document
* deprecate the PyScript class
* use a better error message
* fix test_pyscript.py
* introduce a __repr__ for DeprecatedGlobal
* add an helper to ensure that we don't show any error or warning on the page
* WIP: ensure that examples don't use depreacted features. Many tests are failing
* don't deprecate Element
* don't use the global micropip to install packages, else we trigger a warning
* use a better error message for micropip
* fix test_todo_pylist to avoid using deprecated globals
* fix test_webgl_raycaster
* fix tests
* make HTML globally available
* add MIME_RENDERERS and MIME_METHODS
* fix the typing of Micropip, thanks to @FabioRosado
* Fake server 404 support
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* 404 test
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* fix test
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* test fix
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* rm unecessary code on output rendering on pyscript.py
* Remove all ids from repl
* Fix problems on rendering outside repl
* fixing tests
* Fixes repl and tes_py_repl
* Fix zz tests
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* test 864now works consistently
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* Add runtime.invalidate_module_path_cache() to clear importlib's cache of modules
* Clear cache after [[fetch]], after plugin files download, after plugins setup, and prior to py-script tag execution.
* add test and example files
* update config to include python plugins in build
* add markdown plugin
* remove full pyscript execution from pyodide
* move loading of pyscript.py from pyodide loagInterpreter to main setupVirtualEnv and add function to create python CE plugins
* add plugin class to pyscript.py
* add missing import
* fix plugin path
* add fetchPythonPlugins to PyScriptApp
* remove old comments
* fix test
* add support for python plugins beyond custom elements and add app to python namespace in main
* inject reference to PyScript app onto python plugins
* add example hook onto markdown plugin
* change plugin events logs
* remove unused PyPlugin
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* fix type import
* add docstring to fetchPythonPlugins
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* rename addPythonPlugin method
* address PR comment
* call python plugins on hooks after the interpreted is ready
* add test for event hooks and split the test in 2 separate plugins to isolte type of plugins tests
* change python plugins initialization and registration, to inject the app from app itself instead of on the plugins themselves
* handle case when plugin cannot load due to missing plugin attribute
* add test for fail scenario when a plugin module does not have a plugin attribute
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* add deprecation warning for pyscript objects loaded in global namespace
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* remove all from global scope
* remove create_custom_element from global scope
* rename create_custom_element to define_custom_element
* rename attributes in define_custom_element and add docstrings
* better handle connect event output
* add warning to py_markdown plugin
* remove debugging logs
* improve tests
* remove debugging log
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* remove unused import
* add executable shebang
* add pyodide mock module
* fmt and lint
* Update to pyodide.ffi.create_proxy per pyodide v21 api change
* Mock pyodide as package instead of mdoule
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* add __init__ to pyodide package
* Update pyscriptjs/src/plugin.ts
fix logger name
Co-authored-by: Antonio Cuni <anto.cuni@gmail.com>
* fix pyodide import but handling the diff in their API change
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* oops, conflict resolution blooper
* Fix failing integration tests
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Jeff Glass <glass.jeffrey@gmail.com>
Co-authored-by: Antonio Cuni <anto.cuni@gmail.com>
Co-authored-by: FabioRosado <fabiorosado@outlook.com>
* Import current version as PyScript.__version__ and PyScript.version_info
* Add integration, python unit tests
* Mock pyscript.py with __mocks__/pyscript.js to make jest tests happy
* Revert to runPython instead of await runPythonAsync
* "Implicit Coroutines" are no longer permitted in py-script tags
* Tests added for the above
* xfail test_importmap (See #938)
This PR move codes from main.ts into two new plugins:
- splashscreen (formerly known as py-loader)
- importmap
The old setting config.autoclose_loader is still supported but deprecated; the new setting is config.splashscreen.autoclose.
Moreover, it does a small refactoring around UserError: now UserErrors are correctly caught even if they are raised from within afterRuntimeLoad.
* Raise error if we get a non 200 status from fetch
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Add custom exception
* Add check for TypeError as well
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* use pytest-cache to cache HTTP requests, so that it survives across multiple runs
* add an option to clear the HTTP cache
* add some docs about pytest
This PR does two things:
1. introduce the first minimal version of a Plugin system. Plugins are subclasses of the Plugin class, and pyscript will call the relevant methods/hooks at the right time. Currently, I have added only the minimal sets of hooks which were needed for this PR.
2. Implement <py-terminal> as a plugin.
* implement proposal
* update docs and replace py-env
* more docs
* suggested proposal
* update docs
* add to_file parameter
* remove comment from Makefile
* suggested improvements
* move tests from basic to py_config
* retain leading slash from the first path
- display(some_str) escapes the string by default. This is almost always what you want
- display(some_obj) calls repr(obj) and escapes the result. Again, it's a very sensible default
- if you want to inject some raw HTML in the output, you can use the new HTML class: display(HTML("<p>hello</p>")).
Major highlights:
1. Merge&simplify base.ts and pyrepl.ts; kill base.ts
2. improve and extente the py-repl integration tests
3. Reorder the code in pyrepl.ts. This part of the PR doesn't change much of the concrete logic: it's just a sequence of renaming variables, moving code around, group code into functions, killing code which is no longer needed. But the end result is much better and nicer to read, IMHO.
Minor highlights:
1. py-repl now uses the new logic in pyexec.ts to run the code
2. after PR Add display impl, rm outputManage, print and console.log default to browser console #749 py-repl no longer displayed the result of the last evaluated expression (e.g. if you typed 42 and run it, it displayed nothing). This PR re-introduces this behavior, which is what you would expect by a REPL.
3. improve the pytest --dev option: now it implies --no-fake-server so that sourcemaps works automatically
4. improve the names of the CSS classes to be more consistent
5. kill pyrepl.test.ts: the old tests didn't check anything useful, this style of unit test doesn't really add much value if you have good integration tests (which now we have) and trying to revive them was not worth the hassle
* Reference Docs
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* py-repl
* pyrepl
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Until now, we didn't have a nice way to check that we expect a specific JS error in the web page.
This PR improves check_js_errors() so that now you can pass a list of error messages that you expect.
It is tricky because we need to handle (and test!) all various combinations of cases:
- errors expected and found / expected but not found
- unexpected errors found / not found
Moreover, JS exceptions now are logged in the special category console.js_error, which means that the printed text is also available using e.g. self.console.js_error.text or self.console.all.text. However, this should never be required and it's preferred to use self.check_js_errors to check for exceptions. This fixes#795 .
Finally, use the new logic to improve test_no_implicit_target.
Yet another refactoring to untangle the old mess.
Highlights:
base.ts, pyscript.ts and pyrepl.ts were a tangled mess of code, in which each of them interacted with the others in non-obvious ways. Now PyScript is no longer a subclass of BaseEvalElement and it is much simpler. I removed code for handling the attributes std-out and std-err because they are no longer needed with the new display() logic.
The logic for executing python code is now in pyexec.ts: so we are decoupling the process of "finding" the python code (handled by the py-script web component) and the logic to actually execute it. This has many advantages, including the fact that it will be more easily usable by other components (e.g. pyrepl). Also, note that it's called pyexec and not pyeval: in the vast majority of cases in Python you have statements to execute, and almost never expressions to evaluate.
I killed the last remaining global store, scriptQueue tada. As a bonus effect, now we automatically do the correct thing when a <py-script> tag is dynamically added to the DOM (I added a test for it). I did not remove svelte from packages.json, because I don't fully understand the implications: there are various options which mention svelte in rollup.js and tsconfig.json, so it's probably better to kill it in its own PR.
pyexec.ts is also responsible of handling the default target for display() and correct handling/visualization of exceptions. I fixed/improved/added display/output tests in the process.
I also found a problem though, see issue #878, so I improved the test and marked it as xfail.
I removed BaseEvalElement as the superclass of most components. Now the only class which inherits from it is PyRepl. In a follow-up PR, I plan to merge them into a single class and do more cleanup.
During the refactoring, I killed guidGenerator: now instead of generating random py-* IDs which are very hard to read for humans, we generated py-internal-X IDs, where X is 0, 1, 2, 3, etc. This makes writing tests and debugging much easier.
I improved a lot our test machinery: it turns out that PR #829 broke the ability to use/view sourcemaps inside the playwright browser (at least on my machine).
For some reason chromium is unable to find sourcemaps if you use playwrights internal routing. So I reintroduced the http_server fixture which was removed by that PR, and added a pytest option --no-fake-server to use it instead, useful for debugging. By default we are still using the fakeserver though (which is faster and parallelizable).
Similarly, I added --dev which implies --headed and also automatically open chrome dev tools.
* export 'pyscript' JS module with runtime attribute, to allow accessing (Pyodide) runtime and globals from JS.
* add docs to explain the js module
* add integration tests for the js module
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* use emscripten virtual FS directly to load paths
* use more low level APIs
* use await instead of then
* remove try...catch from loadFromFile since it's being handled externally
* add test for an invalid path
* test checks for error shown to the user too
* add comment about a missing case
* ts strict getAttribute
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* mark xfail
* fix to string
* Remove
* use getAttribute for theme
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* Add display impl, remove outputManage, print and console.log defaults to terminal
* Fixing tests
* Lint
* Erase unecessary code, add cuter CSS formating for errors, fix problems around REPL output
* Add fix to repl2 and lint
* lint
* Allow for list of display, fix elif to else
* Add better global option
* test work
* xfails
* (antocuni, mariana): let's try to start again with TDD methodology: write the minimum test and code for a simple display()
* (antocuni, mariana): this test works out of the box
* WIP: this test is broken, mariana is going to fix it
* add a failing test
* Add ability to deal with targets
* Add append arg and append tests
* Add multiple values to display
* Small adjustments to tests. I noticed I wasn;t running all at some point
* add display test
* Add console tests
* Add async tests
* Fix repl tests
* Fixing merging issues
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Address antocuni's review
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Fixing more tests
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* linting
* Improve repl tests
* Change my test so codespell is hapy with it
* Test: change test_runtime_config to use json instead of toml to see if stops failing on CI
* kill this file: it is a merge artifact since it was renamed into test_py_config.py on the main branch
* Change test execution order and add async tests to async test file
Co-authored-by: Antonio Cuni <anto.cuni@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
As the title stays, the main goal of the branch is to kill the infamous runtimeLoaded global store and all the complications, problems and bugs caused by the fact that in many places we needed to ensure/wait that the global runtime was properly set before being able to execute code.
The core idea is that runtime is never a global object and that it's passed around explicitly, which means that when a function receives it, it is guaranteed to be initialized&ready.
This caused a bit of complications in pybutton.ts, pyinputbox.ts and pyrepl.ts, because they indirectly want to call runtime.run from connectedCallback, which is the only place where we cannot explicitly pass the runtime because it's automatically called by the browser.
But also, it is also a sign of a bad design, because it were entirely possible that connectedCallback was called before the runtime was ready, which probably caused many bugs, see e.g. #673 and #747.
The solution to is use dependency injection and create the class later on: so instead of having a global PyButton class which relies on a global runtime (whose state is uncertain) we have a make_PyButton function which takes a runtime and make a PyButton class which is tied to that specific runtime (whose state is certainly ready, because we call make_PyButton only when we know that the runtime is ready).
Similar for PyInputBox and PyRepl.
Other highlights: thanks to this, I could kill the also infamous runAfterRuntimeInitialized and a couple of smelly lines which used setTimeout to "wait" for the runtime.
While I was at it, I also called a lot of other stores which were completely unused and where probably leftovers from a past universe.
* Use only single copy() plugin to avoid race condition
* clean production def, better copy_target structure
* Restore '!process.env.ROLLUP_WATCH to production definition
Co-authored-by: Ted Patrick <tpatrick@anaconda.com>
* Hide py-config element
* display:none for all web components
* docs
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Add style tests for raw html and pyscript enabled html
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* test naming
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* Upgrade and Pin Dependencies
* Removal all unused deps
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* lock
* remove svelte-fa reference from the svg style.
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* Add directly listing for releases
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* Add cache, fetch, retry logic to tests
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* run in parallel
* add pytest-xdist
* undo parallelism. Need to remove http server to enable.
* woops a extra space
* Pass flake8
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* spell fulfill
* use decorator for fetch if not in cache
* Fix --headed and limit to PlaywrightRequestError
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* docs on cache
* CICD caching of conda on unstable builds
* fix config issues
* empty commit to trigger gh-actions
* restore build-unstable
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Remove http server, add parallel
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* temp: Bypass zip runtime test and point to v0.21.3 on CDN
* suport for files in zip under /pyodide
* remove test-one
* self.http_server and remove content_type
* domcontentloaded w no timeout on base url + longer timeout on wait_for_pyscript
* Fixed#678
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* set default timeout to 60000
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* seamless --headed support
* add test-integration-parallel and default for GHActions
* simplify the code. Use http://fakeserver instead of localhost:8080 so that it's clearer that the browser is NOT hitting a real server, and use urllib to parse the url. Moreover, the special case for pyodide is no longer needed, it's automatically handled by the normal 'fakeserver' logic
* The page-routing logic is becoming too much complicated to stay as an inner function. Move it to its own class, and add some logic to workaround a limitation of playwright which just hangs if a Python exception is raised inside it
* no need to use a hash, we can use the url as the key
* re-implement the retry logic. The old @retry decorator was nice but a bit too over-engineered and most importantly failed silently in case of exceptions. This new approach is less powerful but since we want to retry only two times, simple is better than complex -- and in case of exception, the exception is actually raised
* improve logging
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Madhur Tandon <madhurtandon23@gmail.com>
Co-authored-by: Antonio Cuni <anto.cuni@gmail.com>
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.
* Add stale to pyscript repo
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Add tags: backlog, needs-triage, needs-work
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This PR is the first step to improve and rationalize the life-cycle of a pyscript app along the lines of what I described in #763 .
It is not a complete solution, more PRs will follow.
Highlights:
- py-config is no longer a web component: the old code relied on PyConfig.connectedCallback to do some logic, but then if no <py-config> tag was present, we had to introduce a dummy one with the sole goal of activating the callback. Now the logic is much more linear.
- the new pyconfig.ts only contains the code which is needed to parse the config; I also moved some relevant code from utils.ts because it didn't really belong to it
- the old PyConfig class did much more than dealing with the config: in particular, it contained the code to initialize the env and the runtime. Now this logic has been moved directly into main.ts, inside the new PyScriptApp class. I plan to refactor the initialization code in further PRs
- the current code relies too much on global state and global variables, they are everywhere. This PR is a first step to solve the problem by introducing a PyScriptApp class, which will hold all the mutable state of the page. Currently only config is stored there, but eventually I will migrate more state to it, until we will have only one global singleton, globalApp
- thanks to what I described above, I could kill the appConfig svelte store: one less store to kill :).
* TOML Error Cases
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* remove traceback
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* any is a ts feature
* full eslint
* format and disable eslint for toml.js
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Madhur Tandon <madhurtandon23@gmail.com>
from Ted Patrick --
tedpatrick — 09/19/2022
Hello and Good Morning (CST in Austin TX)
Key: We want the dialog about Pyscript OSS to be transparent and centered in the community. Rather than add another communication platform, using this Discord meets the community where they are.
* simplify OutputCtxManager logging
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* Minimium viable py-config default schema
* Add packages and paths to default
* Add in default for plugins
* Remove tests for values no longer in the default config
* Loading and Script evaluate with Promise.all
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Move to 'void script.evaluate();'
* chmod files to 644
* Add a test
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* Add unit tests for pyloader and pytitle
* Add more unit tests for pyrepl, pybox and pyinputbox
* Add more tests for pyscript and pyconfig
* White space
* Fix d3 tests and improve more examples test
* Update matplotlib test
* Add numpy to dependencies
* Address Madhur comments
* Update test name
* A workflow that enables snapshot releases by manual github action
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* typo in comment
* match naming and add name to workflow
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* add toml support for configs with fast-toml
* fix package-lock.json and pin pyodide to 0.21.2
* use browser version of fast-toml
* disable eslint and add credits
* fix jest issues
* use type attribute for py-config
* add HTTP request how to
First draft.
Proof read http-requests.md
Formatting
Reword intro
modify fetch API docs links
Conclusion
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* add http-request howto into toctree, index
* implement review
By @madhur-tandon
Implement review
and fix formatting mistake in request function docstring.
* add # HTTP requests section, add fetch_kwargs to helper function
Add a section in the explanation discussing HTTP Requests
* add API reference
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* specify docs for `pyodide.http` members
* address review
By @marimeireles
* Change code [Python] to Python
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: mariana <marianameireles@protonmail.com>
* refactor py-config to use toml
* switch from toml to json and add unit tests
* fix test for py-config
* fix integration test
* use flat structure for JSON
* allow merging configs
* replace arrays instead of concatenating them
* remove extra keys from inline config of integration test
* simplify array replacement logic
* allow config from src to be partial as well
* add comments to unit tests
* add unit test for setting config from both inline and src
* handle parse errors + validate config supplied
* separate functions for src and inline
* suggested improvements
* show error message in red on parser error
* fix eslint
* use resolveJsonModule as true
* use default config defined as a variable without import
* remove disable eslint comment
* remove import for covfefe.json as well
* metadata injection
* add support for schema + extra keys
* use schema_version
* Execute pys-on* events when triggered, not at load
Mimicing the behavior of Javascripts 'onLoad' event, we should
not be executing the use code at page-load time, only when
the event is triggered.
* Update examples to new syntax
* Fix merge issue
* Await running event handler code
* Restore pys-on* events with original behavior, deprecation warning
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* xfail toga example
* Add missing { (typo)
* Adjust callback chandling to make linter happy
* Change alpha to latest (#760)
* Don't create custom elements in main and fix various small issues on tests (#747)
* Create custom elements when the runtime finishes loading
* Remove xfails and fix repl integration test
* Fix commented ignore
* Address Antonio's comments
* Fix bad rebase
* Make ure to wait for repl to be in attached state before asserting content
* Move createCustomeElement up so it runs before we close the loader, xfail flaky d3 test
* Fix xfail
* [pre-commit.ci] pre-commit autoupdate (#762)
updates:
- [github.com/pre-commit/mirrors-eslint: v8.23.0 → v8.23.1](https://github.com/pre-commit/mirrors-eslint/compare/v8.23.0...v8.23.1)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* change documentation to point to latest instead of frozen alpha (#764)
* Toga example is xpass
* Correct 'xpass' to 'xfail' mark
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Peter W <34256109+pww217@users.noreply.github.com>
Co-authored-by: Fábio Rosado <fabiorosado@outlook.com>
* Create custom elements when the runtime finishes loading
* Remove xfails and fix repl integration test
* Fix commented ignore
* Address Antonio's comments
* Fix bad rebase
* Make ure to wait for repl to be in attached state before asserting content
* Move createCustomeElement up so it runs before we close the loader, xfail flaky d3 test
* Fix xfail
* Begin writeup
* Draft full howto
* Correct code errors in writeup, swap sections
* Add introduction, clarification
* Add link to howto:js in index
* Copyedit, update examples to Pyodide 21
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Add toc tree context
* Use print instead of js console in python examples
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: mariana <marianameireles@protonmail.com>
This PR tries to improve and rationalize what we log. Key points:
- introduce `logger.ts`: each file/component is encouraged to use the logger instead of writing directly to `console.*`
* the logger automatically prepend a prefix like `[py-config]`, `[py-env]` which make it easier to understand where a certain message is printed from
* it provide a central place where to add more features in the future. E.g., I can imagine having a config setting to completely silence the logs (not implemented yet)
- use the new loggers everywhere
- write to `.info()` instead of `.log()`. The idea is to keep `console.log` free, so that for the users it's easier to tell apart their own messages and the pyscript ones
- generally improve what we log. This is an endless exercise, but I tried to print more things which are useful to understand what's going on and in which order the various things are executed, and remove prints which were clearly debugging leftovers
* add integration test for py-config
* fix bug
* fix test
* remove indexURL altogether
* make jest happy
* fix create_proxy import
* check that py-config loads an older version
* add unit test
* suggested changes
* don't use /tmp because of bandit
* discrete steps and artifact passing
* fix small mistakes, prep test
* upload path
* fix path again
* change again
* checkout for test
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* formatting
* artifact paths
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* diagnostics
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* simplify
* small cosemtic changes
* move upload to end
* needs:
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* make runtime an object of Runtime class when it is just an object
* fix constructor
* remove explicit string type
* define default values out of pyodide runtime and use default config instead of initializing a DEFAULT_RUNTIME instance
Co-authored-by: Fabio Pliger <fabio.pliger@gmail.com>
* Remove unwanted class attribute
Multiple attributes with the same name are illegal in html. Nonetheless, the class task-check is not doing anything here.
* Remove to=task_list
The argument to=task_list is not playing any role, since the function works well without it.
Please see comment in pyscript.py
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Clean comment
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: mariana <marianameireles@protonmail.com>
* 585: Add a line to the makefile to run the examples on a python server with one line command
* Build exs and run server with previous makefile cmds
Co-authored-by: Todd Keech <tkeech1@hotmail.com>
Co-authored-by: mariana <marianameireles@protonmail.com>
* PyodideRuntime should be one of the runtimes
* subsume interpreter into runtime API
* fix eslint
* add comments
* move initializers, postInitializers, scriptsQueue, etc. to initialize() of Runtime Super Class
* modify comment for initialize
* small renaming
* change id to default
* fix pyscript.py import
* try adding tests
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Add inlineDynamicImports option
* Make jest happy about ESM modules
* Attempt to make jest happy about pyodide
* point to version in accordance with node module being used
* fix base.ts
* fix tests
* fix indexURL path determination
* edit pyodide.asm.js as a part of setup process
* load runtime beforeAll tests
* add test for loading a package
* use only runPythonAsync underneath for pyodide
* import PyodideInterface type directly from pyodide
* add some comments
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Philipp Rudiger <prudiger@anaconda.com>
* Update README.md
UPDATE: Specified to add files to head tag of HTML file
* UPDATE README.md
UPDATE README: Specify to add CSS and JS file to head tag of HTML
* Update README.md
Clean up wording.
* Add more integration tests for py-components and examples
for more information, see https://pre-commit.ci
* remove xfail mark since we merged fix for issue 707
Co-authored-by: Fabio Pliger <fabio.pliger@gmail.com>
* add build to the make examples cmd so that it automates more to the user
* temporarily improve error managament when executing eval until we properly refactor the whole io and error workflow
* add minimal test for format_mime
* move current integration tests to the integration folder
* move pyscript.py into its own python folder
* change the path for python unit testing files
* change pyscript.py path
* Update Makefile
* remove echo
* replace conda run with pytest directly
* oops, add python test files I embarrassingly forgot to add
Co-authored-by: Peter W <34256109+pww217@users.noreply.github.com>
* install test dependencies
* change config for tests
* fix linter failing tests
* add basic test file
* add custom element registration to test
* update dependencies
* add jest config file
* fix test calls on makefile and minor fix on test
* update local npm version
* clean testm file
* Ensure that angle brackets in pyscript tag are escaped before parsing
* Improve tests
* Update pyscriptjs/tests/test_01_basic.py
Co-authored-by: James A. Bednar <jbednar@users.noreply.github.com>
Co-authored-by: James A. Bednar <jbednar@users.noreply.github.com>
* WIP: start to use the PyScriptTests machinery to test the examples
* factor test_hello_world out of test_examples
* B011 forbids 'assert False' in tests because python -O remove asserts. Thank you, I knew that.
* improve test_simple_clock and remove it from test_examples
* test_altair
* test_bokeh
* rename
* kill the parametrized test_example and write individual tests for each of them
* test_kmeans it's slow, increase the timeout
* improve these xfail
* kill wait_for_load, no longer needed
* write the name of the issue
* add issue number
* add a trick which I discovered to run test interactively
* move the docstring inside the class
This PR is about integration tests: they use playwright to load HTML pages in the browser and check that PyScript works as intended, as opposed to unit tests like the ones being introduced by #665 and #661.
The main goal of this PR is to introduce some machinery to make such tests easier to write, read and maintain, with some attention to capture enough information to produce useful error messages in case they fail in the CI.
In order to use the machinery, you need to subclass tests.support.PyScriptTest, which provides several useful API calls in the form self.xxx().
See the full description here:
https://github.com/pyscript/pyscript/pull/663
Co-authored-by: Mariana Meireles <marian.meireles@gmail.com>
Co-authored-by: mariana <marianameireles@protonmail.com>
* checkpoint: added some text
* checkpoint: added setting up the environment, tips for writing good issues
* continuing to fill it out
* added more detailed description of the process of creating a change and some other cleanup.
* added a getting started section and cleaned up the grammar. This ready for the PR now
* forgot to add the new section to the TOC
* Changes
* Minor fixes
* Minor fixes
* Minor fixes
* Minor fixes
* Minor fixes
* Minor fixes
* Fix
Co-authored-by: Kevin Goldsmith <kgoldsmith@anaconda.com>
Co-authored-by: Matt Kramer <mkramer@anaconda.com>
* fix tests by changing serving dir
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* Expanded upon the make setup docs
* Fixed formatting & speling, added troubleshooting
* same
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* checkpoint: added some text
* checkpoint: added setting up the environment, tips for writing good issues
* continuing to fill it out
* added more detailed description of the process of creating a change and some other cleanup.
* added a getting started section and cleaned up the grammar. This ready for the PR now
* forgot to add the new section to the TOC
* Minor fixes
Co-authored-by: Kevin Goldsmith <kgoldsmith@anaconda.com>
Co-authored-by: Matt Kramer <mkramer@anaconda.com>
* start removing tailwind and rebuilding some css
* add css to pybox and add class to repl
* set output component visibility
* replace tailwind class with single component class
* add styles to css
* replace classes on button
* replace classes on input
* replace classes in title
* replace classes on list
* replace classes
* add new style file
* add list element style
* remove tailwind classes from todo example
* revert link on examples files
* remove tailwind config files
* remove commented old code
* add missing ;
* add section and cleared up documentation
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* I fixed the typo in getting-started
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* add release.yml, release automation ready for prod
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update .github/workflows/build-release.yml
Co-authored-by: Antonio Cuni <anto.cuni@gmail.com>
* dont overwrite /alpha/ and change unstable to latest
* alpha -> releases
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Antonio Cuni <anto.cuni@gmail.com>
* Add GHA to push issues directly to dashboard
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
Co-authored-by: mariana <marianameireles@protonmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* Simplify tests with pytest-playwright
* Add pytest-playwright to pip
* Fix simple_clock example
* Attempt to make example tests more robust
* Make pre-commit happy
* Revert accidental change to simple_clock pyscript resources
* Another attempt at reducing flakeyness
* Do not wait until page load event is fired
* Remove pointless py-config
Co-authored-by: mariana <marianameireles@protonmail.com>
* workflow updates
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* build release
* remove if
* test on main
* update docs release workflow
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* Added card components for basic examples
* Added card components for mime rendering
* fix anchor tag inside anchor tag
* Added card components for js interaction
* Added card components for visualizations e dashboards
* Refactor card components responsive
* Fix href Fractals with NumPy and canvas
* Refactor quote format
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Added css files
* Refactor card components for basic examples
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Rename global file to main
* Add css variables
* Refactor card components
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Refactor move css files into css folder
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* Adding FAQ topic and link from main index
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Adding periods
* fix typo
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Adds utils.htmlDecode arround innerHTML to read the code for <py-repl> and
<py-script>, which preserves all newlines, tabs, and < & > characters.
Fix bug #480
* Fix conflict
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
Co-authored-by: mariana <marianameireles@protonmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* add output div visibility rule and make sure CustomWidget is being registered
* add new runAfterRuntimeInitialized method that classes can use to run code only after runtime actually initialized
* replace setTimout with proper event to wait for runtime to be completed
* replace setTimout on pyinpytbox with proper event to wait for runtime to be completed
* Only run docs review workflow on non-forks.
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* Chnage the metadata format
* Add syntax highlighting
* have simple_clock example run from local build to test change
Co-authored-by: Fabio Pliger <fabio.pliger@gmail.com>
* update README.md
Corrected the grammatical mistakes to make the documents easier to read and understand.
* update README.md
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update README.md
made required changes
* update CONTRIBUTING.md
made necessary changes.
* fixed a typo in CONTRIBUTING.md
* removed unnecessary file
* removed unnecessary file
* removed unnecessary words
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* return on \n before empty div is appended
* use appendOutput with out.write
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
Co-authored-by: Mariano Weber <info@uiremotely.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* Added bug report and feature request issue forms
* Update bug-report.yml
Added browsers dropdown to bugs
* Added misc issue type
* Add keypress event to todo example (#241)
* add enter keypress event in todo example
* fix linting
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* Changed variable names to snake_case for PEP8 formatting (#211)
* Changed variable names to snakecase for PEP8 formatting.
* Changed variable names to snakecase for PEP8 formatting.
* fix indentation
Co-authored-by: Fabio Pliger <fabio.pliger@gmail.com>
* Add issue templates (#252)
* add issue templates
* incorporate @fpliger suggestions
* Removed mardown files. Added link for questions
* Updated browser dev console info
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Minor typo
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Fix issue with labels that should be strings, ignore pretty-format of ISSUE_TEMPLATE yaml files
* Removed old md. Updated label
* add the needs-triage label to all new issues
Co-authored-by: Allan Lago <35788148+alago1@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Jason Barnwell <master.j1994@gmail.com>
Co-authored-by: Fabio Pliger <fabio.pliger@gmail.com>
Co-authored-by: Antonio Cuni <anto.cuni@gmail.com>
Co-authored-by: Matt Kramer <mkramer@anaconda.com>
* Move tests, create makefile action to run tests on examples
* Correct import file for html files
* Build environment for tests
* Fix the CI
* rearrange CI
* fix find cmd and make sure we don't delete the folder implicitly
* more rearranging
* fix folder permissions and custom sed for subfolders
* add toga wheels files
* re-add missing file
* mirror latest changes in alpha ci
* fix find cmd
* try different fix for find
* remove redundant build
Co-authored-by: mariana <marianameireles@protonmail.com>
Co-authored-by: pww217 <pwilson@anaconda.com>
Co-authored-by: Fabio Pliger <fabio.pliger@gmail.com>
* fix OutputManager _append setter
* fix OutputManager change parameters
* fix OutputCtxManager __init__ and change methods
* replacing OutputManager pyscript.write with write function
* add optional output-append attribute to py-repl
* add appendOutput(default: true) to base component
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update pyscriptjs/src/components/pyrepl.ts
Co-authored-by: woxtu <woxtup@gmail.com>
* change from output-append flag to output-mode attribute
* removed type annotation
* repositioned setOutputMode call for auto-generated REPLs to work
* fixed indentation error for indented input
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* added preEvaluate method
* moved output-mode logic to preEvaluate
* remove static write method from PyScript, add write method to Element
* removed err parameter from OutputCtxManager
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* add PyScript.write back with a deprecation warning
* fix wrong input name
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: woxtu <woxtup@gmail.com>
Co-authored-by: Fabio Pliger <fabio.pliger@gmail.com>
* new testing ci flow
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* install conda
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* test conda
* pre-commit fix
* remove if
* makefile fix
* fix pytest install
* argument for test
* restructure
* fix sync
* full path filter
* use setup-condav2
* syntax
* test path
* add binary argument
* remove which
* Update Makefile
* remove arguments
* trigger CI
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* Add type annotations
* Replace `StateCommand` with `Command`
* Revert "Replace `StateCommand` with `Command`"
This reverts commit 2dfc2d34e4.
* Fix the return value
* add missing tags in getting started
* add py-config tag to getting started
* Edits to Fabio's tags/definitions
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update getting-started.md
Co-authored-by: Idan <ienglander@anaconda.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: idanenglander <60263976+idanenglander@users.noreply.github.com>
* Added microsoft channel and playwright as dependency
* Added test-setup to run
* Basic tests for each example in examples/index.html
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update test_webgl_raycaster_index.py
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update test_folium.py
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update test_folium.py
* Update test_folium.py
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update test_bokeh.py
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Whitelisting assertion statements in test files
* Updated bare execept statements with ImportError
* Flake8 compliance
* Updated message
* Removed 'make test-setup'
* Removed @echo from make test
* Uncommented Toga test
* Removed __test_all__.py file
* Removing unnecessary files
* Removed individual test files
* conftest.py with all data for running tests
* Consolidated test file
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Fixed pre-commit flake8 issues
* flake8 issue
* add playwright installation to setup
* Testing parameterization and webserver to serve examples locally
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Flake8 compliance
* More flake8
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Michael Verhulst <michael@terminallabs.com>
Co-authored-by: Fabio Pliger <fabio.pliger@gmail.com>
* Embedding video, adding PS tag definitions
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* html -> HTML; add sphinxcontrib.youtube to env.yml
* change place of sphinxcontrib.youtube in env.yml
* one more sphinxcontrib-youtube change
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* Add onscreen error when using py-env paths in local HTTP files without file server
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Remove redundant code, fix error handling, add 404 error
* Lint and Format
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* manage errors loading files
* use handleFetchError for handling fetch errors in env
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Fabio Pliger <fabio.pliger@gmail.com>
* Initial setup.
This does a few things:
- Adds some placeholders following the Diátaxis framework (https://diataxis.fr)
- Sets up Sphinx with MyST parser for Markdown in addition to rST.
- Uses the well-known PyData Sphinx theme.
- Moves some already existing Markdown files into the docs directory.
- Sets up the initial doc review GitHub action to auto-deploy to GitHub pages.
* Activate conda env.
* Remove custom action.
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Make the dir.
* Push directly
* Add readthedocs config.
* Disable GitHub pages deployment for now.
* Add release and latest workflows as well.
* Make clear that this is work in progress.
* Made docs merge ready, added What is PyScript section with example.
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Replace `on:tags:` with `on:create:`
The existing trigger is apparently not in the GHA spec
* Pretty format YAML
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* add s3 sync and permissions
* Leave status message in PR.
* Redirect from docs.pyscript.net/ to docs.pyscript.net/latest/
* Delete latest directory before deployment.
* Update review and release workflows, too.
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Allow access to S3 for review and release doc workflow.
* Fix name of workflow.
* Bump up Python version.
* Because YAML.
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Revert move to 3.10.
* Fix sitemap.
* Remove status settgin from release and latest build.
* Comment out cleanup.
* Add write permissions for statuses.
* More permissions?
* Fix artifact name.
* Use appropriate concurrency.
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* .zip not needed
* Align name of workflows with CI workflows.
* Add checks permission.
* Set a notice instead.
* Move to sphinx-design.
* Add sphinx-autobuild.
* Use frontmatter more.
* Add section for mdformat but disable it for now.
See https://github.com/executablebooks/mdformat-myst/pull/9 for more details.
* Fix fencing.
* Actually using html renderer.
* Revert moving governance files.
* Use full URLs for governance docs.
* Added warning.
* Fix copyright and author.
* Another minor fix.
* Use GitHub Action summary instead of notice.
* Fix variable name.
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Matt Kramer <mkramer@anaconda.com>
Co-authored-by: ximena9201 <ximenandrea.ro@gmail.com>
Going through bugs and issues takes up a lot of time, so please be so kind and take a few minutes to fill out all the areas to the best of your ability.
There will always be more issues than there is time to do them, and so we will need to selectively close issues that don't provide enough information, so we can focus our time on helping people like you who fill out the issue form completely. Thank you for your collaboration!
There are also already a lot of open issues, so please take 2 minutes and search through existing ones to see if what you are experiencing already exists
Thanks for helping PyScript be amazing. We are nothing without people like you helping build a better community 💐!
- type:checkboxes
id:checks
attributes:
label:Checklist
description:Please confirm and check all the following options.
options:
- label:I added a descriptive title
required:true
- label:I searched for other issues and couldn't find a solution or duplication
required:true
- label:I already searched in Google and didn't find any good information or help
required:true
- type:textarea
id:what-happened
attributes:
label:What happened?
description:And what should have happened instead? This really helps everyone review quicker and greatly increases the chance that someone can get around to solve your issue
placeholder:Tell us what you see!
validations:
required:true
- type:dropdown
id:browsers
attributes:
label:What browsers are you seeing the problem on? (if applicable)
multiple:true
options:
- Firefox
- Chrome
- Safari
- Microsoft Edge
- Other
validations:
required:false
- type:textarea
id:list
attributes:
label:Console info
description:|
If there are errors in your browser console then its helpful to be able to troubleshoot.
- Chrome , Firefox, and Edge: Right-click on the page and select *Inspect*. Alternatively you can press F12 on your keyboard.
<!--Please describe the changes in your pull request in few words here. -->
## Changes
<!-- List the changes done to fix a bug or introduce a new feature.Please note both user-facing changes and changes to internal API's here -->
## Checklist
<!-- Note: Only user-facing changes require a changelog entry. Internal-only API changes do not require a changelog entry. Changes in documentation do not require a changelog entry. -->
- [ ] All tests pass locally
- [ ] I have updated `CHANGELOG.md`
- [ ] I have created documentation for this(if applicable)
- Added the `xterm` attribute to `py-config`. When set to `True` or `xterm`, an (output-only) [xterm.js](http://xtermjs.org/) terminal will be used in place of the default py-terminal.
- The default version of Pyodide is now `0.23.2`. See the [Pyodide Changelog](https://pyodide.org/en/stable/project/changelog.html#version-0-23-2) for a detailed list of changes.
- Added the `@when` decorator for attaching Python functions as event handlers
- The `py-mount` attribute on HTML elements has been deprecated, and will be removed in a future release.
#### Runtime py- attributes
- Added logic to react to `py-*` attributes changes, removal, `py-*` attributes added to already live nodes but also `py-*` attributes added or defined via injected nodes (either appended or via `innerHTML` operations). ([#1435](https://github.com/pyscript/pyscript/pull/1435))
#### <script type="py">
- Added the ability to optionally use `<script type="py">`, `<script type="pyscript">` or `<script type="py-script">` instead of a `<py-script>` custom element, in order to tackle cases where the content of the `<py-script>` tag, inevitably parsed by browsers, could accidentally contain _HTML_ able to break the surrounding page layout. ([#1396](https://github.com/pyscript/pyscript/pull/1396))
#### <py-terminal>
- Added a `docked` field and attribute for the `<py-terminal>` custom element, enabled by default when the terminal is in `auto` mode, and able to dock the terminal at the bottom of the page with auto scroll on new code execution.
#### <py-script>
- Restored the `output` attribute of `py-script` tags to route `sys.stdout` to a DOM element with the given ID. ([#1063](https://github.com/pyscript/pyscript/pull/1063))
- Added a `stderr` attribute of `py-script` tags to route `sys.stderr` to a DOM element with the given ID. ([#1063](https://github.com/pyscript/pyscript/pull/1063))
#### <py-repl>
- The `output` attribute of `py-repl` tags now specifies the id of the DOM element that `sys.stdout`, `sys.stderr`, and the results of a REPL execution are written to. It no longer affects the location of calls to `display()`
- Added a `stderr` attribute of `py-repl` tags to route `sys.stderr` to a DOM element with the given ID. ([#1106](https://github.com/pyscript/pyscript/pull/1106))
- Resored the `output-mode` attribute of `py-repl` tags. If `output-mode` == 'append', the DOM element where output is printed is _not_ cleared before writing new results.
- Load code from the attribute src of py-repl and preload it into the corresponding py-repl tag by use the attribute `str` in your `py-repl` tag([#1292](https://github.com/pyscript/pyscript/pull/1292))
- <py-repl> elements now have a `getPySrc()` method, which returns the code inside the REPL as a string.([#1516](https://github.com/pyscript/pyscript/pull/1292))
#### Plugins
- Plugins may now implement the `beforePyReplExec()` and `afterPyReplExec()` hooks, which are called immediately before and after code in a `py-repl` tag is executed. ([#1106](https://github.com/pyscript/pyscript/pull/1106))
#### Web worker support
- introduced the new experimental `execution_thread` config option: if you set `execution_thread = "worker"`, the python interpreter runs inside a web worker
- worker support is still **very** experimental: not everything works, use it at your own risk
### Bug fixes
- Fixes [#1280](https://github.com/pyscript/pyscript/issues/1280), which describes the errors on the PyRepl tests related to having auto-gen tags that shouldn't be there.
### Enhancements
- Py-REPL tests now run on both osx and non osx OSs
- migrated from _rollup_ to _esbuild_ to create artifacts
- updated `@codemirror` dependency to its latest
### Docs
- Add docs for event handlers
## 2023.03.1
### Features
### Bug fixes
- Fixed an issue where `pyscript` would not be available when using the minified version of PyScript. ([#1054](https://github.com/pyscript/pyscript/pull/1054))
- Fixed missing closing tag when rendering an image with `display`. ([#1058](https://github.com/pyscript/pyscript/pull/1058))
- Fixed a bug where Python plugins methods were being executed twice. ([#1064](https://github.com/pyscript/pyscript/pull/1064))
### Enhancements
- When adding a `py-` attribute to an element but didn't added an `id` attribute, PyScript will now generate a random ID for the element instead of throwing an error which caused the splash screen to not shutdown. ([#1122](https://github.com/pyscript/pyscript/pull/1122))
- You can now disable the splashscreen by setting `enabled = false` in your `py-config` under the `[splashscreen]` configuration section. ([#1138](https://github.com/pyscript/pyscript/pull/1138))
### Documentation
- Fixed 'Direct usage of document is deprecated' warning in the getting started guide. ([#1052](https://github.com/pyscript/pyscript/pull/1052))
- Added reference documentation for the `py-splashscreen` plugin ([#1138](https://github.com/pyscript/pyscript/pull/1138))
- Adds doc for installing tests ([#1156](https://github.com/pyscript/pyscript/pull/1156))
- Adds docs for custom Pyscript attributes (`py-*`) that allow you to add event listeners to an element ([#1125](https://github.com/pyscript/pyscript/pull/1125))
### Deprecations and Removals
- The py-config `runtimes` to specify an interpreter has been deprecated. The `interpreters` config should be used instead. ([#1082](https://github.com/pyscript/pyscript/pull/1082))
- The attributes `pys-onClick` and `pys-onKeyDown` have been deprecated, but the warning was only shown in the console. An alert banner will now be shown on the page if the attributes are used. They will be removed in the next release. ([#1084](https://github.com/pyscript/pyscript/pull/1084))
- The pyscript elements `py-button`, `py-inputbox`, `py-box` and `py-title` have now completed their deprecation cycle and have been removed. ([#1084](https://github.com/pyscript/pyscript/pull/1084))
- The attributes `pys-onClick` and `pys-onKeyDown` have been removed. Use `py-click` and `py-keydown` instead ([#1361](https://github.com/pyscript/pyscript/pull/1361))
* [License terms for contributions](#license-terms-for-contributions)
- [Setting up your local environment and developing](#setting-up-your-local-environment-and-developing)
* [Becoming a maintainer](#becoming-a-maintainer)
- [Developing](#developing)
* [Trademarks](#trademarks)
- [Rebasing changes](#rebasing-changes)
- [Building the docs](#building-the-docs)
- [Places to start](#places-to-start)
- [Setting up your local environment and developing](#setting-up-your-local-environment-and-developing)
- [Submitting a change](#submitting-a-change)
- [License terms for contributions](#license-terms-for-contributions)
- [Becoming a maintainer](#becoming-a-maintainer)
- [Trademarks](#trademarks)
## Code of Conduct
# Code of Conduct
The [PyScript Code of Conduct](https://github.com/pyscript/governance/blob/main/CODE-OF-CONDUCT.md) governs the project and everyone participating in it. By participating, you are expected to uphold this code. Please report unacceptable behavior to the maintainers or administrators as described in that document.
The [PyScript Code of Conduct](https://github.com/pyscript/governance/blob/main/CODE-OF-CONDUCT.md) governs the project and everyone participating in it. By participating, you are expected to uphold this code. Please report unacceptable behavior to the maintainers or administrators as described in that document.
## Contributing
# Contributing
### Reporting bugs
## Reporting bugs
Bugs are tracked on the [project issues page](https://github.com/pyscript/pyscript/issues). Please check if your issue has already been filed by someone else by searching the existing issues before filing a new one. Once your issue is filed, it will be triaged by another contributor or maintainer. If there are questions raised about your issue, please respond promptly.
Bugs are tracked on the [project issues page](https://github.com/pyscript/pyscript/issues). Please check if your issue has already been filed by someone else by searching the existing issues before filing a new one. Once your issue is filed, it will be triaged by another contributor or maintainer. If there are questions raised about your issue, please respond promptly.
#### Creating useful issues
## Creating useful issues
* Use a clear and descriptive title.
- Use a clear and descriptive title.
* Describe the specific steps that reproduce the problem with as many details as possible so that someone can verify the issue.
- Describe the specific steps that reproduce the problem with as many details as possible so that someone can verify the issue.
* Describe the behavior you observed, and the behavior you had expected.
- Describe the behavior you observed, and the behavior you had expected.
* Include screenshots if they help make the issue clear.
- Include screenshots if they help make the issue clear.
### Reporting security issues
## Reporting security issues
If you aren't confident that it is appropriate to submit a security issue using the above process, you can e-mail it to security@pyscript.net
If you aren't confident that it is appropriate to submit a security issue using the above process, you can e-mail it to security@pyscript.net
### Asking questions
## Asking questions
If you have questions about the project, using PyScript, or anything else, please ask in the [PyScript forum](https://community.anaconda.cloud/c/tech-topics/pyscript).
If you have questions about the project, using PyScript, or anything else, please ask in the [PyScript forum](https://community.anaconda.cloud/c/tech-topics/pyscript).
### Setting up your environment
## Places to start
* clone the repo
If you would like to contribute to PyScript, but you aren't sure where to begin, here are some suggestions:
```
git clone https://github.com/pyscript/pyscript
```
* cd into the main project folder
```
cd pyscript/pyscriptjs
```
* install the dependencies with npm install - make sure to use nodejs version >= 16
```
npm install
```
* run npm run dev to build and run the dev server. This will also watch for changes and rebuild when a file is saved.
```
npm run dev
```
### Places to start
-**Read over the existing documentation.** Are there things missing, or could they be clearer? Make some changes/additions to those documents.
-**Review the open issues.** Are they clear? Can you reproduce them? You can add comments, clarifications, or additions to those issues. If you think you have an idea of how to address the issue, submit a fix!
-**Look over the open pull requests.** Do you have comments or suggestions for the proposed changes? Add them.
-**Check out the examples.** Is there a use case that would be good to have sample code for? Create an example for it.
If you would like to contribute to PyScript, but you aren't sure where to begin, here are some suggestions.
## Setting up your local environment and developing
* **Read over the existing documentation.** Are there things missing, or could they be clearer? Make some changes/additions to those documents.
If you would like to contribute to PyScript, you will need to set up a local development environment. The [following instructions](https://pyscript.github.io/docs/latest/development/setting-up-environment.html) will help you get started.
* **Review the open issues.** Are they clear? Can you reproduce them? You can add comments, clarifications, or additions to those issues. If you think you have an idea of how to address the issue, submit a fix!
* **Look over the open pull requests.** Do you have comments or suggestions for the proposed changes? Add them.
* **Check out the examples.** Is there a use case that would be good to have sample code for? Create an example for it.
### Submitting a change
You can also read about PyScript's [development process](https://pyscript.github.io/docs/latest/development/developing.html) to learn how to contribute code to PyScript, how to run tests and what's the PR etiquette of the community!
All contributions must be licensed Apache 2.0, and all files must have a copy of the boilerplate license comment (can be copied from an existing file).
To create a change for PyScript, you can follow the process described [here](https://docs.github.com/en/get-started/quickstart/contributing-to-projects).
* Fork a personal copy of the PyScript project.
* Make the changes you would like (don't forget to test them!)
* Please squash all commits for a change into a single commit (this can be done using "git rebase -i"). Do your best to have a well-formed commit message for the change.
* Open a pull request back to the PyScript project and address any comments/questions from the maintainers and other contributors.
## License terms for contributions
## License terms for contributions
@@ -86,12 +69,13 @@ This Project welcomes contributions, suggestions, and feedback. All contribution
## Becoming a maintainer
## Becoming a maintainer
Contributors are invited to be maintainers to the project by demonstrating good decision making in their contributions, a commitment to the goals of the project, and consistent adherence to the [code of conduct](https://github.com/pyscript/governance/blob/main/CODE-OF-CONDUCT.md). New maintainers are invited by a 3/4 vote of the existing maintainers.
Contributors are invited to be maintainers of the project by demonstrating good decision making in their contributions, a commitment to the goals of the project, and consistent adherence to the [code of conduct](https://github.com/pyscript/governance/blob/main/CODE-OF-CONDUCT.md). New maintainers are invited by a 3/4 vote of the existing maintainers.
## Trademarks
## Trademarks
The Project abides by the Organization's [trademark policy](https://github.com/pyscript/governance/blob/main/TRADEMARKS.md).
The Project abides by the Organization's [trademark policy](https://github.com/pyscript/governance/blob/main/TRADEMARKS.md).
---
---
Part of MVG-0.1-beta.
Part of MVG-0.1-beta.
Made with love by GitHub. Licensed under the [CC-BY 4.0 License](https://creativecommons.org/licenses/by-sa/4.0/).
Made with love by GitHub. Licensed under the [CC-BY 4.0 License](https://creativecommons.org/licenses/by-sa/4.0/).
pyscript.write('pi', f'π is approximately {pi:.3f}')
</py-script>
</body>
</html>
```
## Packages and modules
In addition to the [Python Standard Library](https://docs.python.org/3/library/) and
the `pyscript` module, many 3rd-party OSS packages will work out-of-the-box with PyScript.
In order to use them you will need to declare the dependencies using the `<py-env>` in the
HTML head. You can also link to `.whl` files directly on disk like in our [toga example](https://github.com/pyscript/pyscript/blob/main/pyscriptjs/examples/toga/freedom.html)
If your `.whl` is not a pure Python wheel, then open a PR or issue with [pyodide](https://github.com/pyodide/pyodide) to get it added [here](https://github.com/pyodide/pyodide/tree/main/packages).
If there's enough popular demand the pyodide team will likely work on supporting your package, regardless things will likely move faster if you make the PR and consult with the team to get unblocked.
For example, NumPy and Matplotlib are available. Notice here we're using `<py-script output="plot">`
as a shortcut, which takes the expression on the last line of the script and runs `pyscript.write('plot', fig)`.
This document provides the governance policy for the Project. Maintainers agree to this policy and to abide by all Project polices, including the [code of conduct](https://github.com/pyscript/governance/blob/main/CODE-OF-CONDUCT.md), [trademark policy](https://github.com/pyscript/governance/blob/main/TRADEMARKS.md), and [antitrust policy](https://github.com/pyscript/governance/blob/main/ANTITRUST.md) by adding their name to the [maintainers.md file](./MAINTAINERS.md).
This document provides the governance policy for the Project. Maintainers agree to this policy and to abide by all Project policies, including the [code of conduct](https://github.com/pyscript/governance/blob/main/CODE-OF-CONDUCT.md), [trademark policy](https://github.com/pyscript/governance/blob/main/TRADEMARKS.md), and [antitrust policy](https://github.com/pyscript/governance/blob/main/ANTITRUST.md) by adding their name to the [maintainers.md file](https://github.com/pyscript/pyscript/blob/main/MAINTAINERS.md).
## 1. Roles.
## 1. Roles.
@@ -41,5 +41,6 @@ Any names, trademarks, logos, or goodwill developed by and associated with the P
Amendments to this governance policy may be made by affirmative vote of 2/3 of all Maintainers, with approval by the Organization's Steering Committee.
Amendments to this governance policy may be made by affirmative vote of 2/3 of all Maintainers, with approval by the Organization's Steering Committee.
---
---
Part of MVG-0.1-beta.
Part of MVG-0.1-beta.
Made with love by GitHub. Licensed under the [CC-BY 4.0 License](https://creativecommons.org/licenses/by-sa/4.0/).
Made with love by GitHub. Licensed under the [CC-BY 4.0 License](https://creativecommons.org/licenses/by-sa/4.0/).
This document lists the Maintainers of the Project. Maintainers may be added once approved by the existing maintainers as described in the [Governance document](./GOVERNANCE.md). By adding your name to this list you are agreeing to abide by the Project governance documents and to abide by all of the Organization's polices, including the [code of conduct](https://github.com/pyscript/governance/blob/main/CODE-OF-CONDUCT.md), [trademark policy](https://github.com/pyscript/governance/blob/main/TRADEMARKS.md), and [antitrust policy](https://github.com/pyscript/governance/blob/main/TRADEMARKS.md). If you are participating because of your affiliation with another organization (designated below), you represent that you have the authority to bind that organization to these policies.
This document lists the Maintainers of the Project. Maintainers may be added once approved by the existing maintainers as described in the [Governance document](https://github.com/pyscript/pyscript/blob/main/GOVERNANCE.md). By adding your name to this list you are agreeing to abide by the Project governance documents and to abide by all of the Organization's polices, including the [code of conduct](https://github.com/pyscript/governance/blob/main/CODE-OF-CONDUCT.md), [trademark policy](https://github.com/pyscript/governance/blob/main/TRADEMARKS.md), and [antitrust policy](https://github.com/pyscript/governance/blob/main/TRADEMARKS.md). If you are participating because of your affiliation with another organization (designated below), you represent that you have the authority to bind that organization to these policies.
| **NAME** | **Organization** |
| **NAME** | **Organization** |
| --- | --- |
| -------------------- | ---------------- |
| Fabio Pliger | Anaconda, Inc |
| Fabio Pliger | Anaconda, Inc |
| Antonio Cuni | Anaconda, Inc |
| Antonio Cuni | Anaconda, Inc |
| Philipp Rudiger | Anaconda, Inc |
| Philipp Rudiger | Anaconda, Inc |
| Peter Wang | Anaconda, Inc |
| Peter Wang | Anaconda, Inc |
| Kevin Goldsmith | Anaconda, Inc |
| Kevin Goldsmith | Anaconda, Inc |
| Mariana Meireles | Anaconda, Inc |
| Mariana Meireles | |
| --- | --- |
| Nicholas H.Tollervey | Anaconda, Inc |
| Madhur Tandon | Anaconda, Inc |
| Ted Patrick | Anaconda, Inc |
| Jeff Glass | |
| Paul Everitt | |
| Fabio Rosado | Anaconda, Inc |
| Andrea Giammarchi | Anaconda, Inc |
---
---
Part of MVG-0.1-beta.
Part of MVG-0.1-beta.
Made with love by GitHub. Licensed under the [CC-BY 4.0 License](https://creativecommons.org/licenses/by-sa/4.0/).
Made with love by GitHub. Licensed under the [CC-BY 4.0 License](https://creativecommons.org/licenses/by-sa/4.0/).
PyScript is a Pythonic alternative to Scratch, JSFiddle, and other "easy to use" programming frameworks, with the goal of making the web a friendly, hackable place where anyone can author interesting and interactive applications.
To get started see [GETTING-STARTED](GETTING-STARTED.md).
PyScript is a framework that allows users to create rich Python applications in the browser using HTML's interface and the power of [Pyodide](https://pyodide.org/en/stable/), [MicroPython](https://micropython.org/) and [WASM](https://webassembly.org/), and modern web technologies.
For examples see [the pyscript folder](pyscriptjs).
To get started see the [Beginning PyScript tutorial](https://docs.pyscript.net/latest/beginning-pyscript/).
For examples see [here](https://pyscript.com/@examples).
Other useful resources:
- The [official technical docs](https://docs.pyscript.net/).
- Our current [Home Page](https://pyscript.net/) on the web.
- A free-to-use [online editor](https://pyscript.com/) for trying PyScript.
- Our community [Discord Channel](https://discord.gg/BYB2kvyFwm), to keep in touch .
Every Tuesday at 15:30 UTC there is the _PyScript Community Call_ on zoom, where we can talk about PyScript development in the open. Most of the maintainers regularly participate in the call, and everybody is welcome to join.
Every other Thursday at 16:00 UTC there is the _PyScript FUN_ call: this is a call in which everybody is encouraged to show what they did with PyScript.
For more details on how to join the calls and up to date schedule, consult the official calendar:
- [Google calendar](https://calendar.google.com/calendar/u/0/embed?src=d3afdd81f9c132a8c8f3290f5cc5966adebdf61017fca784eef0f6be9fd519e0@group.calendar.google.com&ctz=UTC) in UTC time;
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.
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
## Try PyScript
To try PyScript, import the appropriate pyscript files to your html page with:
To try PyScript, import the appropriate pyscript files into the `<head>` tag of your html page:
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
You can then use PyScript components in your html page. PyScript currently offers various ways of running Python code:
*`<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 [pyscriptjs/examples](pyscriptjs/examples) folder for more examples on how to use it, all you need to do is open them in Chrome.
-`<script type="py">`: can be used to define python code that is executable within the web page.
-`<script type="py" src="hello.py">`: same as above, but the python source is fetched from the given URL.
-`<script type="py" terminal>`: same as above, but also creates a terminal where to display stdout and stderr (e.g., the output of `print()`); `input()` does not work.
-`<script type="py" terminal worker>`: run Python inside a web worker: the terminal is fully functional and `input()` works.
-`<py-script>`: same as `<script type="py">`, but it is not recommended because if the code contains HTML tags, they could be parsed wrongly.
-`<script type="mpy">`: same as above but use MicroPython instead of Python.
Check out the [official docs](https://docs.pyscript.net/) for more detailed documentation.
## How to Contribute
## How to Contribute
To contribute see the [CONTRIBUTING](CONTRIBUTING.md) document.
Read the [contributing guide](CONTRIBUTING.md) to learn about our development process, reporting bugs and improvements, creating issues and asking questions.
## Resources
Check out the [developing process](https://pyscript.github.io/docs/latest/contributing) documentation for more information on how to setup your development environment.
This page is meant for troubleshooting common problems with PyScript.
## Table of contents:
- [Make Setup](#make-setup)
## Make setup
A lot of problems related to `make setup` are related to node and npm being outdated. Once npm and node are updated, `make setup` should work. You can follow the steps on the [npm documentation](https://docs.npmjs.com/try-the-latest-stable-version-of-npm) to update npm (the update command for Linux should work for Mac as well). Once npm has been updated you can continue to the instructions to update node below.
To update Node run the following commands in order (Most likely you'll be prompted for your user password, this is normal):
We have moved and renamed previous _core_ module as [polyscript](https://github.com/pyscript/polyscript/#readme), which is the base module used in here to build up _PyScript Next_, now hosted in this folder.
## Documentation
Please read [core documentation](./docs/README.md) to know more about this project.
## Development
Clone this repository then run `npm install` within its folder.
Use `npm run build` to create all artifacts and _dist_ files.
Use `npm run server` to test locally, via the `http://localhost:8080/test/` url, smoke tests or to test manually anything you'd like to check.
### Artifacts
There are two main artifacts in this project:
-**stdlib** and its content, where `src/stdlib/pyscript.js` exposes as object literal all the _Python_ content within the folder (recursively)
-**plugins** and its content, where `src/plugins.js` exposes all available _dynamic imports_, able to instrument the bundler to create files a part within the _dist/_ folder, so that by default _core_ remains as small as possible
Accordingly, whenever a file contains this warning at its first line, please do not change such file directly before submitting a merge request, as that file will be overwritten at the next `npm run build` command, either here or in _CI_:
```js
// ⚠️ This file is an artifact: DO NOT MODIFY
```
### Running tests
Before running the tests, we need to create a tests environment first. To do so run the following command from the root folder of the project:
```
make setup
```
This will create a tests environment [in the root of the project, named `./env`]and install all the dependencies needed to run the tests.
After the command has completed and the tests environment has been created, you can run the **integration tests** with
the following command:
```
make test-integration
```
## `pyscript` python package
The `pyscript` package available in _Python_ lives in the folder `src/stdlib/pyscript/`.
All _Python_ files will be embedded automatically whenever `npm run build` happens and reflected into the `src/stdlib/pyscript.js` file.
It is _core_ responsibility to ensure those files will be available through the Filesystem in either the _main_ thread, or any _worker_.
## JS plugins
While community or third party plugins don't need to be part of this repository and can be added just importing `@pyscript/core` as module, there are a few plugins that we would like to make available by default and these are considered _core plugins_.
To add a _core plugin_ to this project you can define your plugin entry-point and name in the `src/plugins` folder (see the `error.js` example) and create, if necessary, a folder with the same name where extra files or dependencies can be added.
The _build_ command will bring plugins by name as artifact so that the bundler can create ad-hoc files within the `dist/` folder.
<sup>A summary of <code>@pyscript/core</code> features</sup>
### Getting started
Differently from [pyscript classic](https://github.com/pyscript/pyscript), where "*classic*" is the disambiguation name we use to describe the two versions of the project, `@pyscript/core` is an *ECMAScript Module* with the follow benefits:
* it doesn't block the page like a regular script, without a `deferred` attribute, would
* it allows modularity in the future
* it bootstraps itself once but it allows exports via the module
Accordingly, this is the bare minimum required output to bootstrap *PyScript Next* in your page via a CDN:
```html
<!-- Option 1: based on esm.sh which in turns is jsdlvr -->
<!-- Option X: any CDN that uses npmjs registry should work -->
```
Once the module is loaded, any `<script type="py"></script>` on the page, or any `<py-script>` tag, would automatically run its own code or the file defined as `src` attribute, after bootstrapping the *pyodide* interpreter.
If no `<script type="py">` or `<py-script>` tag is present, it is still possible to use the module to bootstrap via JS a *Worker*, bypassing the need to bootstrap *pyodide* on the main thread, hence without ever blocking the page.
Alternatively, it is possible to specify a `worker` attribute to either run embedded code or the provided `src` file.
#### CSS
If you are planning to use either `<py-config>` or `<py-script>` tags on the page, where latter case is usually better off with `<script type="py">` instead, you can also use CDNs to land our custom CSS:
```html
<!-- Option 1: based on esm.sh which in turns is jsdlvr -->
<!-- Option X: any CDN that uses npmjs registry should work -->
```
The CSS is needed to avoid seeing content on the page before *PyScript* gets a chance to initialize itself. This means both `py-config` and `py-script` tags will have a `display:none` property which is overwritten by *PyScript* once it initialize each `py-script` custom element.
Once again, if you use `<script type="py">` instead, you won't need CSS unless you also have a `py-config` on the page, instead of using an external `config` file, defined via the `config` attribute:
```html
<scripttype="py"config="./config.toml">
frompyscriptimportdisplay
display("Hello PyScript Next")
</script>
```
#### HTML Example
This is a complete reference to bootstrap *PyScript* in a HTML document.
Either `<script type="py">` or `<py-script>` can have zero, one or more attributes:
* **src** if defined, the content of the tag is ignored and the *Python* code in the file will be evaluated instead.
* **config** if defined, the code will be evaluated after the configuration has been parsed but this can also be directly *JSON* so that both `config='{"packages":["numpy"]}'` and `config="./config.json"`, or `config="./config.toml"`, would be valid options.
* **async** if present, it will run the *Python* code asynchronously.
* **worker** if present, it will not bootstrap *pyodide* on the main page, only on the worker file it points at, as in `<script type="py" worker="./worker.py"></script>`. Both `async` and `config` attributes are also available and used to bootstrap the worker as desired.
Please note that other [polyscript's attributes](https://pyscript.github.io/polyscript/#script-attributes) are available too but their usage is more advanced.
## JS Module API
The module itself is currently exporting the following utilities:
* **PyWorker**, which allows to bootstrap a *worker* with *pyodide* and the *pyscript* module available within the code. This callback accepts a file as argument, and an additional, and optional, `options` object literal, able to understand a `config`, which could also be directly a *JS* object literal instead of a JSON string or a file to point at, and `async` which if `true` will run the worker code with top level await enabled. Please note that the returned reference is exactly the same as [the polyscript's XWorker](https://pyscript.github.io/polyscript/#the-xworker-reference), exposing exact same utilities but granting on bootstrap all hooks are in place and the type is always *pyodide*.
* **hooks**, which allows plugins to define *ASAP* callbacks or strings that should be executed either in the main thread or the worker before, or after, the code has been executed.
// each function is invoked before or after python gets executed
// via: callback(pyScriptUtils, currentElement)
/** @type {Set<function>} */
onBeforeRun:newSet(),
/** @type {Set<function>} */
onBeforeRunAync:newSet(),
/** @type {Set<function>} */
onAfterRun:newSet(),
/** @type {Set<function>} */
onAfterRunAsync:newSet(),
// each function is invoked once when PyScript is ready
// and for each element via: callback(pyScriptUtils, currentElement)
/** @type {Set<function>} */
onInterpreterReady:newSet(),
// each string is prepended or appended to the worker code
/** @type {Set<string>} */
codeBeforeRunWorker:newSet(),
/** @type {Set<string>} */
codeBeforeRunWorkerAsync:newSet(),
/** @type {Set<string>} */
codeAfterRunWorker:newSet(),
/** @type {Set<string>} */
codeAfterRunWorkerAsync:newSet(),
})
```
Please note that a *worker* is a completely different environment and it's not possible, by specifications, to pass a callback to it, which is why worker sets are strings and not functions.
However, each worker string can use `from pyscript import x, y, z` as that will be available out of the box.
## PyScript Python API
The `pyscript` python package offers various utilities in either the main thread or the worker.
The commonly shared utilities are:
* **window** in both main and worker, refers to the actual main thread global window context. In classic PyScript that'd be the equivalent of `import js` in the main, which is still available in *PyScript Next*. However, to make code easily portable between main and workers, we decided to offer this named export but please note that in workers, this is still the *main* window, not the worker global context, which would be reachable instead still via `import js`.
* **document** in both main and worker, refers to the actual main page `document`. In classic PyScript, this is the equivalent of `from js import document` on the main thread, but this won't ever work in a worker because there is no `document` in there. Fear not though, *PyScript Next*`document` will instead work out of the box, still accessing the main document behind the scene, so that `from pyscript import document` is granted to work in both main and workers seamlessly.
* **display** in both main and worker, refers to the good old `display` utility except:
* in the *main* it automatically uses the current script `target` to display content
* in the *worker* it still needs to know *where* to display content using the `target="dom-id"` named argument, as workers don't get a default target attached
* in both main and worker, the `append=True` is the *default* behavior, which is inherited from the classic PyScript.
#### Extra main-only features
* **PyWorker** which allows Python code to create a PyScript worker with the *pyscript* module pre-bundled. Please note that running PyScript on the main requires *pyodide* bootstrap, but also every worker requires *pyodide* bootstrap a part, as each worker is an environment / sandbox a part. This means that using *PyWorker* in the main will take, even if the main interpreter is already up and running, a bit of time to bootstrap the worker, also accordingly to the config files or packages in it.
#### Extra worker-only features
* **sync** which allows both main and the worker to seamlessly pass any serializable data around, without the need to convert Python dictionaries to JS object literals, as that's done automatically.
To make it possible to use what looks like *synchronous* DOM APIs, or any other API available via the `window` within a *worker*, we are using latest Web features such as [Atomics](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics).
Without going into too many details, this means that the *SharedArrayBuffer* primitive must be available, and to do so, the server should enable the following headers:
```
Cross-Origin-Opener-Policy: same-origin
Cross-Origin-Embedder-Policy: require-corp
Cross-Origin-Resource-Policy: cross-origin
```
These headers allow local files to be secured and yet able to load resources from the Web (i.e. pyodide library or its packages).
> ℹ️ **Careful**: we are using and testing these headers on both Desktop and Mobile to be sure all major browsers work as expected (Safari, Firefox, Chromium based browsers). If you change the value of these headers please be sure you test your target devices and browsers properly.
Please note that if you don't have control over your server's headers, it is possible to simply put [mini-coi](https://github.com/WebReflection/mini-coi#readme) script at the root of your *PyScript with Workers* enabled folder (site root, or any subfolder).
```sh
cd project-folder
# grab mini-coi content and save it locally as mini-coi.js
Please note that a local or remote web server is still needed to allow the Service Worker and `python -m http.server` would do locally, *except* we need to reach `http://localhost:8000/`, not `http://0.0.0.0:8000/`, because the browser does not consider safe non localhost sites when the insecure `http://` protocol, instead of `https://`, is reached.
#### local server example
If you'd like to test locally these headers, without needing the *mini-coi* Service Worker, you can use various projects or, if you have *NodeJS* available, simply run the following command in the folder containing the site/project:
```sh
# bootstrap a local server with all headers needed
npx static-handler --cors --coep --coop --corp .
```
### F.A.Q.
<details>
<summary><strong>why config attribute can also contain JSON but not TOML?</strong></summary>
<div markdown=1>
The *JSON* standard doesn't require new lines or indentation so it felt quick and desired to allow inline JSON as attribute content.
It's true that HTML attributes can be multi-line too, if properly embedded, but that looked too awkward and definitively harder to explain to me.
We might decide to allow TOML too in the future, but the direct config as attribute, instead of a proper file, or the usage of `<py-config>`, is meant for quick and simple packages or files dependencies and not much else.
</div>
</details>
<details>
<summary><strong>what are the worker's caveats?</strong></summary>
<div markdown=1>
When interacting with `window` or `document` it's important to understand that these use, behind the scene, an orchestrated [postMessage](https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage) dance.
This means that some kind of data that cannot be passed around, specially not compatible with the [structured clone algorithm](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm).
In short, please try to stick with *JS* references when passing along, or dealing with, *DOM* or other *APIs*.
"build":"npm run build:3rd-party && npm run build:stdlib && npm run build:plugins && npm run build:core && eslint src/ && npm run ts && npm run test:mpy",
This folder contains artifacts created via [3rd-party.cjs](../../rollup/3rd-party.cjs).
As we would like to offer a way to run PyScript offline, and we already offer a `dist` folder with all the necessary scripts, we have created a foreign dependencies resolver that allow to lazy-load CDN dependencies out of the box.
Please **note** these dependencies are **not interpreters**, because interpreters have their own mechanism, folders structure, WASM files, and whatnot, to work locally, but at least XTerm or the TOML parser, among other lazy dependencies, should be available within the dist folder.
/** @type {Promise<[...any]>} A Promise wrapping any plugins which should be loaded. */
letplugins;
/** @type {any} The PyScript configuration parsed from the JSON or TOML object*. May be any of the return types of JSON.parse() or toml-j0.4's parse() ( {number | string | boolean | null | object | Array} ) */
letparsed;
/** @type {Error | undefined} The error thrown when parsing the PyScript config, if any.*/
leterror;
letconfig,
type,
pyElement,
pyConfigs=$$(`${TYPE}-config`),
attrConfigs=$$(
[
`script[type="${TYPE}"][config]:not([worker])`,
`${TYPE}-script[config]:not([worker])`,
].join(","),
);
// throw an error if there are multiple <py-config> or <mpy-config>
if(pyConfigs.length>1){
error=conflictError(`Too many ${TYPE}-config`);
}else{
// throw an error if there are <x-config> and config="x" attributes
* Internal function for creating alert banners on the page
* @param {string} message The message to be displayed to the user
* @param {string} level The alert level of the message. Can be any string; 'error' or 'warning' cause matching messages to be emitted to the console
* @param {string} [messageType="text"] If set to "html", the message content will be assigned to the banner's innerHTML directly, instead of its textContent
* @param {any} [logMessage=true] An additional flag for whether the message should be sent to the console log.
Some files were not shown because too many files have changed in this diff
Show More
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.