postBuild 1.3 KB

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