From dfef7eda3b74ba55ad66ad4e98e9c7576cb92e22 Mon Sep 17 00:00:00 2001 From: Peter W <34256109+pww217@users.noreply.github.com> Date: Mon, 12 Jun 2023 15:25:58 -0500 Subject: [PATCH 01/24] Use 8-core, 32GB runners for testing and faster builds (#1524) * swap 3 jobs to 8 core runners * 16 core test * test 4 core * back to 8 core --- .github/workflows/build-unstable.yml | 2 +- .github/workflows/prepare-release.yml | 2 +- .github/workflows/publish-release.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-unstable.yml b/.github/workflows/build-unstable.yml index 73b0ba355f2..e27303e4057 100644 --- a/.github/workflows/build-unstable.yml +++ b/.github/workflows/build-unstable.yml @@ -20,7 +20,7 @@ on: jobs: BuildAndTest: - runs-on: ubuntu-latest + runs-on: ubuntu-latest-8core defaults: run: working-directory: pyscriptjs diff --git a/.github/workflows/prepare-release.yml b/.github/workflows/prepare-release.yml index 944eeef1100..98e995c550d 100644 --- a/.github/workflows/prepare-release.yml +++ b/.github/workflows/prepare-release.yml @@ -15,7 +15,7 @@ defaults: jobs: build: - runs-on: ubuntu-latest + runs-on: ubuntu-latest-8core steps: - name: Checkout uses: actions/checkout@v3 diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index 304fc7592cc..047719780b0 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -14,7 +14,7 @@ defaults: jobs: build: - runs-on: ubuntu-latest + runs-on: ubuntu-latest-8core permissions: contents: read id-token: write From a108e6e97e32d959ecc3526373ab33730bff0a57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A1bio=20Rosado?= Date: Tue, 13 Jun 2023 15:06:19 +0100 Subject: [PATCH 02/24] Add workflow to run next CI (#1527) * Add workflow to run next CI * Don't actually replace the whole unstable * Unstable name * Add empty line * Make CI run on changes to workflow build-unstable-next * Rename workflow for test-next instead of build * Update path to use the next test-next * Add pyscript.core to path --- .github/workflows/test-next.yml | 120 ++++++++++++++++++++++++++++++++ 1 file changed, 120 insertions(+) create mode 100644 .github/workflows/test-next.yml diff --git a/.github/workflows/test-next.yml b/.github/workflows/test-next.yml new file mode 100644 index 00000000000..683d8cada06 --- /dev/null +++ b/.github/workflows/test-next.yml @@ -0,0 +1,120 @@ +name: "[CI] Test Next" + +on: + push: # Only run on merges into main that modify files under pyscriptjs/ and examples/ + branches: + - next + paths: + - pyscript.core/** + - pyscriptjs/** + - examples/** + - .github/workflows/test-next.yml # Test that workflow works when changed + + pull_request: # Run on any PR that modifies files under pyscriptjs/ and examples/ + branches: + - next + paths: + - pyscript.core/** + - pyscriptjs/** + - examples/** + - .github/workflows/test-next.yml # Test that workflow works when changed + workflow_dispatch: + +jobs: + BuildAndTest: + runs-on: ubuntu-latest-8core + defaults: + run: + working-directory: pyscriptjs + env: + MINICONDA_PYTHON_VERSION: py38 + MINICONDA_VERSION: 4.11.0 + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Install node + uses: actions/setup-node@v3 + with: + node-version: 18.x + + - name: Cache node modules + uses: actions/cache@v3 + env: + cache-name: cache-node-modules + with: + # npm cache files are stored in `~/.npm` on Linux/macOS + path: ~/.npm + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + + - name: setup Miniconda + uses: conda-incubator/setup-miniconda@v2 + + - name: Setup Environment + run: make setup + + - name: Build + run: make build + + - name: TypeScript Tests + run: make test-ts + + - name: Python Tests + run: make test-py + + - name: Integration Tests + run: make test-integration-parallel + + - name: Examples Tests + run: make test-examples + + - uses: actions/upload-artifact@v3 + with: + name: pyscript + path: | + pyscriptjs/build/ + if-no-files-found: error + retention-days: 7 + + - uses: actions/upload-artifact@v3 + if: success() || failure() + with: + name: test_results + path: pyscriptjs/test_results + if-no-files-found: error + eslint: + runs-on: ubuntu-latest + defaults: + run: + working-directory: pyscriptjs + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Install node + uses: actions/setup-node@v3 + with: + node-version: 18.x + + - name: Cache node modules + uses: actions/cache@v3 + env: + cache-name: cache-node-modules + with: + # npm cache files are stored in `~/.npm` on Linux/macOS + path: ~/.npm + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + + - name: npm install + run: npm install + + - name: Eslint + run: npx eslint src -c .eslintrc.js From 258b80a6a59ac0c1b034bc42aca5932e76fd0f72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A1bio=20Rosado?= Date: Wed, 14 Jun 2023 14:12:42 +0100 Subject: [PATCH 03/24] Add step to install next deps and run test (#1528) --- .github/workflows/test-next.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-next.yml b/.github/workflows/test-next.yml index 683d8cada06..c8b50b33eb7 100644 --- a/.github/workflows/test-next.yml +++ b/.github/workflows/test-next.yml @@ -60,12 +60,20 @@ jobs: - name: Build run: make build - - name: TypeScript Tests + - name: TypeScript Tests (core) run: make test-ts - name: Python Tests run: make test-py + - name: install next deps + working-directory: pyscript.core + run: npm i + + - name: Run next tests + working-directory: pyscript.core + run: npm test + - name: Integration Tests run: make test-integration-parallel From 8879187e6a106ad1170865d3c31972e83b217e85 Mon Sep 17 00:00:00 2001 From: Madhur Tandon <20173739+madhur-tandon@users.noreply.github.com> Date: Wed, 14 Jun 2023 19:42:38 +0530 Subject: [PATCH 04/24] fix access to interpreter globals without awaits (#1529) --- pyscriptjs/src/main.ts | 6 +++-- .../tests/integration/test_interpreter.py | 22 +++++++++++-------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/pyscriptjs/src/main.ts b/pyscriptjs/src/main.ts index f9463be2f6a..a9acef401f1 100644 --- a/pyscriptjs/src/main.ts +++ b/pyscriptjs/src/main.ts @@ -71,6 +71,7 @@ export let runtime; export class PyScriptApp { config: AppConfig; interpreter: InterpreterClient; + unwrapped_remote: RemoteInterpreter; readyPromise: Promise; PyScript: ReturnType; plugins: PluginManager; @@ -139,10 +140,10 @@ export class PyScriptApp { await this.plugins.configure(this.config); this.plugins.beforeLaunch(this.config); await this.loadInterpreter(); - interpreter = this.interpreter; + interpreter = this.unwrapped_remote; // TODO: This is for backwards compatibility, it should be removed // when we finish the deprecation cycle of `runtime` - runtime = this.interpreter; + runtime = this.unwrapped_remote; } // lifecycle (2) @@ -193,6 +194,7 @@ export class PyScriptApp { logger.info('Starting the interpreter in the main thread'); // this is basically equivalent to worker_initialize() const remote_interpreter = new RemoteInterpreter(interpreter_cfg.src); + this.unwrapped_remote = remote_interpreter; const { port1, port2 } = new Synclink.FakeMessageChannel() as unknown as MessageChannel; port1.start(); port2.start(); diff --git a/pyscriptjs/tests/integration/test_interpreter.py b/pyscriptjs/tests/integration/test_interpreter.py index 4eae127a2e9..b92a2150e50 100644 --- a/pyscriptjs/tests/integration/test_interpreter.py +++ b/pyscriptjs/tests/integration/test_interpreter.py @@ -1,9 +1,10 @@ -from .support import PyScriptTest +from .support import PyScriptTest, skip_worker class TestInterpreterAccess(PyScriptTest): """Test accessing Python objects from JS via pyscript.interpreter""" + @skip_worker("WONTFIX: used without synclink to avoid awaits") def test_interpreter_python_access(self): self.pyscript_run( """ @@ -17,9 +18,9 @@ def py_func(): self.run_js( """ - const x = await pyscript.interpreter.globals.get('x'); - const py_func = await pyscript.interpreter.globals.get('py_func'); - const py_func_res = await py_func(); + const x = pyscript.interpreter.globals.get('x'); + const py_func = pyscript.interpreter.globals.get('py_func'); + const py_func_res = py_func(); console.log(`x is ${x}`); console.log(`py_func() returns ${py_func_res}`); """ @@ -29,13 +30,14 @@ def py_func(): "py_func() returns 2", ] + @skip_worker("WONTFIX: used without synclink") def test_interpreter_script_execution(self): """Test running Python code from js via pyscript.interpreter""" self.pyscript_run("") self.run_js( """ - const interface = pyscript.interpreter._remote.interface; + const interface = pyscript.interpreter.interface; await interface.runPython('print("Interpreter Ran This")'); """ ) @@ -46,13 +48,14 @@ def test_interpreter_script_execution(self): py_terminal = self.page.wait_for_selector("py-terminal") assert py_terminal.text_content() == expected_message + @skip_worker("WONTFIX: used without synclink") def test_backward_compatibility_runtime_script_execution(self): """Test running Python code from js via pyscript.runtime""" self.pyscript_run("") self.run_js( """ - const interface = pyscript.runtime._remote.interpreter; + const interface = pyscript.runtime.interpreter; await interface.runPython('print("Interpreter Ran This")'); """ ) @@ -63,6 +66,7 @@ def test_backward_compatibility_runtime_script_execution(self): py_terminal = self.page.wait_for_selector("py-terminal") assert py_terminal.text_content() == expected_message + @skip_worker("WONTFIX: used without synclink to avoid awaits") def test_backward_compatibility_runtime_python_access(self): """Test accessing Python objects from JS via pyscript.runtime""" self.pyscript_run( @@ -77,9 +81,9 @@ def py_func(): self.run_js( """ - const x = await pyscript.interpreter.globals.get('x'); - const py_func = await pyscript.interpreter.globals.get('py_func'); - const py_func_res = await py_func(); + const x = pyscript.runtime.globals.get('x'); + const py_func = pyscript.runtime.globals.get('py_func'); + const py_func_res = py_func(); console.log(`x is ${x}`); console.log(`py_func() returns ${py_func_res}`); """ From f4936316ab81928745a6a3e19fbb85d6b02b25b2 Mon Sep 17 00:00:00 2001 From: Jeff Glass Date: Wed, 14 Jun 2023 12:56:57 -0500 Subject: [PATCH 05/24] Make getPySrc() a Documented Feature (#1516) * Add documentation and tests (no real code changes) * Add Changelog --- docs/changelog.md | 1 + docs/reference/elements/py-repl.md | 8 ++++++++ pyscriptjs/tests/integration/test_py_repl.py | 20 ++++++++++++++++++++ 3 files changed, 29 insertions(+) diff --git a/docs/changelog.md b/docs/changelog.md index efc26b67474..ff4287888ad 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -32,6 +32,7 @@ Features - 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)) diff --git a/docs/reference/elements/py-repl.md b/docs/reference/elements/py-repl.md index 32d95021dd1..bee115f130d 100644 --- a/docs/reference/elements/py-repl.md +++ b/docs/reference/elements/py-repl.md @@ -28,6 +28,14 @@ The ID of an element in the DOM that `stderr` will be written to. Defaults to No ### `src` If a \ tag has the `src` attribute, during page initialization, resource in the `src` will be preloaded into the REPL. Please note that this will not run in advance. If there is content in the \ tag, it will be cleared and replaced with preloaded resource. +## Methods + +The following are methods that can be called on the \ element, from within Python or JavaScript + +### `getPySrc()` + +Returns the current code contents of the REPL as a string. + ## Examples ### `` element set to auto-generate diff --git a/pyscriptjs/tests/integration/test_py_repl.py b/pyscriptjs/tests/integration/test_py_repl.py index 930389e3bfc..b369ec91fb3 100644 --- a/pyscriptjs/tests/integration/test_py_repl.py +++ b/pyscriptjs/tests/integration/test_py_repl.py @@ -595,6 +595,26 @@ def test_repl_output_element_id_change(self): alert_banner = self.page.wait_for_selector(".alert-banner") assert expected_alert_banner_msg in alert_banner.inner_text() + def test_getPySrc_Contents(self): + """Test that an empty REPL returns an empty string as src, and that the typed contents + are returned as the source + """ + self.pyscript_run( + """ + + + """ + ) + py_repl = self.page.locator("py-repl") + src = py_repl.evaluate("node => node.getPySrc()") + assert src == "" + assert type(src) == str + + py_repl.focus() + py_repl.type("Hello, world!") + src = py_repl.evaluate("node => node.getPySrc()") + assert src == "Hello, world!" + def test_repl_load_content_from_src(self): self.writefile("loadReplSrc1.py", "print('1')") self.pyscript_run( From 79ad39260e3adff75f7f361b97959c362c73e9db Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Thu, 15 Jun 2023 11:51:36 -0700 Subject: [PATCH 06/24] Fix lifetime for pyExec results (#1540) Currently if the result from pyExec is a PyProxy, it gets destroyed. This switches to using `to_js` to handle this (it is better to use than an explicit `create_proxy` since it automatically decides whether to create a proxy or not). I also added `destroyIfProxy` which checks if something is a `PyProxy` and then destroys it. Each use of `pyExec` needs to call `destroyIfProxy` on the result after it is done with it. --- pyscriptjs/src/components/pyrepl.ts | 2 +- pyscriptjs/src/components/pyscript.ts | 1 + pyscriptjs/src/python/pyscript/_internal.py | 4 +- pyscriptjs/src/remote_interpreter.ts | 14 +++++++ pyscriptjs/tests/integration/test_py_repl.py | 44 ++++++++++++++++++++ 5 files changed, 62 insertions(+), 3 deletions(-) diff --git a/pyscriptjs/src/components/pyrepl.ts b/pyscriptjs/src/components/pyrepl.ts index 20034641fce..432fe8946bd 100644 --- a/pyscriptjs/src/components/pyrepl.ts +++ b/pyscriptjs/src/components/pyrepl.ts @@ -191,7 +191,7 @@ export function make_PyRepl(interpreter: InterpreterClient, app: PyScriptApp) { pyReplTag: this, result, }); - + await interpreter._remote.destroyIfProxy(result); this.autogenerateMaybe(); } diff --git a/pyscriptjs/src/components/pyscript.ts b/pyscriptjs/src/components/pyscript.ts index 722ef8ed1bd..63d940f0ff6 100644 --- a/pyscriptjs/src/components/pyscript.ts +++ b/pyscriptjs/src/components/pyscript.ts @@ -36,6 +36,7 @@ export function make_PyScript(interpreter: InterpreterClient, app: PyScriptApp) await app.plugins.beforePyScriptExec({ interpreter, src, pyScriptTag }); const { result } = await pyExec(interpreter, src, pyScriptTag); await app.plugins.afterPyScriptExec({ interpreter, src, pyScriptTag, result }); + await interpreter._remote.destroyIfProxy(result); } finally { releaseLock(); app.decrementPendingTags(); diff --git a/pyscriptjs/src/python/pyscript/_internal.py b/pyscriptjs/src/python/pyscript/_internal.py index 81e2f753a2e..a486757644e 100644 --- a/pyscriptjs/src/python/pyscript/_internal.py +++ b/pyscriptjs/src/python/pyscript/_internal.py @@ -4,7 +4,7 @@ from js import Object from pyodide.code import eval_code -from pyodide.ffi import JsProxy +from pyodide.ffi import JsProxy, to_js from ._event_loop import ( defer_user_asyncio, @@ -103,7 +103,7 @@ def run_pyscript(code: str, id: str = None) -> JsProxy: with display_target(id), defer_user_asyncio(): result = eval_code(code, globals=__main__.__dict__) - return Object.new(result=result) + return to_js({"result": result}, depth=1, dict_converter=Object.fromEntries) __all__ = [ diff --git a/pyscriptjs/src/remote_interpreter.ts b/pyscriptjs/src/remote_interpreter.ts index 1585f9eb251..a9c2ae93210 100644 --- a/pyscriptjs/src/remote_interpreter.ts +++ b/pyscriptjs/src/remote_interpreter.ts @@ -274,6 +274,20 @@ export class RemoteInterpreter extends Object { this.FS.writeFile(path, data, { canOwn: true }); } + destroyIfProxy(px: any): void { + if (this.interface.ffi) { + // Pyodide 0.23 + if (px instanceof this.interface.ffi.PyProxy) { + px.destroy(); + } + } else { + // older Pyodide + if (this.interface.isPyProxy(px)) { + px.destroy(); + } + } + } + /** * delegates clearing importlib's module path * caches to the underlying interface diff --git a/pyscriptjs/tests/integration/test_py_repl.py b/pyscriptjs/tests/integration/test_py_repl.py index b369ec91fb3..64b097639e6 100644 --- a/pyscriptjs/tests/integration/test_py_repl.py +++ b/pyscriptjs/tests/integration/test_py_repl.py @@ -674,3 +674,47 @@ def test_repl_src_path_that_do_not_exist(self): "Are your filename and path correct?" ) assert self.console.error.lines[-1] == errorMsg + + @skip_worker("dont-care") + def test_repl_results(self): + self.writefile("loadReplSrc2.py", "2") + self.writefile("loadReplSrc3.py", "print('3')") + + self.pyscript_run( + """ + + 42 + +
+ + + c = [1,2,3] + from sys import getrefcount + # should print 2: 1 from the reference c and 1 since getrefcount + # holds a reference to its argument + print(getrefcount(c)) + c + +
+ + + # should also print 2: if it prints 3 that would mean that c was not properly + # released by py-repl + getrefcount(c) + +
+ """ + ) + py_repl1 = self.page.locator("py-repl#py-repl1") + py_repl1.locator("button").click() + + py_repl2 = self.page.locator("py-repl#py-repl2") + py_repl2.locator("button").click() + + py_repl3 = self.page.locator("py-repl#py-repl3") + py_repl3.locator("button").click() + + assert self.page.wait_for_selector("#out1").inner_text() == "42" + assert self.page.wait_for_selector("#out2").inner_text() == "2\n\n[1, 2, 3]" + # Check that c was released + assert self.page.wait_for_selector("#out3").inner_text() == "2" From ea9bdcc961c661ff2153bec8aa775d3b1777a8fa Mon Sep 17 00:00:00 2001 From: Jeff Glass Date: Tue, 20 Jun 2023 08:08:24 -0500 Subject: [PATCH 07/24] Fix previous changlog date (#1546) * Previous version updated from 2023.01.1 to 2023.03.1 --- docs/changelog.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/changelog.md b/docs/changelog.md index ff4287888ad..67a08a17b4e 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -58,7 +58,7 @@ Docs - Add docs for event handlers -2023.01.1 +2023.03.1 ========= From e4e8f2edae9f29ef2e979380b2444040787af6fa Mon Sep 17 00:00:00 2001 From: Ted Patrick Date: Tue, 20 Jun 2023 12:17:08 -0500 Subject: [PATCH 08/24] Fix build unstable to run on ubuntu-latest-8core (#1549) * Fix build unstable to run on ubuntu-latest-8core * ubuntu-latest to ubuntu-latest-8core --- .github/workflows/build-unstable.yml | 4 ++-- .github/workflows/docs-release.yml | 2 +- .github/workflows/docs-review.yml | 2 +- .github/workflows/docs-unstable.yml | 2 +- .github/workflows/publish-snapshot.yml | 2 +- .github/workflows/sync-examples.yml | 2 +- .github/workflows/test-next.yml | 2 +- .github/workflows/test_report.yml | 2 +- pyscriptjs/package-lock.json | 20 ++++++++++---------- pyscriptjs/package.json | 2 +- 10 files changed, 20 insertions(+), 20 deletions(-) diff --git a/.github/workflows/build-unstable.yml b/.github/workflows/build-unstable.yml index e27303e4057..335dccd1e3e 100644 --- a/.github/workflows/build-unstable.yml +++ b/.github/workflows/build-unstable.yml @@ -85,7 +85,7 @@ jobs: path: pyscriptjs/test_results if-no-files-found: error eslint: - runs-on: ubuntu-latest + runs-on: ubuntu-latest-8core defaults: run: working-directory: pyscriptjs @@ -118,7 +118,7 @@ jobs: run: npx eslint src -c .eslintrc.js Deploy: - runs-on: ubuntu-latest + runs-on: ubuntu-latest-8core needs: BuildAndTest if: github.ref == 'refs/heads/main' # Only deploy on merge into main permissions: diff --git a/.github/workflows/docs-release.yml b/.github/workflows/docs-release.yml index 2978d7a971b..3d34d40bfa4 100644 --- a/.github/workflows/docs-release.yml +++ b/.github/workflows/docs-release.yml @@ -6,7 +6,7 @@ on: jobs: build: - runs-on: ubuntu-latest + runs-on: ubuntu-latest-8core permissions: contents: read id-token: write diff --git a/.github/workflows/docs-review.yml b/.github/workflows/docs-review.yml index 37ba5b13678..5054d4e0899 100644 --- a/.github/workflows/docs-review.yml +++ b/.github/workflows/docs-review.yml @@ -19,7 +19,7 @@ concurrency: jobs: build: if: github.repository_owner == 'pyscript' - runs-on: ubuntu-latest + runs-on: ubuntu-latest-8core permissions: contents: read id-token: write diff --git a/.github/workflows/docs-unstable.yml b/.github/workflows/docs-unstable.yml index 0d093db5b78..9ad28948ce3 100644 --- a/.github/workflows/docs-unstable.yml +++ b/.github/workflows/docs-unstable.yml @@ -9,7 +9,7 @@ on: jobs: build: - runs-on: ubuntu-latest + runs-on: ubuntu-latest-8core permissions: contents: read id-token: write diff --git a/.github/workflows/publish-snapshot.yml b/.github/workflows/publish-snapshot.yml index e2ef5c982c3..daa12b373ac 100644 --- a/.github/workflows/publish-snapshot.yml +++ b/.github/workflows/publish-snapshot.yml @@ -11,7 +11,7 @@ on: jobs: snapshot: - runs-on: ubuntu-latest + runs-on: ubuntu-latest-8core permissions: contents: read id-token: write diff --git a/.github/workflows/sync-examples.yml b/.github/workflows/sync-examples.yml index d8ed32b8e22..deb56f638c2 100644 --- a/.github/workflows/sync-examples.yml +++ b/.github/workflows/sync-examples.yml @@ -6,7 +6,7 @@ on: jobs: build: - runs-on: ubuntu-latest + runs-on: ubuntu-latest-8core permissions: contents: read id-token: write diff --git a/.github/workflows/test-next.yml b/.github/workflows/test-next.yml index c8b50b33eb7..a0c6652e2a4 100644 --- a/.github/workflows/test-next.yml +++ b/.github/workflows/test-next.yml @@ -95,7 +95,7 @@ jobs: path: pyscriptjs/test_results if-no-files-found: error eslint: - runs-on: ubuntu-latest + runs-on: ubuntu-latest-8core defaults: run: working-directory: pyscriptjs diff --git a/.github/workflows/test_report.yml b/.github/workflows/test_report.yml index dacbc8e7732..7ffca86bf32 100644 --- a/.github/workflows/test_report.yml +++ b/.github/workflows/test_report.yml @@ -6,7 +6,7 @@ on: - completed jobs: report: - runs-on: ubuntu-latest + runs-on: ubuntu-latest-8core steps: - uses: dorny/test-reporter@v1.6.0 with: diff --git a/pyscriptjs/package-lock.json b/pyscriptjs/package-lock.json index 50639199bfe..5b291a1530d 100644 --- a/pyscriptjs/package-lock.json +++ b/pyscriptjs/package-lock.json @@ -34,7 +34,7 @@ "prettier": "2.7.1", "pyodide": "0.23.2", "synclink": "0.2.4", - "ts-jest": "29.0.3", + "ts-jest": "29.1.0", "typescript": "5.0.4", "xterm": "^5.1.0" } @@ -5674,15 +5674,15 @@ } }, "node_modules/ts-jest": { - "version": "29.0.3", - "resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-29.0.3.tgz", - "integrity": "sha512-Ibygvmuyq1qp/z3yTh9QTwVVAbFdDy/+4BtIQR2sp6baF2SJU/8CKK/hhnGIDY2L90Az2jIqTwZPnN2p+BweiQ==", + "version": "29.1.0", + "resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-29.1.0.tgz", + "integrity": "sha512-ZhNr7Z4PcYa+JjMl62ir+zPiNJfXJN6E8hSLnaUKhOgqcn8vb3e537cpkd0FuAfRK3sR1LSqM1MOhliXNgOFPA==", "dev": true, "dependencies": { "bs-logger": "0.x", "fast-json-stable-stringify": "2.x", "jest-util": "^29.0.0", - "json5": "^2.2.1", + "json5": "^2.2.3", "lodash.memoize": "4.x", "make-error": "1.x", "semver": "7.x", @@ -5699,7 +5699,7 @@ "@jest/types": "^29.0.0", "babel-jest": "^29.0.0", "jest": "^29.0.0", - "typescript": ">=4.3" + "typescript": ">=4.3 <6" }, "peerDependenciesMeta": { "@babel/core": { @@ -10247,15 +10247,15 @@ } }, "ts-jest": { - "version": "29.0.3", - "resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-29.0.3.tgz", - "integrity": "sha512-Ibygvmuyq1qp/z3yTh9QTwVVAbFdDy/+4BtIQR2sp6baF2SJU/8CKK/hhnGIDY2L90Az2jIqTwZPnN2p+BweiQ==", + "version": "29.1.0", + "resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-29.1.0.tgz", + "integrity": "sha512-ZhNr7Z4PcYa+JjMl62ir+zPiNJfXJN6E8hSLnaUKhOgqcn8vb3e537cpkd0FuAfRK3sR1LSqM1MOhliXNgOFPA==", "dev": true, "requires": { "bs-logger": "0.x", "fast-json-stable-stringify": "2.x", "jest-util": "^29.0.0", - "json5": "^2.2.1", + "json5": "^2.2.3", "lodash.memoize": "4.x", "make-error": "1.x", "semver": "7.x", diff --git a/pyscriptjs/package.json b/pyscriptjs/package.json index a86c47d3251..02447af1dc1 100644 --- a/pyscriptjs/package.json +++ b/pyscriptjs/package.json @@ -36,7 +36,7 @@ "prettier": "2.7.1", "pyodide": "0.23.2", "synclink": "0.2.4", - "ts-jest": "29.0.3", + "ts-jest": "29.1.0", "typescript": "5.0.4", "xterm": "^5.1.0" }, From 848d77b1c29d4145a3438b832acd4b3b9bf32951 Mon Sep 17 00:00:00 2001 From: Ted Patrick Date: Tue, 20 Jun 2023 13:01:56 -0500 Subject: [PATCH 09/24] Same steps as build-unstable (#1550) * Same steps as build-unstable * make setup --- .github/workflows/prepare-release.yml | 16 ++++++++++++++-- .github/workflows/publish-release.yml | 16 ++++++++++++++-- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/.github/workflows/prepare-release.yml b/.github/workflows/prepare-release.yml index 98e995c550d..bd0a4de7bd6 100644 --- a/.github/workflows/prepare-release.yml +++ b/.github/workflows/prepare-release.yml @@ -44,8 +44,20 @@ jobs: - name: Setup Environment run: make setup - - name: Build and Test - run: make test + - name: Build + run: make build + + - name: TypeScript Tests + run: make test-ts + + - name: Python Tests + run: make test-py + + - name: Integration Tests + run: make test-integration-parallel + + - name: Examples Tests + run: make test-examples - name: Zip build folder run: zip -r -q ./build.zip ./build diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index 047719780b0..f56a85fdcb9 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -46,8 +46,20 @@ jobs: - name: Setup Environment run: make setup - - name: Build and Test - run: make test + - name: Build + run: make build + + - name: TypeScript Tests + run: make test-ts + + - name: Python Tests + run: make test-py + + - name: Integration Tests + run: make test-integration-parallel + + - name: Examples Tests + run: make test-examples # Upload to S3 - name: Configure AWS credentials From 7765a629c715dfa3989479484c80a3c39ccb8e11 Mon Sep 17 00:00:00 2001 From: Jeff Glass Date: Wed, 21 Jun 2023 06:23:26 -0500 Subject: [PATCH 10/24] Update verison (#1552) * Update verison * Fix test to account for single-digit months --- pyscriptjs/src/version.ts | 2 +- pyscriptjs/tests/integration/test_01_basic.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pyscriptjs/src/version.ts b/pyscriptjs/src/version.ts index 28ec30db4aa..c9bd3955828 100644 --- a/pyscriptjs/src/version.ts +++ b/pyscriptjs/src/version.ts @@ -7,4 +7,4 @@ * circular imports. */ -export const version = '2022.12.1.dev'; +export const version = '2023.05.1.dev'; diff --git a/pyscriptjs/tests/integration/test_01_basic.py b/pyscriptjs/tests/integration/test_01_basic.py index 1170adc76ec..59bb5c16f90 100644 --- a/pyscriptjs/tests/integration/test_01_basic.py +++ b/pyscriptjs/tests/integration/test_01_basic.py @@ -293,7 +293,7 @@ def test_python_version(self): ) assert ( re.match( - r"version_info\(year=\d{4}, month=\d{2}, " + r"version_info\(year=\d{4}, month=\d{1,2}, " r"minor=\d+, releaselevel='([a-zA-Z0-9]+)?'\)", self.console.log.lines[-1], ) From 9a70943a365005f77e4ea74551c5058f2a54cd58 Mon Sep 17 00:00:00 2001 From: Neon22 Date: Thu, 22 Jun 2023 10:56:47 +1200 Subject: [PATCH 11/24] Update when.md (#1554) * Update when.md: include info on importing when to get access --------- Co-authored-by: Jeff Glass --- docs/reference/API/when.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/reference/API/when.md b/docs/reference/API/when.md index aaf4f761b9b..ba5c5b0123b 100644 --- a/docs/reference/API/when.md +++ b/docs/reference/API/when.md @@ -6,6 +6,9 @@ The `@when` decorator attaches the decorated function or Callable as an event ha If the decorated function takes a single (non-self) argument, it will be passed the [Event object](https://developer.mozilla.org/en-US/docs/Web/API/Event) corresponding to the triggered event. If the function takes no (non-self) argument, it will be called with no arguments. +You will need to import `when` to get access to this feature: +`from pyscript import when` + ## Parameters `event_type` - A string representing the event type to match against. This can be any of the [https://developer.mozilla.org/en-US/docs/Web/Events#event_listing](https://developer.mozilla.org/en-US/docs/Web/Events) that HTML elements may emit, as appropriate to their element type. From 55cf6b9e4c4ddb6a5f502ab6485f678d8311e916 Mon Sep 17 00:00:00 2001 From: Neon22 Date: Fri, 23 Jun 2023 01:12:11 +1200 Subject: [PATCH 12/24] Update py-click.md (#1553) used wrong file extension so link was missing --- docs/tutorials/py-click.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/tutorials/py-click.md b/docs/tutorials/py-click.md index 6cb52c2d125..23bda056979 100644 --- a/docs/tutorials/py-click.md +++ b/docs/tutorials/py-click.md @@ -1,6 +1,6 @@ # Handling click events -This tutorial will show you how to use the `py-click` attribute to handle mouse clicks on elements on your page. The `py-click` attribute is a special attribute that allows you to specify a Python function that will be called when the element is clicked. There are many other events such as py-mouseover, py-focus, py-input, py-keyress etc, which can be used as well. They are listed here [Attr-to-Event](../reference/API/attr_to_event.html) +This tutorial will show you how to use the `py-click` attribute to handle mouse clicks on elements on your page. The `py-click` attribute is a special attribute that allows you to specify a Python function that will be called when the element is clicked. There are many other events such as py-mouseover, py-focus, py-input, py-keyress etc, which can be used as well. They are listed here [Attr-to-Event](../reference/API/attr_to_event.md) ## Development setup From 1b9cb562ec613ce1a5137770c330917c9ed3d147 Mon Sep 17 00:00:00 2001 From: Aapo Soukkio <105101351+AapoSoukkio@users.noreply.github.com> Date: Thu, 20 Jul 2023 19:34:30 +0300 Subject: [PATCH 13/24] Remove unused comment (#1604) --- examples/webgl/raycaster/style.css | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/webgl/raycaster/style.css b/examples/webgl/raycaster/style.css index d70645cffb5..8a47d6ef126 100644 --- a/examples/webgl/raycaster/style.css +++ b/examples/webgl/raycaster/style.css @@ -10,7 +10,6 @@ canvas { height: 100%; } .header { - /*top:45%;*/ top: 45%; color: #dddddd; } From 71e2555213ccd217582264b2233e132bd9fdad17 Mon Sep 17 00:00:00 2001 From: Fabio Pliger Date: Tue, 8 Aug 2023 08:21:50 -0700 Subject: [PATCH 14/24] fix LICENSE info around dates and project owner (#1606) * fix info around dates and project owner * add originated at Anaconda, Inc to license * add . on Inc --------- Co-authored-by: Fabio Pliger --- LICENSE | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index 261eeb9e9f8..e024c1dc997 100644 --- a/LICENSE +++ b/LICENSE @@ -186,7 +186,9 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright [yyyy] [name of copyright owner] + Copyright (c) 2022-present, PyScript Development Team + + Originated at Anaconda, Inc. in 2022 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. From be79f70f664467f0074e44309451e8aba6f84798 Mon Sep 17 00:00:00 2001 From: Shubhashis Date: Wed, 9 Aug 2023 02:35:57 -0600 Subject: [PATCH 15/24] Fix #1577: Change script sources that include Cross-Origin Resource Policy (#1627) --- examples/d3.html | 2 +- examples/panel_deckgl.html | 14 +++++++------- examples/panel_kmeans.html | 12 ++++++------ examples/panel_stream.html | 12 ++++++------ 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/examples/d3.html b/examples/d3.html index ef3e66f50e7..898c7ffd0f1 100644 --- a/examples/d3.html +++ b/examples/d3.html @@ -10,7 +10,7 @@ /> - +