| 1 |
#!/usr/bin/env python3 |
| 2 |
""" perform a development install of jupyterlab_pygments |
| 3 |
|
| 4 |
On Binder, this will run _after_ the environment has been fully created from |
| 5 |
the environment.yml in this directory. |
| 6 |
|
| 7 |
This script should also run locally on Linux/MacOS/Windows: |
| 8 |
|
| 9 |
python3 binder/postBuild |
| 10 |
""" |
| 11 |
import subprocess |
| 12 |
import sys |
| 13 |
from pathlib import Path |
| 14 |
|
| 15 |
|
| 16 |
ROOT = Path.cwd() |
| 17 |
|
| 18 |
def _(*args, **kwargs): |
| 19 |
""" Run a command, echoing the args |
| 20 |
|
| 21 |
fails hard if something goes wrong |
| 22 |
""" |
| 23 |
print("\n\t", " ".join(args), "\n") |
| 24 |
return_code = subprocess.call(args, **kwargs) |
| 25 |
if return_code != 0: |
| 26 |
print("\nERROR", return_code, " ".join(args)) |
| 27 |
sys.exit(return_code) |
| 28 |
|
| 29 |
# verify the environment is self-consistent before even starting |
| 30 |
_(sys.executable, "-m", "pip", "check") |
| 31 |
|
| 32 |
# install the labextension |
| 33 |
_(sys.executable, "-m", "pip", "install", "-e", ".") |
| 34 |
_(sys.executable, "-m", "jupyter", "labextension", "develop", "--overwrite", ".") |
| 35 |
|
| 36 |
# verify the environment the extension didn't break anything |
| 37 |
_(sys.executable, "-m", "pip", "check") |
| 38 |
|
| 39 |
# list the extensions |
| 40 |
_("jupyter", "server", "extension", "list") |
| 41 |
|
| 42 |
# initially list installed extensions to determine if there are any surprises |
| 43 |
_("jupyter", "labextension", "list") |
| 44 |
|
| 45 |
|
| 46 |
print("JupyterLab with jupyterlab_pygments is ready to run with:\n") |
| 47 |
print("\tjupyter lab\n") |