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

Commit 9693f3a

Browse files
authored
Add advanced section to the docs for providing a custom empack_config.yaml (#127)
* Add advanced docs for `empack_config.yaml` * add command * Add linkify extension * wording * add more explanations
1 parent c7e7c48 commit 9693f3a

File tree

3 files changed

+43
-0
lines changed

3 files changed

+43
-0
lines changed

docs/build-environment.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ dependencies:
88
- pip
99
- click
1010
- typer
11+
- linkify-it-py
1112
- myst-parser
1213
- pydata-sphinx-theme
1314
- yarn

docs/conf.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
'myst_parser',
66
]
77

8+
myst_enable_extensions = [
9+
"linkify",
10+
]
11+
812
master_doc = 'index'
913
source_suffix = '.rst'
1014

docs/configuration.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,41 @@ Then those packages are usable directly:
5454
plt.plot(np.sin(np.linspace(0, 20, 100)))
5555
plt.show();
5656
```
57+
58+
## Advanced Configuration
59+
60+
```{warning}
61+
This section is mostly for reference and should not be needed for regular use of the `jupyterlite-xeus-python` kernel.
62+
```
63+
64+
### Provide a custom `empack_config.yaml`
65+
66+
Packages sometimes ship more data than needed for the package to work (tests, documentation, data files etc). This is fine on a regular installation of the package, but in the emscripten case when running in the browser this means that starting the kernel would download more files.
67+
For this reason, `empack` filters out anything that is not required for the Python code to run. It does it by following a set of filtering rules available in this file: https://github.com/emscripten-forge/empack/blob/main/config/empack_config.yaml.
68+
69+
But this default filtering could break some packages. In that case you would probably want to either contribute to the default empack config, or provide your own set of filtering rules.
70+
71+
The xeus-python kernel supports passing a custom `empack_config.yaml`. This file can be used to override the default filter rules set by the underlying `empack` tool used for packing the environment.
72+
73+
If you would like to provide additional rules for including or excluding files in the packed environment, create a `empack_config.yaml` with the following content as an example:
74+
75+
```yaml
76+
packages:
77+
xarray:
78+
include_patterns:
79+
- pattern: '**/*.py'
80+
- pattern: '**/static/css/*.css'
81+
- pattern: '**/static/html/*.html'
82+
```
83+
84+
This example defines a set of custom rules for the `xarray` package to make sure it includes some static files that should be available from the kernel.
85+
86+
You can use this file when building JupyterLite:
87+
88+
```shell
89+
jupyter lite build --XeusPythonEnv.empack_config=empack_config.yaml
90+
```
91+
92+
```{note}
93+
Filtering files helps reduce the size of the assets to download and as a consequence reduce network traffic.
94+
```

0 commit comments

Comments
 (0)