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

Commit 7d1a9e8

Browse files
authored
Merge pull request #62 from martinRenou/update_empack_1
Update to empack 1 with support for loading custom empack config
2 parents c2e4d66 + 7b2ee44 commit 7d1a9e8

File tree

3 files changed

+27
-4
lines changed

3 files changed

+27
-4
lines changed

docs/configuration.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ Then those packages are usable directly:
3232
.. replite::
3333
:kernel: xeus-python
3434
:height: 600px
35+
:prompt: Try it!
3536

3637
%matplotlib inline
3738

jupyterlite_xeus_python/env_build_addon.py

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
"""a JupyterLite addon for creating the env for xeus-python"""
2+
import json
23
import os
4+
from pathlib import Path
5+
import requests
6+
import shutil
37
from subprocess import check_call, run, DEVNULL
48
from tempfile import TemporaryDirectory
5-
import json
6-
import shutil
7-
from pathlib import Path
9+
from urllib.parse import urlparse
10+
11+
import yaml
812

913
from traitlets import List, Unicode
1014

1115
from empack.file_packager import pack_environment
16+
from empack.file_patterns import PkgFileFilter, pkg_file_filter_from_yaml
1217

1318
from jupyterlite.constants import (
1419
SHARE_LABEXTENSIONS,
@@ -74,6 +79,12 @@ class XeusPythonEnv(FederatedExtensionAddon):
7479
config=True, description="The xeus-python version to use"
7580
)
7681

82+
empack_config = Unicode(
83+
"https://raw.githubusercontent.com/emscripten-forge/recipes/main/empack_config.yaml",
84+
config=True,
85+
description="The path or URL to the empack config file",
86+
)
87+
7788
packages = PackagesList([]).tag(
7889
config=True,
7990
description="A comma-separated list of packages to install in the xeus-python env",
@@ -123,11 +134,22 @@ def post_build(self, manager):
123134
# Create emscripten env with the given packages
124135
self.create_env()
125136

137+
# Download env filter config
138+
empack_config_is_url = urlparse(self.empack_config).scheme in ("http", "https")
139+
if empack_config_is_url:
140+
empack_config_content = requests.get(self.empack_config).content
141+
pkg_file_filter = PkgFileFilter.parse_obj(
142+
yaml.safe_load(empack_config_content)
143+
)
144+
else:
145+
pkg_file_filter = pkg_file_filter_from_yaml(self.empack_config)
146+
126147
# Pack the environment
127148
pack_environment(
128149
env_prefix=self.prefix_path,
129150
outname=Path(self.cwd.name) / "python_data",
130151
export_name="globalThis.Module",
152+
pkg_file_filter=pkg_file_filter,
131153
download_emsdk="latest",
132154
)
133155

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
"traitlets",
5858
"jupyterlite",
5959
"requests",
60-
"empack>=0.8.2,<0.9",
60+
"empack>=1.0.0,<2",
6161
],
6262
zip_safe=False,
6363
include_package_data=True,

0 commit comments

Comments
 (0)