Skip to content

Commit

Permalink
[0.4.x] Support Pyodide 0.27 (#154)
Browse files Browse the repository at this point in the history
* bump versions

* accept some FS as any

* rework piplite

* also invert _query_packages ordering

* update compatibility matrix
  • Loading branch information
bollwyvl authored and jtpio committed Jan 2, 2025
1 parent 36aedb9 commit ea1318d
Show file tree
Hide file tree
Showing 14 changed files with 53 additions and 36 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ yet work in a full, `jupyter_server`-hosted client such as JupyterLab or Noteboo
| `>=0.1.2,<=0.2.1` | `0.24.*` | `3.10.*` | `3.1.45` |
| `>=0.2.2,<=0.2.3` | `0.25.*` | `3.11.*` | `3.1.46` |
| `>=0.3.*,<=0.4.0` | `0.25.*` | `3.11.*` | `3.1.46` |
| `>=0.4.*,<=0.5.0` | `0.26.*` | `3.12.*` | `3.1.58` |
| `>=0.4.*,<=0.4.6` | `0.26.*` | `3.12.*` | `3.1.58` |
| `>=0.4.7,<=0.5.0` | `0.27.*` | `3.12.*` | `3.1.58` |

Note that the Emscripten version is strict down to the bugfix version.

Expand Down
2 changes: 1 addition & 1 deletion examples/jupyter-lite.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"@jupyterlite/pyodide-kernel-extension:kernel": {
"loadPyodideOptions": {
"packages": ["matplotlib", "micropip", "numpy", "sqlite3", "ssl"],
"lockFileURL": "https://cdn.jsdelivr.net/pyodide/v0.26.4/full/pyodide-lock.json?from-lite-config=1"
"lockFileURL": "https://cdn.jsdelivr.net/pyodide/v0.27.0/full/pyodide-lock.json?from-lite-config=1"
}
}
}
Expand Down
22 changes: 15 additions & 7 deletions jupyterlite_pyodide_kernel/constants.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Well-known (and otherwise) constants used by ``jupyterlite-pyodide-kernel``"""

### pyodide-specific values
### Pyodide-specific values
#: the key for PyPI-compatible API responses pointing to wheels
PIPLITE_URLS = "pipliteUrls"
DISABLE_PYPI_FALLBACK = "disablePyPIFallback"
Expand All @@ -10,9 +10,9 @@
KERNEL_SETTINGS_SCHEMA = "kernel.v0.schema.json"
#: where we put wheels, for now
PYPI_WHEELS = "pypi"
#: the plugin id for the pydodide kernel labextension
#: the plugin id for the Pydodide kernel labextension
PYODIDE_KERNEL_PLUGIN_ID = "@jupyterlite/pyodide-kernel-extension:kernel"
#: the npm name of the pyodide kernel
#: the npm name of the Pyodide kernel
PYODIDE_KERNEL_NPM_NAME = PYODIDE_KERNEL_PLUGIN_ID.split(":")[0]
#: the package.json key for piplite
PKG_JSON_PIPLITE = "piplite"
Expand All @@ -29,12 +29,20 @@
PYODIDE_URL_ENV_VAR = "JUPYTERLITE_PYODIDE_URL"

#: probably only compatible with this version of pyodide
PYODIDE_VERSION = "0.26.4"
PYODIDE_VERSION = "0.27.0"

#: the only kind of noarch wheel piplite understands
NOARCH_WHL = "py3-none-any.whl"

#: the only kind of binary wheel piplite understands
WASM_WHL = "emscripten_*_wasm32.whl"
#: the only kind of binary wheel piplite previously understood
EMSCRIPTEN_ABI_WHL = "emscripten_*_wasm32.whl"

ALL_WHL = [NOARCH_WHL, WASM_WHL]
#: legacy variable alias
WASM_WHL = EMSCRIPTEN_ABI_WHL

#: the Pyodide ABI wheel is the same as the Emscripten
#: ABI wheel, but with a different platform tag, i.e.,
# YYYY_buildnumber.
PYODIDE_ABI_WHL = "pyodide_*_wasm32.whl"

ALL_WHL = [NOARCH_WHL, WASM_WHL, PYODIDE_ABI_WHL]
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"pyodideUrl": {
"description": "The path to the main pyodide.js entry point",
"type": "string",
"default": "https://cdn.jsdelivr.net/pyodide/v0.26.4/full/pyodide.js",
"default": "https://cdn.jsdelivr.net/pyodide/v0.27.0/full/pyodide.js",
"format": "uri"
},
"disablePyPIFallback": {
Expand Down
2 changes: 1 addition & 1 deletion packages/pyodide-kernel-extension/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const KERNEL_ICON_URL = `data:image/svg+xml;base64,${btoa(KERNEL_ICON_SVG_STR)}`
/**
* The default CDN fallback for Pyodide
*/
const PYODIDE_CDN_URL = 'https://cdn.jsdelivr.net/pyodide/v0.26.4/full/pyodide.js';
const PYODIDE_CDN_URL = 'https://cdn.jsdelivr.net/pyodide/v0.27.0/full/pyodide.js';

/**
* The id for the extension, and key in the litePlugins.
Expand Down
2 changes: 1 addition & 1 deletion packages/pyodide-kernel/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"@types/jest": "^29.5.4",
"esbuild": "^0.19.2",
"jest": "^29.7.0",
"pyodide": "0.26.4",
"pyodide": "0.27.0",
"rimraf": "^5.0.1",
"ts-jest": "^26.3.0",
"typescript": "~5.2.2"
Expand Down
2 changes: 1 addition & 1 deletion packages/pyodide-kernel/py/piplite/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

This is a companion package to
[micropip](https://github.com/pyodide/pyodide/tree/main/packages/micropip) which only
works inside a [pyodide](https://github.com/pyodide/pyodide/) runtime.
works inside a [Pyodide](https://github.com/pyodide/pyodide/) runtime.

It adds the ability to use extra Warehouse-like API responses to resolve `pip`
dependencies, and can disable the fallback to `pypi.org`
18 changes: 11 additions & 7 deletions packages/pyodide-kernel/py/piplite/piplite/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,19 @@
.. code:
async def install(
requirements: str | list[str],
keep_going: bool = False, # --verbose
deps: bool = True, # --no-deps
credentials: str | None = None,
pre: bool = False, # --pre
) -> None:
self,
requirements: str | list[str], # -r and [packages]
keep_going: bool = False, # --verbose
deps: bool = True, # --no-deps
credentials: str | None = None, # no CLI alias
pre: bool = False, # --pre
index_urls: list[str] | str | None = None, # no CLI alias
*,
verbose: bool | int | None = None,
):
```
As this is _not_ really a CLI, it doesn't bother with accurate return codes, and should
As this is _not_ really a CLI, it doesn't bother with accurate return codes, and
failures should not block execution.
"""

