forked from jupyrdf/ipyelk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpostBuild
executable file
·60 lines (43 loc) · 1.48 KB
/
postBuild
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env python3
""" a windows-friendly, binder-compatible script to get a development environment
"""
# Copyright (c) 2021 Dane Freeman.
# Distributed under the terms of the Modified BSD License.
import shutil
import subprocess
import sys
from pathlib import Path
from jupyterlab_server.process import which
NPM = which("npm") or which("npm.cmd") or which("npm.bat")
JLPM = which("jlpm")
HERE = Path.cwd()
DIST = HERE / "dist"
DIST.exists() and shutil.rmtree(DIST)
def _(*args, **kwargs):
_check = kwargs.pop("_check", True)
if "cwd" in kwargs:
kwargs["cwd"] = str(kwargs["cwd"])
str_args = [str(a) for a in args]
print(f"\n>>>\t{' '.join(str_args)}\n")
if _check:
return subprocess.check_call(str_args, **kwargs)
else:
return subprocess.call(str_args, **kwargs)
# preflight existing extensions
_("jupyter", "labextension", "list")
# avoid weird caching issues
_(JLPM, "cache", "clean")
# perform all the node stuff
_(JLPM, "bootstrap")
# install local python dev
_(sys.executable, "-m", "pip", "install", "-e", ".", "--no-deps")
# list the extensions
_("jupyter", "labextension", "list")
# disable bundled extensions
_("jupyter", "labextension", "disable", "jupyter-offlinenotebook", _check=False)
_("jupyter", "labextension", "uninstall", "jupyter-offlinenotebook", _check=False)
# install our extension
_("jupyter", "labextension", "develop", "--overwrite", ".")
# list the extensions again
_("jupyter", "labextension", "list")
print(">>> OK")