Skip to content

Commit 0325a82

Browse files
authored
Add micropip 0.8.0 workaround (#33)
1 parent 3903815 commit 0325a82

File tree

10 files changed

+595
-496
lines changed

10 files changed

+595
-496
lines changed

CHANGELOG.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,21 @@
33
<details>
44

55
<summary><b>UNRELEASED</b></summary>
6+
</details>
67

78
## `0.1.1`
89

910
### `jupyterlite-pyodide-lock 0.1.1`
1011

11-
> TBD
12+
- [#33]
13+
- adds a workaround for `micropip 0.8.0`
14+
- cleans up the README
1215

1316
### `jupyterlite-pyodide-lock-webdriver 0.1.1`
1417

15-
> TBD
18+
- [#33] adds some badges, and cleans up the README
1619

17-
</details>
20+
[#33]: https://github.com/deathbeds/jupyterlite-pyodide-lock/pull/33
1821

1922
## `0.1.0`
2023

README.md

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,28 @@
33
> Build reproducible Jupyter Lite sites with [jupyterlite-pyodide-kernel][jlpk] and
44
> [pyodide-lock][pl].
55
6+
| docs | install | build |
7+
| :-------------------------: | :----------------------------------------------------------------------------------------: | :----------------------------------: |
8+
| [![docs][docs-badge]][docs] | [![install from pypi][pypi-badge]][pypi] [![install from conda-forge][conda-badge]][conda] | [![build][workflow-badge]][workflow] |
9+
10+
[docs]: https://jupyterlite-pyodide-lock.rtfd.org
11+
[docs-badge]:
12+
https://readthedocs.org/projects/jupyterlite-pyodide-lock/badge/?version=latest
13+
[conda-badge]: https://img.shields.io/conda/vn/conda-forge/jupyterlite-pyodide-lock
14+
[conda]: https://anaconda.org/conda-forge/jupyterlite-pyodide-lock
15+
[pypi-badge]: https://img.shields.io/pypi/v/jupyterlite-pyodide-lock
16+
[pypi]: https://pypi.org/project/jupyterlite-pyodide-lock
17+
[workflow-badge]:
18+
https://github.com/deathbeds/jupyterlite-pyodide-lock/actions/workflows/test.yml/badge.svg?branch=main
19+
[workflow]:
20+
https://github.com/deathbeds/jupyterlite-pyodide-lock/actions/workflows/test.yml?query=branch%3Amain
21+
622
View the full documentation on [ReadTheDocs][rtfd].
723

824
[jlpk]: https://github.com/jupyterlite/pyodide-kernel
925
[pl]: https://github.com/pyodide/pyodide-lock
1026
[rtfd]: https://jupyterlite-pyodide-lock.rtfd.org/en/latest
1127

12-
> **⚠️ EXPERIMENTAL**
13-
>
14-
> These packages are not yet released. See the [GitHub repo][gh] for development status.
15-
16-
[gh]: https://github.com/deathbeds/jupyterlite-pyodide-lock
17-
1828
## Overview
1929

2030
`jupyterlite-pyodide-lock` avoids **run time** `pyodide` and `jupyterlite` package
@@ -42,7 +52,7 @@ controlled baseline `pyodide` runtime environment, or ensure complex dependencie
4252

4353
```text
4454
jupyterlite-core ==0.4.5
45-
jupyterlite-pyodide-kernel ==0.4.6
55+
jupyterlite-pyodide-kernel ==0.4.7
4656
jupyterlite-pyodide-lock ==0.1.1
4757
```
4858

@@ -107,7 +117,7 @@ controlled baseline `pyodide` runtime environment, or ensure complex dependencie
107117
dependencies:
108118
- ipywidgets ==8.1.5
109119
- jupyterlite-core ==0.4.5
110-
- jupyterlite-pyodide-kernel ==0.4.6
120+
- jupyterlite-pyodide-kernel ==0.4.7
111121
- jupyterlite-pyodide-lock-recommended ==0.1.1
112122
```
113123

_scripts/vale/config/vocabularies/jlpl/accept.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ PyPI
7474
pytest
7575
pythonhosted
7676
raw_packages
77+
README
7778
ReadTheDocs
7879
REPLite
7980
repo

docs/demo.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# 🕹️ DEMO
22

3+
> Hang tight, the demo is currently loading in an `iframe`.
4+
35
<div class="jlpl-demo">
46
<iframe src="./_static/lab/index.html?path=README.ipynb" width="100%">
57
</iframe>

examples/jupyter_lite_config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"temp_profile": true
1818
},
1919
"WebDriverLocker": {
20-
"webdriver_log_path": "../build/geckodriver.log",
20+
"webdriver_log_output": "../build/geckodriver.log",
2121
"webdriver_service_args": ["--log", "trace"]
2222
}
2323
}

pixi.lock

Lines changed: 445 additions & 428 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pixi.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ name = "jlpl"
55
version = "0.1.1"
66
channels = [
77
"conda-forge",
8-
"conda-forge/label/jupyterlite_core_alpha",
9-
"conda-forge/label/jupyterlite_pyodide_kernel_alpha",
8+
"conda-forge/label/jupyterlite_core_beta",
9+
"conda-forge/label/jupyterlite_pyodide_kernel_beta",
1010
]
1111
platforms = ["linux-64", "osx-64", "win-64", "osx-arm64"]
1212

@@ -658,12 +658,12 @@ python = "3.13.*"
658658
pyodide-lock = "0.1.0a6"
659659

660660
[feature.deps-run-next.dependencies.jupyterlite-core]
661-
version = ">=0.5.0a2"
662-
channel = "conda-forge/label/jupyterlite_core_alpha"
661+
version = ">=0.5.0b0"
662+
channel = "conda-forge/label/jupyterlite_core_beta"
663663

664664
[feature.deps-run-next.dependencies.jupyterlite-pyodide-kernel]
665-
version = ">=0.5.0a1"
666-
channel = "conda-forge/label/jupyterlite_pyodide_kernel_alpha"
665+
version = ">=0.5.0b0"
666+
channel = "conda-forge/label/jupyterlite_pyodide_kernel_beta"
667667

668668
[feature.deps-pip.dependencies]
669669
pip = "*"

py/jupyterlite-pyodide-lock-webdriver/README.md

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,48 @@
44
55
[webdriver]: https://www.w3.org/TR/webdriver
66

7+
| docs | install | build |
8+
| :-------------------------: | :----------------------------------------------------------------------------------------: | :----------------------------------: |
9+
| [![docs][docs-badge]][docs] | [![install from pypi][pypi-badge]][pypi] [![install from conda-forge][conda-badge]][conda] | [![build][workflow-badge]][workflow] |
10+
11+
[docs]: https://jupyterlite-pyodide-lock.rtfd.org
12+
[docs-badge]:
13+
https://readthedocs.org/projects/jupyterlite-pyodide-lock/badge/?version=latest
14+
[conda-badge]:
15+
https://img.shields.io/conda/vn/conda-forge/jupyterlite-pyodide-lock-webdriver
16+
[conda]: https://anaconda.org/conda-forge/jupyterlite-pyodide-lock-webdriver
17+
[pypi-badge]: https://img.shields.io/pypi/v/jupyterlite-pyodide-lock-webdriver
18+
[pypi]: https://pypi.org/project/jupyterlite-pyodide-lock-webdriver
19+
[workflow-badge]:
20+
https://github.com/deathbeds/jupyterlite-pyodide-lock/actions/workflows/test.yml/badge.svg?branch=main
21+
[workflow]:
22+
https://github.com/deathbeds/jupyterlite-pyodide-lock/actions/workflows/test.yml?query=branch%3Amain
23+
24+
View the full documentation on [ReadTheDocs][rtfd].
25+
26+
[rtfd]: https://jupyterlite-pyodide-lock.rtfd.org/en/latest
27+
728
## Install
829

9-
> This package is not yet released. See `CONTRIBUTING.md` for development.
10-
>
11-
> ```bash
12-
> pip install jupyterlite-pyodide-lock-webdriver
13-
> ```
30+
```bash
31+
pip install jupyterlite-pyodide-lock-webdriver
32+
```
33+
34+
or
35+
36+
```bash
37+
conda install jupyterlite-pyodide-lock-webdriver
38+
```
1439

1540
## Usage
1641

1742
### Configure
1843

1944
> See the `jupyterlite-pyodide-lock` documentation for more information.
2045
21-
```yaml
22-
# examples/jupyter_lite_config.json
46+
```json
2347
{
24-
'PyodideLockAddon': { 'enabled': true, 'locker': 'WebDriverLocker' },
25-
'WebDriverLocker': { 'browser': 'firefox' },
48+
"PyodideLockAddon": { "enabled": true, "locker": "WebDriverLocker" },
49+
"WebDriverLocker": { "browser': 'firefox" }
2650
}
2751
```

py/jupyterlite-pyodide-lock/README.md

Lines changed: 54 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,37 @@
22

33
> Create pre-solved environments for jupyterlite-pyodide-kernel with pyodide-lock.
44
5+
| docs | install | build |
6+
| :-------------------------: | :----------------------------------------------------------------------------------------: | :----------------------------------: |
7+
| [![docs][docs-badge]][docs] | [![install from pypi][pypi-badge]][pypi] [![install from conda-forge][conda-badge]][conda] | [![build][workflow-badge]][workflow] |
8+
9+
[docs]: https://jupyterlite-pyodide-lock.rtfd.org
10+
[docs-badge]:
11+
https://readthedocs.org/projects/jupyterlite-pyodide-lock/badge/?version=latest
12+
[conda-badge]: https://img.shields.io/conda/vn/conda-forge/jupyterlite-pyodide-lock
13+
[conda]: https://anaconda.org/conda-forge/jupyterlite-pyodide-lock
14+
[pypi-badge]: https://img.shields.io/pypi/v/jupyterlite-pyodide-lock
15+
[pypi]: https://pypi.org/project/jupyterlite-pyodide-lock
16+
[workflow-badge]:
17+
https://github.com/deathbeds/jupyterlite-pyodide-lock/actions/workflows/test.yml/badge.svg?branch=main
18+
[workflow]:
19+
https://github.com/deathbeds/jupyterlite-pyodide-lock/actions/workflows/test.yml?query=branch%3Amain
20+
21+
View the full documentation on [ReadTheDocs][rtfd].
22+
23+
[rtfd]: https://jupyterlite-pyodide-lock.rtfd.org/en/latest
24+
525
## Installing
626

7-
> This package is not yet released. See `CONTRIBUTING.md` for development.
8-
>
9-
> ```bash
10-
> pip install jupyterlite-pyodide-lock
11-
> ```
12-
>
13-
> or mamba/conda:
14-
>
15-
> ```bash
16-
> mamba install -c conda-forge jupyterlite-pyodide-lock
17-
> ```
27+
```bash
28+
pip install jupyterlite-pyodide-lock
29+
```
30+
31+
or:
32+
33+
```bash
34+
mamba install -c conda-forge jupyterlite-pyodide-lock
35+
```
1836

1937
## Usage
2038

@@ -30,36 +48,34 @@ A number of ways to add requirements to the lock file are supported:
3048
- URLs to remote wheels that will be downloaded and cached
3149
- local paths relative to `lite_dir` of `.whl` files (or folders of wheels)
3250

33-
```yaml
34-
# examples/jupyter_lite_config.json
35-
{ 'PyodideLockAddon': { 'enabled': true, 'specs': [
36-
# pep508 spec
37-
'ipywidgets >=8.1,<8.2',
38-
], 'packages': [
39-
# a wheel
40-
'../dist/ipywidgets-8.1.2-py3-none-any.whl',
41-
# a folder of wheels
42-
'../dist',
43-
] } }
51+
```json
52+
{
53+
"PyodideLockAddon": {
54+
"enabled": true,
55+
"specs": ["ipywidgets >=8.1,<8.2"],
56+
"packages": ["../dist/ipywidgets-8.1.2-py3-none-any.whl", "../dist"]
57+
}
58+
}
4459
```
4560

4661
#### Lockers
4762

4863
The _Locker_ is responsible for starting a browser, executing `micopip.install` and
4964
`micropip.freeze` to try to get a viable lock file solution.
5065

51-
```yaml
52-
{ 'PyodideLockAddon': {
53-
'enabled': true,
54-
# the default locker: uses naive a `subprocess.Popen` approach
55-
'locker': 'browser',
56-
}, 'BrowserLocker': {
57-
# requires `firefox` or `firefox.exe` on PATH
58-
'browser': 'firefox',
59-
'headless': true,
60-
'private_mode': true,
61-
'temp_profile': true,
62-
} }
66+
```json
67+
{
68+
"PyodideLockAddon": {
69+
"enabled": true,
70+
"locker": "browser"
71+
},
72+
"BrowserLocker": {
73+
"browser": "firefox",
74+
"headless": true,
75+
"private_mode": true,
76+
"temp_profile": true
77+
}
78+
}
6379
```
6480

6581
A convenience CLI options will show some information about detected browsers:
@@ -76,13 +92,13 @@ newer than that date will be filtered out before a lock is attempted.
7692
Combined with a fixed `pyodide_url` archive, this should prevent known packages and
7793
their dependencies from "drifting."
7894

79-
```yaml
95+
```json
8096
{
81-
'PyodideAddon':
97+
"PyodideAddon":
8298
{
83-
'pyodide_url': f"https://github.com/pyodide/pyodide/releases/download/0.25.0/pyodide-core-0.25.0.tar.bz2",
99+
"pyodide_url": f"https://github.com/pyodide/pyodide/releases/download/0.25.0/pyodide-core-0.25.0.tar.bz2",
84100
},
85-
'PyodideLockAddon': { 'enabled': true, 'lock_date_epoch': 1712980201 },
101+
"PyodideLockAddon": { "enabled": true, "lock_date_epoch": 1712980201 }
86102
}
87103
```
88104

py/jupyterlite-pyodide-lock/src/jupyterlite_pyodide_lock/lockers/handlers/lock.html.j2

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,43 @@
2828
2929
await pyodide.runPythonAsync(`
3030
try:
31-
import micropip, js, json
31+
import json, js, micropip, traceback
32+
3233
await micropip.install(
3334
**json.loads(
3435
'''
3536
{{ micropip_args_json }}
3637
'''
3738
)
3839
)
39-
js.window.PYODIDE_LOCK = micropip.freeze()
40+
lock = None
41+
if micropip.__version__ == "0.8.0":
42+
# from https://github.com/pyodide/micropip/pull/172
43+
from micropip.freeze import load_pip_packages
44+
45+
PM = micropip._package_manager_singleton
46+
packages = dict(load_pip_packages())
47+
packages.update(
48+
{
49+
name: info
50+
for name, info in PM.repodata_packages.items()
51+
if name not in packages
52+
}
53+
)
54+
lock = json.dumps(
55+
{"info": PM.repodata_info, "packages": packages},
56+
indent=2,
57+
sort_keys=True
58+
)
59+
else:
60+
lock = micropip.freeze()
61+
62+
js.window.PYODIDE_LOCK = lock
4063
except Exception as err:
41-
js.window.PYODIDE_ERROR = str(err)
64+
js.window.PYODIDE_ERROR = f"""
65+
{traceback.format_exc()}
66+
{str(err)}
67+
"""
4268
`);
4369
4470
await post(

0 commit comments

Comments
 (0)