Upgrade to Pyodide 0.21.3 (#887)

* Upgrade to Pyodide 21.3

* During the PyodideRuntime test, set the indexURL parameter of loadPyodide to allow Jest to find pyodide-adjacent files.
This commit is contained in:
Jeff Glass
2022-10-27 15:16:17 -05:00
committed by GitHub
parent ab085c2d92
commit 4850f39b5a
7 changed files with 34 additions and 26 deletions

View File

@@ -156,8 +156,8 @@ The `<py-config>` tag can be used as follows:
autoclose_loader = true
[[runtimes]]
src = "https://cdn.jsdelivr.net/pyodide/v0.21.2/full/pyodide.js"
name = "pyodide-0.21.2"
src = "https://cdn.jsdelivr.net/pyodide/v0.21.3/full/pyodide.js"
name = "pyodide-0.21.3"
lang = "python"
</py-config>
```
@@ -170,8 +170,8 @@ Alternatively, a JSON config can be passed using the `type` attribute.
{
"autoclose_loader": true,
"runtimes": [{
"src": "https://cdn.jsdelivr.net/pyodide/v0.21.2/full/pyodide.js",
"name": "pyodide-0.21.2",
"src": "https://cdn.jsdelivr.net/pyodide/v0.21.3/full/pyodide.js",
"name": "pyodide-0.21.3",
"lang": "python"
}]
}
@@ -189,8 +189,8 @@ where `custom.toml` contains
```
autoclose_loader = true
[[runtimes]]
src = "https://cdn.jsdelivr.net/pyodide/v0.21.2/full/pyodide.js"
name = "pyodide-0.21.2"
src = "https://cdn.jsdelivr.net/pyodide/v0.21.3/full/pyodide.js"
name = "pyodide-0.21.3"
lang = "python"
```
@@ -206,8 +206,8 @@ where `custom.json` contains
{
"autoclose_loader": true,
"runtimes": [{
"src": "https://cdn.jsdelivr.net/pyodide/v0.21.2/full/pyodide.js",
"name": "pyodide-0.21.2",
"src": "https://cdn.jsdelivr.net/pyodide/v0.21.3/full/pyodide.js",
"name": "pyodide-0.21.3",
"lang": "python"
}]
}

View File

@@ -31,7 +31,7 @@
"jest": "29.1.2",
"jest-environment-jsdom": "29.1.2",
"prettier": "2.7.1",
"pyodide": "0.21.2",
"pyodide": "0.21.3",
"rollup": "2.79.1",
"rollup-plugin-copy": "3.4.0",
"rollup-plugin-css-only": "3.1.0",
@@ -5067,9 +5067,9 @@
}
},
"node_modules/pyodide": {
"version": "0.21.2",
"resolved": "https://registry.npmjs.org/pyodide/-/pyodide-0.21.2.tgz",
"integrity": "sha512-pU2VSihi8uGZAJwN6Jhz1JCPQubJR1wGdwH08iH9NyrapwqmFNjL4RGv74OzYo/ZreHEXBQ1GrTZ1Pm0FXX0/A==",
"version": "0.21.3",
"resolved": "https://registry.npmjs.org/pyodide/-/pyodide-0.21.3.tgz",
"integrity": "sha512-5fu5P8ys8V8tKTsK9lag0HattbZQuFRdnNzv1LLOLCieM9A96OPs2cF29lPpcD9N+8GuUtfrGCWEMKiupTHUlA==",
"dev": true,
"dependencies": {
"base-64": "^1.0.0",
@@ -10028,9 +10028,9 @@
"dev": true
},
"pyodide": {
"version": "0.21.2",
"resolved": "https://registry.npmjs.org/pyodide/-/pyodide-0.21.2.tgz",
"integrity": "sha512-pU2VSihi8uGZAJwN6Jhz1JCPQubJR1wGdwH08iH9NyrapwqmFNjL4RGv74OzYo/ZreHEXBQ1GrTZ1Pm0FXX0/A==",
"version": "0.21.3",
"resolved": "https://registry.npmjs.org/pyodide/-/pyodide-0.21.3.tgz",
"integrity": "sha512-5fu5P8ys8V8tKTsK9lag0HattbZQuFRdnNzv1LLOLCieM9A96OPs2cF29lPpcD9N+8GuUtfrGCWEMKiupTHUlA==",
"dev": true,
"requires": {
"base-64": "^1.0.0",

View File

@@ -29,7 +29,7 @@
"jest": "29.1.2",
"jest-environment-jsdom": "29.1.2",
"prettier": "2.7.1",
"pyodide": "0.21.2",
"pyodide": "0.21.3",
"rollup": "2.79.1",
"rollup-plugin-copy": "3.4.0",
"rollup-plugin-css-only": "3.1.0",

View File

@@ -45,8 +45,8 @@ export const defaultConfig: AppConfig = {
"type": "app",
"autoclose_loader": true,
"runtimes": [{
"src": "https://cdn.jsdelivr.net/pyodide/v0.21.2/full/pyodide.js",
"name": "pyodide-0.21.2",
"src": "https://cdn.jsdelivr.net/pyodide/v0.21.3/full/pyodide.js",
"name": "pyodide-0.21.3",
"lang": "python"
}],
"packages":[],

View File

@@ -19,7 +19,7 @@ export class PyodideRuntime extends Runtime {
constructor(
config: AppConfig,
src = 'https://cdn.jsdelivr.net/pyodide/v0.21.2/full/pyodide.js',
src = 'https://cdn.jsdelivr.net/pyodide/v0.21.3/full/pyodide.js',
name = 'pyodide-default',
lang = 'python',
) {

View File

@@ -66,7 +66,7 @@ class TestConfig(PyScriptTest):
)
assert self.console.log.lines[-1] == "config name: app with external config"
# The default pyodide version is 0.21.2 as of writing
# The default pyodide version is 0.21.3 as of writing
# this test which is newer than the one we are loading below
# (after downloading locally) -- which is 0.20.0
@@ -175,8 +175,8 @@ class TestConfig(PyScriptTest):
{
"runtimes": [
{
"src": "https://cdn.jsdelivr.net/pyodide/v0.21.2/full/pyodide.js",
"name": "pyodide-0.21.2",
"src": "https://cdn.jsdelivr.net/pyodide/v0.21.3/full/pyodide.js",
"name": "pyodide-0.21.3",
"lang": "python"
},
{

View File

@@ -14,9 +14,8 @@ describe('PyodideRuntime', () => {
/**
* Since import { loadPyodide } from 'pyodide';
* is not used inside `src/pyodide.ts`, the function
* `runtime.initialize();` below which calls
* `loadInterpreter` and thus `loadPyodide` results
* in an expected issue of:
* `runtime.loadInterpreter();` below which calls
* `loadPyodide()` results in an expected issue of:
* ReferenceError: loadPyodide is not defined
*
* To make jest happy, while also not importing
@@ -24,9 +23,18 @@ describe('PyodideRuntime', () => {
* following lines - so as to dynamically import
* and make it available in the global namespace
* - are used.
*
* Pyodide uses a "really hacky" method to get the
* URL/Path where packages/package data are stored;
* it throws an error, catches it, and parses it. In
* Jest, this calculated path is different than in
* the browser/Node, so files cannot be found and the
* test fails. We set indexURL below the correct location
* to fix this.
* See https://github.com/pyodide/pyodide/blob/7dfee03a82c19069f714a09da386547aeefef242/src/js/pyodide.ts#L161-L179
*/
const pyodideSpec = await import('pyodide');
global.loadPyodide = pyodideSpec.loadPyodide;
global.loadPyodide = async (options) => pyodideSpec.loadPyodide(Object.assign({indexURL: '../pyscriptjs/node_modules/pyodide/'}, options));
await runtime.loadInterpreter();
});