Skip to content

Commit 90637d3

Browse files
authored
Update README.md
1 parent 11585d1 commit 90637d3

File tree

1 file changed

+85
-0
lines changed

1 file changed

+85
-0
lines changed

README.md

+85
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,88 @@ Test that it can visualize a map:
1212
python test_healpyvis.py
1313

1414
Check it creates `map.png` file.
15+
16+
# Building PyHealpy with JupyterLite's Pyodide
17+
18+
by @VeerioSDSC
19+
20+
Steps include building the wheel to serve, setting up JupyterLite, and commands for the Lite cells.
21+
22+
### Building the PyHealpy Wheel to Serve
23+
24+
First need to set up the pyodide compiler with the following
25+
26+
```
27+
pip install pyodide-build
28+
git clone https://github.com/emscripten-core/emsdk.git
29+
cd emsdk
30+
PYODIDE_EMSCRIPTEN_VERSION=$(pyodide config get emscripten_version)
31+
./emsdk install ${PYODIDE_EMSCRIPTEN_VERSION}
32+
./emsdk activate ${PYODIDE_EMSCRIPTEN_VERSION}
33+
source emsdk_env.sh
34+
cd ..
35+
```
36+
37+
Then building the wheel:
38+
39+
```
40+
git clone https://github.com/healpy/pyhealpy.git
41+
cd pyhealpy
42+
pyodide build
43+
```
44+
It builds the wheel in a dist folder
45+
46+
Serving the wheel locally:
47+
48+
`python3 -m http.server --directory dist`
49+
50+
### Using it with JupyterLite
51+
52+
If one just wants to use another environment they can use the demo one found here: https://jupyterlite.github.io/demo/lab/index.html
53+
54+
If one wants to deploy Lite with GitHub Pages:
55+
56+
Template to use: https://github.com/jupyterlite/demo
57+
Since the initial commit will fail, go to settings→actions→general and allow read/write perms for workflows, and go to settings→pages and make sure GitHub Actions is selected as the source for Deployment. Make a commmit and then it will deploy.
58+
59+
If one wants to deploy Lite locally:
60+
61+
```
62+
python -m pip install jupyterlite-core
63+
jupyter lite init
64+
python3 -m pip install jupyterlite-pyodide-kernel
65+
cd _output
66+
jupyter lite build
67+
jupyter lite serve
68+
```
69+
### Commands to Run in JupyterLite - web address for installation is based on where the wheel is served.
70+
71+
If locally, you might face [CORS Issue. ](https://chromewebstore.google.com/detail/moesif-origincors-changer/digfbfaphojjndkpccljibejjbppifbc?hl=en-US)
72+
73+
Commands for the cells:
74+
75+
```
76+
import micropip
77+
await micropip.install ("http://localhost:8000/healpy-0.1.dev1885+g71d9336-py3-none-any.whl")
78+
await micropip.install("matplotlib")
79+
import healpy
80+
```
81+
82+
Then it can be tested with the [contents of file from above](https://github.com/healpy/pyhealpy/blob/pyhealpy/test_healpyvis.py):
83+
84+
```
85+
86+
import healpy as hp
87+
import matplotlib.pyplot as plt
88+
89+
m = hp.read_map(
90+
"wmap_band_iqumap_r9_7yr_W_v4_udgraded32_masked_smoothed10deg_fortran.fits"
91+
);
92+
#link will change based on where file is
93+
94+
hp.projview(m, coord=["G"], projection_type="mollweide");
95+
96+
plt.savefig("map.png")
97+
```
98+
99+

0 commit comments

Comments
 (0)