Skip to content
This repository was archived by the owner on Feb 14, 2024. It is now read-only.

Commit da52ac0

Browse files
use empack 3.0 (#134)
* use empack 3.0 * use empack 3.0 everywhere * revert yarn lock * revert yarn lock * revert yarn lock * revert yarn lock * no change * yarn * no yarn lock * recreated yarn with 3.x * yarn 1.x * Use yarn 3 + missing NPM dependencies * Fix nodejs version in check-release * Fix packages versions + proper yarn 3 config * Fix jupyterlab version in the build env * Fix jupyterlab builder version * Fix lab version * use tar.gz instead of .data * fix tests * fix setup.py * try dev * ... * Fix Lumino version * Fix test workflow * import proper emapck * proper syntax * only tar.gz * added missing , --------- Co-authored-by: martinRenou <martin.renou@gmail.com>
1 parent 63c96ab commit da52ac0

File tree

14 files changed

+1535
-431
lines changed

14 files changed

+1535
-431
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ jobs:
3030
jlpm run build
3131
jlpm run eslint:check
3232
python -m pip install -v .
33-
3433
jupyter labextension list 2>&1 | grep -ie "@jupyterlite/xeus-python-kernel.*OK"
3534
3635
- name: Build the extension
@@ -68,7 +67,7 @@ jobs:
6867
sudo rm -rf $(which node)
6968
sudo rm -rf $(which node)
7069
pip install jupyterlite-xeus-python.tar.gz
71-
pip install jupyterlab
70+
pip install "jupyterlab==3"
7271
jupyter labextension list 2>&1 | grep -ie "@jupyterlite/xeus-python-kernel.*OK"
7372
7473
# TODO: add JupyterLite browser check

.github/workflows/check-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
- name: Install node
2525
uses: actions/setup-node@v2
2626
with:
27-
node-version: '14.x'
27+
node-version: '16.x'
2828
- name: Get pip cache dir
2929
id: pip-cache
3030
run: |

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ node_modules/
44
*.egg-info/
55
.ipynb_checkpoints
66
*.tsbuildinfo
7-
7+
*.tar.gz
8+
empack_env_meta.json
89
# Created by https://www.gitignore.io/api/python
910
# Edit at https://www.gitignore.io/?templates=python
1011

.yarnrc.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
nodeLinker: node-modules

docs/build-environment.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ dependencies:
1414
- yarn
1515
- jupyterlab >=3.5.3,<3.6
1616
- jupyterlite-core >=0.1.0,<0.2.0
17-
- empack >=2.0.9,<3
17+
- empack >=3,<4
1818
- pip:
1919
- jupyterlite-sphinx
2020
- ..

environment.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ channels:
44
dependencies:
55
- python
66
- pip
7-
- jupyterlab
7+
- jupyterlab >=3.6,<4
88
- traitlets
99
- requests
1010
- typer
1111
- pytest
12-
- emsdk >=3.1.11
13-
- empack >=2.0.9,<3
12+
- empack >=3,<4
13+
- yarn =3
1414
- pip:
1515
- jupyterlite

jupyterlite_xeus_python/build.py

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
import yaml
1111

12-
from empack.file_packager import split_pack_environment
12+
from empack.pack import pack_env, DEFAULT_CONFIG_PATH
1313
from empack.file_patterns import PkgFileFilter, pkg_file_filter_from_yaml
1414

1515
import typer
@@ -27,7 +27,7 @@
2727

2828
PYTHON_VERSION = "3.10"
2929

30-
XEUS_PYTHON_VERSION = "0.15.7"
30+
XEUS_PYTHON_VERSION = "0.15.9"
3131

3232
CHANNELS = [
3333
"https://repo.mamba.pm/emscripten-forge",
@@ -199,21 +199,22 @@ def build_and_pack_emscripten_env(
199199
empack_config_is_url = urlparse(empack_config).scheme in ("http", "https")
200200
if empack_config_is_url:
201201
empack_config_content = requests.get(empack_config).content
202-
pack_kwargs["pkg_file_filter"] = PkgFileFilter.parse_obj(
202+
pack_kwargs["file_filters"] = PkgFileFilter.parse_obj(
203203
yaml.safe_load(empack_config_content)
204204
)
205205
else:
206-
pack_kwargs["pkg_file_filter"] = pkg_file_filter_from_yaml(
206+
pack_kwargs["file_filters"] = pkg_file_filter_from_yaml(
207207
empack_config
208208
)
209+
else:
210+
pack_kwargs["file_filters"] = pkg_file_filter_from_yaml(DEFAULT_CONFIG_PATH)
209211

210212
# Pack the environment
211-
split_pack_environment(
213+
pack_env(
212214
env_prefix=prefix_path,
213-
outname="python_data",
214-
pack_outdir=output_path,
215-
export_name="globalThis.Module",
216-
with_export_default_statement=False,
215+
relocate_prefix="/",
216+
outdir=output_path,
217+
use_cache=False,
217218
**pack_kwargs,
218219
)
219220

@@ -235,10 +236,12 @@ def build_and_pack_emscripten_env(
235236
worker = worker.replace("XEUS_KERNEL_FILE", "'xpython_wasm.js'")
236237
worker = worker.replace("LANGUAGE_DATA_FILE", "'python_data.js'")
237238
worker = worker.replace("importScripts(DATA_FILE);", """
238-
importScripts(DATA_FILE);
239-
await globalThis.Module.importPackages();
240-
await globalThis.Module.init();
241-
""" )
239+
await globalThis.Module.bootstrap_from_empack_packed_environment(
240+
`./empack_env_meta.json`, /* packages_json_url */
241+
".", /* package_tarballs_root_url */
242+
false /* verbose */
243+
);
244+
""")
242245
with open(Path(output_path) / "worker.ts", "w") as fobj:
243246
fobj.write(worker)
244247

jupyterlite_xeus_python/env_build_addon.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
from traitlets import List, Unicode
1414

15-
from empack.file_packager import pack_environment
15+
from empack.pack import pack_env, DEFAULT_CONFIG_PATH
1616
from empack.file_patterns import PkgFileFilter, pkg_file_filter_from_yaml
1717

1818
from jupyterlite_core.constants import (
@@ -94,26 +94,20 @@ def post_build(self, manager):
9494
# (make jupyterlite-xeus-python extension somewhat configurable?)
9595
dest = self.output_extensions / "@jupyterlite" / "xeus-python-kernel" / "static"
9696

97-
# copy *.data/*.js for all side packages
97+
# copy *.tar.gz for all side packages
9898
for item in Path(self.cwd.name) .iterdir():
99-
if item.suffix == ".data":
99+
if item.suffix == ".gz":
100100

101101
file = item.name
102102
yield dict(
103103
name=f"xeus:copy:{file}",
104104
actions=[(self.copy_one, [item, dest / file])],
105105
)
106106

107-
js_item = Path(self.cwd.name) / (str(item.stem) + '.js')
108-
js_file = js_item.name
109-
yield dict(
110-
name=f"xeus:copy:{js_file}",
111-
actions=[(self.copy_one, [js_item, dest / js_file])],
112-
)
113107

114108

115109
for file in [
116-
"python_data.js",
110+
"empack_env_meta.json",
117111
"xpython_wasm.js",
118112
"xpython_wasm.wasm",
119113
]:

package.json

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"url": "https://github.com/jupyterlite/xeus-python-kernel.git"
2727
},
2828
"scripts": {
29-
"copy-files": "copyfiles -u 1 src/xpython_wasm.wasm src/xpython_wasm.js src/python_data.js src/*.data src/*.js lib",
29+
"copy-files": "copyfiles -u 1 src/xpython_wasm.wasm src/xpython_wasm.js src/python_data.js src/*.tar.gz src/*.js src/*.json lib",
3030
"build:worker": "webpack --config worker.webpack.config.js --mode=development",
3131
"build": "jlpm run build:xeus-python && jlpm run build:lib && jlpm run build:worker && jlpm run copy-files && jlpm run build:labextension:dev",
3232
"build:xeus-python": "python jupyterlite_xeus_python/build.py --output-path src --build-worker",
@@ -51,12 +51,17 @@
5151
"watch:labextension": "jupyter labextension watch ."
5252
},
5353
"dependencies": {
54+
"@jupyterlab/coreutils": "^5",
55+
"@jupyterlab/services": "^6",
5456
"@jupyterlite/contents": "^0.1.0",
57+
"@jupyterlite/kernel": "^0.1.0",
5558
"@jupyterlite/server": "^0.1.0",
59+
"@lumino/coreutils": "^1",
60+
"@lumino/signaling": "^1",
5661
"comlink": "^4.3.1"
5762
},
5863
"devDependencies": {
59-
"@jupyterlab/builder": "^3.4.1",
64+
"@jupyterlab/builder": "^3.6.4",
6065
"@typescript-eslint/eslint-plugin": "^4.8.1",
6166
"@typescript-eslint/parser": "^4.8.1",
6267
"copy-webpack-plugin": "^9.0.1",
@@ -68,9 +73,12 @@
6873
"npm-run-all": "^4.1.5",
6974
"prettier": "^2.1.1",
7075
"rimraf": "^3.0.2",
76+
"shx": "^0.3.0",
7177
"source-map-loader": "^4.0.0",
7278
"typescript": "~4.2.3",
73-
"shx": "^0.3.0"
79+
"webpack": "^5.87.0",
80+
"webpack-cli": "^5.1.4",
81+
"webpack-dev-server": "^4.15.1"
7482
},
7583
"sideEffects": [
7684
"style/*.css",

pyproject.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[build-system]
2-
requires = ["jupyter_packaging~=0.10,<2", "jupyterlab~=3.1", "empack>=2.0.9,<3"]
2+
requires = ["jupyter_packaging~=0.10,<2", "jupyterlab~=3.1", "empack>=3,<4"]
33
build-backend = "jupyter_packaging.build_api"
44

55
[tool.jupyter-packaging.options]
@@ -14,14 +14,14 @@ build_cmd = "build:prod"
1414
npm = ["jlpm"]
1515

1616
[tool.check-manifest]
17-
ignore = ["share/jupyter/labextensions/@jupyterlite/xeus-python-kernel/**", "yarn.lock", ".*", "package-lock.json", "src/xpython_wasm.js", "src/xpython_wasm.wasm", "src/*.data", "src/*.js", "src/worker.ts", "src/web_worker_kernel.ts", "*.sh"]
17+
ignore = ["share/jupyter/labextensions/@jupyterlite/xeus-python-kernel/**", "yarn.lock", ".*", "package-lock.json", "src/xpython_wasm.js", "src/xpython_wasm.wasm", "src/*.tar.gz", "src/*.js", "src/worker.ts", "src/web_worker_kernel.ts", "*.sh"]
1818

1919
[tool.jupyter-releaser.options]
2020
skip = ["check-links"]
2121

2222
[tool.jupyter-releaser.hooks]
2323
before-build-npm = [
24-
"python -m pip install jupyterlab~=3.1 empack~=2.0 jupyter_packaging~=0.10",
24+
"python -m pip install jupyterlab~=3.1 empack~=3.0 jupyter_packaging~=0.10",
2525
"jlpm",
2626
"jlpm build:prod",
2727
]

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
# Representative files that should exist after a successful build
2020
ensured_targets = [
2121
str(lab_path / "package.json"),
22-
str(lab_path / "static" / "python_data.js"),
22+
str(lab_path / "static" / "empack_env_meta.json"),
2323
str(lab_path / "static" / "xpython_wasm.js"),
2424
str(lab_path / "static" / "xpython_wasm.wasm"),
2525
str(lab_path / "static" / "style.js"),
@@ -61,7 +61,7 @@
6161
"traitlets",
6262
"jupyterlite-core>=0.1.0",
6363
"requests",
64-
"empack>=2.0.9,<3",
64+
"empack>=3,<4",
6565
"typer",
6666
],
6767
zip_safe=False,

tests/test_xeus_python_env.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ def test_python_env():
2727
assert os.path.isfile("/tmp/xeus-python-kernel/envs/xeus-python-kernel/bin/xpython_wasm.wasm")
2828

2929
# Check empack output
30-
assert os.path.isfile(Path(addon.cwd.name) / "python_data.js")
30+
assert os.path.isfile(Path(addon.cwd.name) / "empack_env_meta.json")
3131

32-
os.remove(Path(addon.cwd.name) / "python_data.js")
32+
os.remove(Path(addon.cwd.name) / "empack_env_meta.json")
3333

3434

3535
def test_python_env_from_file_1():
@@ -50,6 +50,6 @@ def test_python_env_from_file_1():
5050
assert os.path.isfile("/tmp/xeus-python-kernel/envs/xeus-python-kernel-1/bin/xpython_wasm.wasm")
5151

5252
# Check empack output
53-
assert os.path.isfile(Path(addon.cwd.name) / "python_data.js")
53+
assert os.path.isfile(Path(addon.cwd.name) / "empack_env_meta.json")
5454

55-
os.remove(Path(addon.cwd.name) / "python_data.js")
55+
os.remove(Path(addon.cwd.name) / "empack_env_meta.json")

webpack.config.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@ module.exports = {
1313
to: '.'
1414
},
1515
{
16-
from: 'src/python_data.js',
17-
to: '.'
18-
},
19-
{
20-
from: 'src/*.data',
21-
to: './[name].data'
16+
from: 'src/*.gz',
17+
to: './[name].gz'
2218
},
2319
{
2420
from: 'src/*.js',
2521
to: './[name].js'
2622
},
23+
{
24+
from: 'src/empack_env_meta.json',
25+
to: '.'
26+
}
2727
]
2828
})
2929
]

0 commit comments

Comments
 (0)