|
| 1 | +#!/usr/bin/env python3 |
| 2 | +""" perform a development install of visualpython |
| 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 | + |
| 35 | +# verify the environment the extension didn't break anything |
| 36 | +_(sys.executable, "-m", "pip", "check") |
| 37 | + |
| 38 | +# list the extensions |
| 39 | +_("jupyter", "server", "extension", "list") |
| 40 | + |
| 41 | +# initially list installed extensions to determine if there are any surprises |
| 42 | +_("jupyter", "labextension", "list") |
| 43 | + |
| 44 | + |
| 45 | +print("JupyterLab with visualpython is ready to run with:\n") |
| 46 | +print("\tjupyter lab\n") |
0 commit comments