Expand Down
12 changes: 8 additions & 4 deletions packages/pyodide-kernel/py/piplite/piplite/piplite.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ async def _get_pypi_json_from_index(name, piplite_url, fetch_kwargs) -> ProjectI

async def _query_package(
name: str,
fetch_kwargs: dict[str, Any] | None = None,
index_urls: list[str] | str | None = None,
fetch_kwargs: dict[str, Any] | None = None,
) -> ProjectInfo:
"""Fetch the warehouse API metadata for a specific ``pkgname``."""
for piplite_url in _PIPLITE_URLS:
Expand All @@ -99,7 +99,11 @@ async def _query_package(
f"{name} could not be installed: PyPI fallback is disabled"
)

return await _MP_QUERY_PACKAGE(name, fetch_kwargs, index_urls)
return await _MP_QUERY_PACKAGE(
name=name,
index_urls=index_urls,
fetch_kwargs=fetch_kwargs,
)


async def _install(
Expand Down Expand Up @@ -174,14 +178,14 @@ def install(
keep_going :
This parameter decides the behavior of the micropip when it encounters a
This parameter decides the behavior of micropip when it encounters a
Python package without a pure Python wheel while doing dependency
resolution:
- If ``False``, an error will be raised on first package with a missing
wheel.
- If ``True``, the micropip will keep going after the first error, and
- If ``True``, micropip will keep going after the first error, and
report a list of errors at the end.
deps :
Expand Down
2 changes: 1 addition & 1 deletion packages/pyodide-kernel/py/pyodide-kernel/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# pyodide-kernel

This is an companion package to [IPython](https://github.com/ipython/ipython) which only
works inside a [pyodide](https://github.com/pyodide/pyodide/) runtime.
works inside a [Pyodide](https://github.com/pyodide/pyodide/) runtime.
4 changes: 2 additions & 2 deletions packages/pyodide-kernel/src/coincident.worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@ export class PyodideCoincidentKernel extends PyodideRemoteKernel {
const { baseUrl } = options;

const driveFS = new PyodideDriveFS({
FS,
FS: FS as any,
PATH,
ERRNO_CODES,
baseUrl,
driveName: this._driveName,
mountpoint,
});
FS.mkdir(mountpoint);
FS.mkdirTree(mountpoint);
FS.mount(driveFS, {}, mountpoint);
FS.chdir(mountpoint);
this._driveFS = driveFS;
Expand Down
4 changes: 2 additions & 2 deletions packages/pyodide-kernel/src/comlink.worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ export class PyodideComlinkKernel extends PyodideRemoteKernel {
const { baseUrl } = options;

const driveFS = new PyodideDriveFS({
FS,
FS: FS as any,
PATH,
ERRNO_CODES,
baseUrl,
driveName: this._driveName,
mountpoint,
});
FS.mkdir(mountpoint);
FS.mkdirTree(mountpoint);
FS.mount(driveFS, {}, mountpoint);
FS.chdir(mountpoint);
this._driveFS = driveFS;
Expand Down
4 changes: 2 additions & 2 deletions packages/pyodide-kernel/src/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,14 @@ export class PyodideRemoteKernel {
const { DriveFS } = await import('@jupyterlite/contents');

const driveFS = new DriveFS({
FS,
FS: FS as any,
PATH,
ERRNO_CODES,
baseUrl,
driveName: this._driveName,
mountpoint,
});
FS.mkdir(mountpoint);
FS.mkdirTree(mountpoint);
FS.mount(driveFS, {}, mountpoint);
FS.chdir(mountpoint);
this._driveFS = driveFS;
Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2987,7 +2987,7 @@ __metadata:
comlink: ^4.4.2
esbuild: ^0.19.2
jest: ^29.7.0
pyodide: 0.26.4
pyodide: 0.27.0
rimraf: ^5.0.1
ts-jest: ^26.3.0
typescript: ~5.2.2
Expand Down Expand Up @@ -10897,12 +10897,12 @@ __metadata:
languageName: node
linkType: hard

"pyodide@npm:0.26.4":
version: 0.26.4
resolution: "pyodide@npm:0.26.4"
"pyodide@npm:0.27.0":
version: 0.27.0
resolution: "pyodide@npm:0.27.0"
dependencies:
ws: ^8.5.0
checksum: 6e2d6205022232309076a7ce7cf10b68e5d7dbcac9679a9378c579fabb5c0ba3349b325f16c05b74a9fbbf188b1f16f5c5fb97a4c33e3bced5da0fb3d01d57f8
checksum: 8d5382b16f37659595488ce69c46beb855a7fc3950254324f98c1cf619a9cc9ac2e304331a343391b8135200732b0a1a13f629989c13ca02b70a2e9dd8cb9029
languageName: node
linkType: hard

Expand Down

0 comments on commit ea1318d

Please sign in to comment.