Upgrade Pyodide to v0.22.1 (#1144)

* 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
This commit is contained in:
Madhur Tandon
2023-02-08 22:01:51 +05:30
committed by GitHub
parent 4c30359b71
commit 9a908e5fd0
13 changed files with 673 additions and 2189 deletions

View File

@@ -144,8 +144,8 @@ $ pytest test_01_basic.py -k test_pyscript_hello -s
[ 0.00 page.goto ] pyscript_hello.html
[ 0.01 request ] 200 - fake_server - http://fake_server/pyscript_hello.html
...
[ 0.17 console.info ] [py-loader] Downloading pyodide-0.21.3...
[ 0.18 request ] 200 - CACHED - https://cdn.jsdelivr.net/pyodide/v0.21.3/full/pyodide.js
[ 0.17 console.info ] [py-loader] Downloading pyodide-0.22.1...
[ 0.18 request ] 200 - CACHED - https://cdn.jsdelivr.net/pyodide/v0.22.1/full/pyodide.js
...
[ 3.59 console.info ] [pyscript/main] PyScript page fully initialized
[ 3.60 console.log ] hello pyscript
@@ -211,16 +211,16 @@ $ pytest --clear-http-cache
-------------------- SmartRouter HTTP cache --------------------
Requests found in the cache:
https://raw.githubusercontent.com/pyscript/pyscript/main/README.md
https://cdn.jsdelivr.net/pyodide/v0.21.3/full/repodata.json
https://cdn.jsdelivr.net/pyodide/v0.21.3/full/pyodide.asm.js
https://cdn.jsdelivr.net/pyodide/v0.21.3/full/micropip-0.1-py3-none-any.whl
https://cdn.jsdelivr.net/pyodide/v0.21.3/full/pyodide.asm.data
https://cdn.jsdelivr.net/pyodide/v0.21.3/full/pyodide.js
https://cdn.jsdelivr.net/pyodide/v0.21.3/full/pyodide.asm.wasm
https://cdn.jsdelivr.net/pyodide/v0.21.3/full/pyodide_py.tar
https://cdn.jsdelivr.net/pyodide/v0.21.3/full/pyparsing-3.0.9-py3-none-any.whl
https://cdn.jsdelivr.net/pyodide/v0.21.3/full/distutils.tar
https://cdn.jsdelivr.net/pyodide/v0.21.3/full/packaging-21.3-py3-none-any.whl
https://cdn.jsdelivr.net/pyodide/v0.22.1/full/repodata.json
https://cdn.jsdelivr.net/pyodide/v0.22.1/full/pyodide.asm.js
https://cdn.jsdelivr.net/pyodide/v0.22.1/full/micropip-0.1-py3-none-any.whl
https://cdn.jsdelivr.net/pyodide/v0.22.1/full/pyodide.asm.data
https://cdn.jsdelivr.net/pyodide/v0.22.1/full/pyodide.js
https://cdn.jsdelivr.net/pyodide/v0.22.1/full/pyodide.asm.wasm
https://cdn.jsdelivr.net/pyodide/v0.22.1/full/pyodide_py.tar
https://cdn.jsdelivr.net/pyodide/v0.22.1/full/pyparsing-3.0.9-py3-none-any.whl
https://cdn.jsdelivr.net/pyodide/v0.22.1/full/distutils.tar
https://cdn.jsdelivr.net/pyodide/v0.22.1/full/packaging-21.3-py3-none-any.whl
Cache cleared
```

View File

@@ -2,11 +2,11 @@
<title>Bokeh Example</title>
<meta charset="iso-8859-1">
<link rel="icon" type="image/x-icon" href="./favicon.png">
<script type="text/javascript" src="https://cdn.bokeh.org/bokeh/release/bokeh-2.4.2.min.js"></script>
<script type="text/javascript" src="https://cdn.bokeh.org/bokeh/release/bokeh-gl-2.4.2.min.js"></script>
<script type="text/javascript" src="https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.4.2.min.js"></script>
<script type="text/javascript" src="https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.4.2.min.js"></script>
<script type="text/javascript" src="https://cdn.bokeh.org/bokeh/release/bokeh-mathjax-2.4.2.min.js"></script>
<script type="text/javascript" src="https://cdn.bokeh.org/bokeh/release/bokeh-3.0.3.min.js"></script>
<script type="text/javascript" src="https://cdn.bokeh.org/bokeh/release/bokeh-gl-3.0.3.min.js"></script>
<script type="text/javascript" src="https://cdn.bokeh.org/bokeh/release/bokeh-widgets-3.0.3.min.js"></script>
<script type="text/javascript" src="https://cdn.bokeh.org/bokeh/release/bokeh-tables-3.0.3.min.js"></script>
<script type="text/javascript" src="https://cdn.bokeh.org/bokeh/release/bokeh-mathjax-3.0.3.min.js"></script>
<script type="text/javascript">
Bokeh.set_log_level("info");
@@ -31,7 +31,9 @@
<py-config>
packages = [
"bokeh"
"pandas",
"bokeh",
"xyzservices"
]
plugins = [
"../build/plugins/python/py_tutor.py"
@@ -49,7 +51,7 @@
from bokeh.resources import CDN
# create a new plot with default tools, using figure
p = figure(plot_width=400, plot_height=400)
p = figure(width=400, height=400)
# add a circle renderer with x and y coordinates, size, color, and alpha
p.circle([1, 2, 3, 4, 5], [6, 7, 2, 4, 5], size=15, line_color="navy", fill_color="orange", fill_alpha=0.5)

View File

@@ -2,11 +2,11 @@
<title>Bokeh Example</title>
<meta charset="iso-8859-1">
<link rel="icon" type="image/x-icon" href="./favicon.png">
<script type="text/javascript" src="https://cdn.bokeh.org/bokeh/release/bokeh-2.4.2.js"></script>
<script type="text/javascript" src="https://cdn.bokeh.org/bokeh/release/bokeh-gl-2.4.2.min.js"></script>
<script type="text/javascript" src="https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.4.2.min.js"></script>
<script type="text/javascript" src="https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.4.2.min.js"></script>
<script type="text/javascript" src="https://cdn.bokeh.org/bokeh/release/bokeh-mathjax-2.4.2.min.js"></script>
<script type="text/javascript" src="https://cdn.bokeh.org/bokeh/release/bokeh-2.4.3.js"></script>
<script type="text/javascript" src="https://cdn.bokeh.org/bokeh/release/bokeh-gl-2.4.3.min.js"></script>
<script type="text/javascript" src="https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.4.3.min.js"></script>
<script type="text/javascript" src="https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.4.3.min.js"></script>
<script type="text/javascript" src="https://cdn.bokeh.org/bokeh/release/bokeh-mathjax-2.4.3.min.js"></script>
<link rel="stylesheet" href="./assets/css/examples.css" />
<script type="text/javascript">
@@ -32,8 +32,8 @@
<py-config>
packages = [
"bokeh",
"numpy"
"https://cdn.holoviz.org/panel/0.14.3/dist/wheels/bokeh-2.4.3-py3-none-any.whl",
"numpy",
]
plugins = [
"../build/plugins/python/py_tutor.py"

View File

@@ -26,7 +26,7 @@
<py-tutor>
<py-config>
packages = [
"bokeh",
"https://cdn.holoviz.org/panel/0.14.3/dist/wheels/bokeh-2.4.3-py3-none-any.whl",
"numpy",
"panel==0.14.1"
]

View File

@@ -21,9 +21,9 @@
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@loaders.gl/json@3.1.7/dist/dist.min.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@loaders.gl/3d-tiles@3.1.7/dist/dist.min.js"></script>
<script type="text/javascript" src="https://api.mapbox.com/mapbox-gl-js/v2.6.1/mapbox-gl.js"></script>
<script type="text/javascript" src="https://cdn.bokeh.org/bokeh/release/bokeh-2.4.2.js"></script>
<script type="text/javascript" src="https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.4.2.min.js"></script>
<script type="text/javascript" src="https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.4.2.min.js"></script>
<script type="text/javascript" src="https://cdn.bokeh.org/bokeh/release/bokeh-2.4.3.js"></script>
<script type="text/javascript" src="https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.4.3.min.js"></script>
<script type="text/javascript" src="https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.4.3.min.js"></script>
<script type="text/javascript" src="https://unpkg.com/@holoviz/panel@0.13.1/dist/panel.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.1/dist/css/bootstrap.min.css">
@@ -68,7 +68,7 @@
<py-tutor>
<py-config>
packages = [
"bokeh",
"https://cdn.holoviz.org/panel/0.14.3/dist/wheels/bokeh-2.4.3-py3-none-any.whl",
"numpy",
"pandas",
"panel==0.13.1"

View File

@@ -18,9 +18,9 @@
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/vega-lite@5"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/vega-embed@6"></script>
<script type="text/javascript" src="https://unpkg.com/tabulator-tables@4.9.3/dist/js/tabulator.js"></script>
<script type="text/javascript" src="https://cdn.bokeh.org/bokeh/release/bokeh-2.4.2.js"></script>
<script type="text/javascript" src="https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.4.2.min.js"></script>
<script type="text/javascript" src="https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.4.2.min.js"></script>
<script type="text/javascript" src="https://cdn.bokeh.org/bokeh/release/bokeh-2.4.3.js"></script>
<script type="text/javascript" src="https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.4.3.min.js"></script>
<script type="text/javascript" src="https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.4.3.min.js"></script>
<script type="text/javascript" src="https://unpkg.com/@holoviz/panel@0.13.1/dist/panel.min.js"></script>
<script type="text/javascript">
Bokeh.set_log_level("info");
@@ -71,6 +71,7 @@
<py-tutor>
<py-config>
packages = [
"https://cdn.holoviz.org/panel/0.14.3/dist/wheels/bokeh-2.4.3-py3-none-any.whl",
"altair",
"numpy",
"pandas",

View File

@@ -15,9 +15,9 @@
<link rel="stylesheet" href="https://unpkg.com/@holoviz/panel@0.13.1/dist/css/markdown.css" type="text/css" />
<script type="text/javascript" src="https://unpkg.com/tabulator-tables@4.9.3/dist/js/tabulator.js"></script>
<script type="text/javascript" src="https://cdn.bokeh.org/bokeh/release/bokeh-2.4.2.js"></script>
<script type="text/javascript" src="https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.4.2.min.js"></script>
<script type="text/javascript" src="https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.4.2.min.js"></script>
<script type="text/javascript" src="https://cdn.bokeh.org/bokeh/release/bokeh-2.4.3.js"></script>
<script type="text/javascript" src="https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.4.3.min.js"></script>
<script type="text/javascript" src="https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.4.3.min.js"></script>
<script type="text/javascript" src="https://unpkg.com/@holoviz/panel@0.13.1/dist/panel.min.js"></script>
<script type="text/javascript">
Bokeh.set_log_level("info");
@@ -58,7 +58,7 @@
<py-tutor>
<py-config>
packages = [
"bokeh",
"https://cdn.holoviz.org/panel/0.14.3/dist/wheels/bokeh-2.4.3-py3-none-any.whl",
"numpy",
"pandas",
"panel==0.13.1"

File diff suppressed because it is too large Load Diff

View File

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

View File

@@ -53,8 +53,8 @@ export const defaultConfig: AppConfig = {
type: 'app',
interpreters: [
{
src: 'https://cdn.jsdelivr.net/pyodide/v0.21.3/full/pyodide.js',
name: 'pyodide-0.21.3',
src: 'https://cdn.jsdelivr.net/pyodide/v0.22.1/full/pyodide.js',
name: 'pyodide-0.22.1',
lang: 'python',
},
],

View File

@@ -28,7 +28,7 @@ export class PyodideInterpreter extends Interpreter {
constructor(
config: AppConfig,
stdio: Stdio,
src = 'https://cdn.jsdelivr.net/pyodide/v0.21.3/full/pyodide.js',
src = 'https://cdn.jsdelivr.net/pyodide/v0.22.1/full/pyodide.js',
name = 'pyodide-default',
lang = 'python',
) {
@@ -78,6 +78,7 @@ export class PyodideInterpreter extends Interpreter {
await this.loadPackage('micropip');
}
logger.info('pyodide loaded and initialized');
this.run('print("Python initialization complete")')
}
run(code: string): unknown {
@@ -90,7 +91,17 @@ export class PyodideInterpreter extends Interpreter {
async loadPackage(names: string | string[]): Promise<void> {
logger.info(`pyodide.loadPackage: ${names.toString()}`);
await this.interface.loadPackage(names, logger.info.bind(logger), logger.info.bind(logger));
// the new way in v0.22.1 is to pass it as a dict of options i.e.
// { messageCallback: logger.info.bind(logger), errorCallback: logger.info.bind(logger) }
// but one of our tests tries to use a locally downloaded older version of pyodide
// for which the signature of `loadPackage` accepts the above params as args i.e.
// the call uses `logger.info.bind(logger), logger.info.bind(logger)`.
if (this.run("import sys; sys.modules['pyodide'].__version__").toString().startsWith("0.22")) {
await this.interface.loadPackage(names, { messageCallback: logger.info.bind(logger), errorCallback: logger.info.bind(logger) });
}
else {
await this.interface.loadPackage(names, logger.info.bind(logger), logger.info.bind(logger));
}
}
async installPackage(package_name: string | string[]): Promise<void> {

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.3 as of writing
# The default pyodide version is 0.22.1 as of writing
# this test which is newer than the one we are loading below
# (after downloading locally) -- which is 0.20.0
@@ -226,8 +226,8 @@ class TestConfig(PyScriptTest):
{
"interpreters": [
{
"src": "https://cdn.jsdelivr.net/pyodide/v0.21.3/full/pyodide.js",
"name": "pyodide-0.21.3",
"src": "https://cdn.jsdelivr.net/pyodide/v0.22.1/full/pyodide.js",
"name": "pyodide-0.22.1",
"lang": "python"
},
{

View File

@@ -104,7 +104,7 @@ class TestExamples(PyScriptTest):
self.goto("examples/bokeh.html")
self.wait_for_pyscript()
assert self.page.title() == "Bokeh Example"
wait_for_render(self.page, "*", '<div.*class=\\"bk\\".*>')
wait_for_render(self.page, "*", '<div.*?class="bk.*".*?>')
self.assert_no_banners()
self.check_tutor_generated_code()