Skip to content
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

Add a Pyodide runner based on the python-execution-prototypes #893

Merged
merged 43 commits into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from 41 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
b6fe433
Add a PyodideRunner component and display it if ?pyodide=true is set
tuzz Jan 18, 2024
809e395
Copy the modified Pyodide packages into public/packages/
tuzz Jan 18, 2024
ea2080e
Copy the pyodideWorker.js from the python-execution-prototypes project
tuzz Jan 18, 2024
73eb5b1
Use correct file paths in pyodideWorker.js
tuzz Jan 18, 2024
2469a80
Set HTTP headers to enable SharedArrayBuffer for all requests
tuzz Jan 19, 2024
0e220ad
Print worker messages to the JavaScript console
tuzz Jan 19, 2024
fffffd7
Update the changelog
tuzz Jan 19, 2024
881a615
Add the worker-loader NPM package
tuzz Jan 19, 2024
d4e1232
Move pygal.js and _internal_sense_hat.js into PyodideRunner/
tuzz Jan 19, 2024
dd73d4d
Work around a webpack reloading problem
tuzz Jan 19, 2024
bd73880
Move PyodideWorker.js into the PyodideRunner/ directory
tuzz Jan 19, 2024
4f791e1
Use the worker-loader webpack loader to load PyodideWorker.js
tuzz Jan 19, 2024
409ca2f
Fix eslint errors and warnings
tuzz Jan 19, 2024
cab3c1d
Add the p5 package from python-execution-prototypes
tuzz Jan 19, 2024
6b6bd04
Use PUBLIC_URL when loading the Python wheel files
tuzz Jan 19, 2024
889de0f
Get a basic version of the pyodide workflow running
tuzz Jan 22, 2024
69a7b80
Parse errors from Python and present them in the UI
tuzz Jan 22, 2024
03be18c
Disable the ‘Run’ button until Pyodide has loaded
tuzz Jan 22, 2024
b5452c8
Improve Pyodide error messages and presentation
tuzz Jan 22, 2024
af3c012
Write components to the Wasm in-memory filesystem before running prog…
tuzz Jan 23, 2024
7a33589
Import RunnerControls in PyodideRunner.jsx
tuzz Jan 23, 2024
60dec34
Copy VisualOutputPane.jsx to the PyodideRunner
tuzz Jan 23, 2024
504930b
Tidy up VisualOutputPane.jsx a bit
tuzz Jan 23, 2024
b6fa599
Implement visualOutput.handleVisual to display graphical output
tuzz Jan 23, 2024
5ff50b7
Update PyodideWorker.js to the latest version
tuzz Jan 24, 2024
394df9e
Forward standard input to the PyodideWorker.js
tuzz Jan 24, 2024
7ccd8c9
Add support for stdin control keys
tuzz Jan 24, 2024
3677a56
Remove ctrl-c and ctrl-z handling in PyodudeRunner.jsx
tuzz Jan 25, 2024
183e7c7
Disable stdin when the program is loaded/stopped/errored
tuzz Jan 25, 2024
cf382fb
Call createError for non-interrupt errors in the same way as PythonRu…
tuzz Jan 25, 2024
78c0784
Tidy handleInput and fix lint errors
tuzz Jan 25, 2024
ea6dec0
Write projectImages to the Pyodide filesystem before running the program
tuzz Jan 25, 2024
e1276c2
Tidy up lines relating to hasVisualOutput
tuzz Jan 25, 2024
7ef9742
Set ‘Execution interrupted’ from the translation key
tuzz Jan 25, 2024
4619aa5
Dynamically show the VisualOutputPane when a visual program is run
tuzz Jan 25, 2024
64a8fe1
Fix the program not ending after pressing ctrl-d
tuzz Jan 25, 2024
18101cf
Remove sports_club.sqlite from PyodideWorker.js
tuzz Jan 25, 2024
ff594e0
Load PyodideWorker.mock.js in the Jest tests
tuzz Jan 30, 2024
a1bae39
Ensure the editor.codeRunLoading state is set un RunButton.test.js
tuzz Jan 30, 2024
35810c1
Fix the interface for pyodide.FS.writeFile
tuzz Jan 28, 2024
19dc454
Merge branch 'main' into pyodide-runner
sra405 Feb 12, 2024
a47452f
Replace ternaries with && expressions
tuzz Feb 12, 2024
2d6931a
Simplify getInputElement in PyodideRunner
tuzz Feb 12, 2024
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Toggle errors sent via apiCallHandler off (#890)
- Upgrade webpack-dev-server to 4.0.0 to support conditional headers
- Upgrade yarn to 3.4.1 to workaround a string-width issue
- Add a ?pyodide=true flag for python project pages

### Fixed

Expand Down
4 changes: 3 additions & 1 deletion config/webpackDevServer.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ module.exports = function (proxy, _allowedHost) {
headers: {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, PATCH, OPTIONS",
"Access-Control-Allow-Headers": "X-Requested-With, content-type, Authorization"
"Access-Control-Allow-Headers": "X-Requested-With, content-type, Authorization",
"Cross-Origin-Opener-Policy": "same-origin",
"Cross-Origin-Embedder-Policy": "require-corp",
},
client: {
// Silence WebpackDevServer's own logs since they're generally not useful.
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,8 @@
"webpack-cli": "^4.9.2",
"webpack-dev-server": "4.0.0",
"webpack-manifest-plugin": "2.2.0",
"workbox-webpack-plugin": "5.1.4"
"workbox-webpack-plugin": "5.1.4",
"worker-loader": "^3.0.8"
},
"jest": {
"roots": [
Expand Down Expand Up @@ -227,7 +228,8 @@
"modulePaths": [],
"moduleNameMapper": {
"^react-native$": "react-native-web",
"^.+\\.module\\.(css|sass|scss)$": "identity-obj-proxy"
"^.+\\.module\\.(css|sass|scss)$": "identity-obj-proxy",
"PyodideWorker.js": "<rootDir>/src/components/Editor/Runners/PyodideRunner/PyodideWorker.mock.js"
},
"moduleFileExtensions": [
"web.js",
Expand Down
Binary file added public/packages/p5-0.0.1-py3-none-any.whl
Binary file not shown.
Binary file not shown.
Binary file added public/packages/turtle-0.0.1-py3-none-any.whl
Binary file not shown.
4 changes: 4 additions & 0 deletions src/assets/stylesheets/PythonRunner.scss
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@

.pythonrunner-console-output-line {
padding-inline-end: 5px;

&.stderr {
color: red;
}
}

.pythonrunner-input {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Editor/ErrorMessage/ErrorMessage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const ErrorMessage = () => {

return error ? (
<div className={`error-message error-message--${settings.fontSize}`}>
<p className="error-message__content">{error}</p>
<pre className="error-message__content">{error}</pre>
</div>
) : null;
};
Expand Down
6 changes: 5 additions & 1 deletion src/components/Editor/Output/Output.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,16 @@ const Output = () => {
const isEmbedded = useSelector((state) => state.editor.isEmbedded);
const searchParams = new URLSearchParams(window.location.search);
const isBrowserPreview = searchParams.get("browserPreview") === "true";
const usePyodide = searchParams.get("pyodide") === "true";

return (
<>
<ExternalFiles />
<div className="proj-runner-container">
<RunnerFactory projectType={project.project_type} />
<RunnerFactory
projectType={project.project_type}
usePyodide={usePyodide}
/>
{isEmbedded && !isBrowserPreview ? <RunBar embedded /> : null}
</div>
</>
Expand Down
Loading
Loading