Skip to content

Fix #2309 - Use all config options #2310

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
299 changes: 152 additions & 147 deletions core/package-lock.json

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pyscript/core",
"version": "0.6.35",
"version": "0.6.36",
"type": "module",
"description": "PyScript",
"module": "./index.js",
Expand Down Expand Up @@ -66,7 +66,7 @@
"@webreflection/idb-map": "^0.3.2",
"add-promise-listener": "^0.1.3",
"basic-devtools": "^0.1.6",
"polyscript": "^0.16.17",
"polyscript": "^0.16.21",
"sabayon": "^0.6.6",
"sticky-module": "^0.1.1",
"to-json-callback": "^0.1.1",
Expand All @@ -77,9 +77,9 @@
"@codemirror/lang-python": "^6.1.7",
"@codemirror/language": "^6.10.8",
"@codemirror/state": "^6.5.2",
"@codemirror/view": "^6.36.3",
"@playwright/test": "1.45.3",
"@rollup/plugin-commonjs": "^28.0.2",
"@codemirror/view": "^6.36.4",
"@playwright/test": "^1.51.0",
"@rollup/plugin-commonjs": "^28.0.3",
"@rollup/plugin-node-resolve": "^16.0.0",
"@rollup/plugin-terser": "^0.4.4",
"@webreflection/toml-j0.4": "^1.1.3",
Expand All @@ -90,14 +90,14 @@
"chokidar": "^4.0.3",
"codedent": "^0.1.2",
"codemirror": "^6.0.1",
"eslint": "^9.21.0",
"eslint": "^9.22.0",
"flatted": "^3.3.3",
"rollup": "^4.34.8",
"rollup": "^4.35.0",
"rollup-plugin-postcss": "^4.0.2",
"rollup-plugin-string": "^3.0.0",
"static-handler": "^0.5.3",
"string-width": "^7.2.0",
"typescript": "^5.7.3",
"typescript": "^5.8.2",
"xterm-readline": "^1.1.2"
},
"repository": {
Expand Down
18 changes: 16 additions & 2 deletions core/src/plugins/py-game.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
import { dedent, define } from "polyscript/exports";
import {
dedent,
define,
createProgress,
loadProgress,
} from "polyscript/exports";

import { stdlib } from "../core.js";
import { configDetails } from "../config.js";
import { getText } from "../fetch.js";

const progress = createProgress("py-game");

let toBeWarned = true;

const hooks = {
Expand All @@ -17,7 +24,7 @@ const hooks = {
let config = {};
if (script.hasAttribute("config")) {
const value = script.getAttribute("config");
const { json, toml, text } = configDetails(value);
const { json, toml, text, url } = await configDetails(value);
if (json) config = JSON.parse(text);
else if (toml) {
const { parse } = await import(
Expand All @@ -32,6 +39,13 @@ const hooks = {
});
micropip.destroy();
}
await loadProgress(
"py-game",
progress,
wrap.interpreter,
config,
url || location.href,
);
}

wrap.interpreter.registerJsModule("_pyscript", {
Expand Down
2 changes: 1 addition & 1 deletion core/tests/manual/game/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<script type="module" src="../../../dist/core.js"></script>
</head>
<body>
<script type="py-game" src="aliens.py"></script>
<script type="py-game" src="aliens.py" config="{}"></script>
<div class="demo">
<div class="demo-header">pygame.examples.aliens</div>
<div class="demo-content">
Expand Down
8 changes: 5 additions & 3 deletions core/tests/py_tests.main.spec.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
import { test, expect } from '@playwright/test';

test.setTimeout(30 * 1000);
const timeout = 60 * 1000;

test.setTimeout(timeout);

test('Python unit tests - MicroPython on MAIN thread', async ({ page }) => {
await page.goto('http://localhost:8080/tests/python/index.html');
const result = page.locator("#result"); // Payload for results will be here.
await result.waitFor(); // wait for the result.
await result.waitFor({ timeout }); // wait for the result.
const data = JSON.parse(await result.textContent()); // get the result data.
await expect(data.fails).toMatchObject([]); // ensure no test failed.
});

test('Python unit tests - Pyodide on MAIN thread', async ({ page }) => {
await page.goto('http://localhost:8080/tests/python/index.html?type=py');
const result = page.locator("#result"); // Payload for results will be here.
await result.waitFor(); // wait for the result.
await result.waitFor({ timeout }); // wait for the result.
const data = JSON.parse(await result.textContent()); // get the result data.
await expect(data.fails).toMatchObject([]); // ensure no test failed.
});
8 changes: 5 additions & 3 deletions core/tests/py_tests.worker.spec.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
import { test, expect } from '@playwright/test';

test.setTimeout(120 * 1000);
const timeout = 120 * 1000;

test.setTimeout(timeout);

test('Python unit tests - MicroPython on WORKER', async ({ page }) => {
await page.goto('http://localhost:8080/tests/python/index.html?worker');
const result = page.locator("#result"); // Payload for results will be here.
await result.waitFor(); // wait for the result.
await result.waitFor({ timeout }); // wait for the result.
const data = JSON.parse(await result.textContent()); // get the result data.
await expect(data.fails).toMatchObject([]); // ensure no test failed.
});

test('Python unit tests - Pyodide on WORKER', async ({ page }) => {
await page.goto('http://localhost:8080/tests/python/index.html?type=py&worker');
const result = page.locator("#result"); // Payload for results will be here.
await result.waitFor(); // wait for the result.
await result.waitFor({ timeout }); // wait for the result.
const data = JSON.parse(await result.textContent()); // get the result data.
await expect(data.fails).toMatchObject([]); // ensure no test failed.
});
Loading