-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
/
Copy pathinstall.py
56 lines (46 loc) · 1.61 KB
/
install.py
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
import os
import sys
pip_e_URL = "https://pip.pypa.io/en/stable/topics/local-project-installs" +\
"/#editable-installs"
repo = "[email protected]:nk53/stanalyzer.git"
def _run_or_die(cmd):
if result := os.system(cmd):
print(cmd[:10], '... failed with status', result, file=sys.stderr)
print("Exiting...", file=sys.stderr)
sys.exit(result)
def finish_install():
saveas = 'stanalyzer'
prog, args = os.path.basename(sys.argv.pop(0)), sys.argv
match args:
case []:
print("This will clone the git repository and install it as an 'editable' package.")
print("Read here for more info:")
print(" ", pip_e_URL)
print()
try:
saveas = input(f"Desired repository save path (default: {saveas}): ") or saveas
except KeyboardInterrupt:
print()
sys.exit(1)
case '-q':
pass
case '-h' | '--help':
print(f"Usage: {prog} [-h] [-q | -p SAVE_PATH]", file=sys.stderr)
sys.exit(0)
case ['-p', saveas]:
pass
case _:
print(f"Usage: {prog} [-h] [-q | -p SAVE_PATH]", file=sys.stderr)
sys.exit(1)
cmds = [
f"git clone {repo} {saveas}",
f"pip install --no-deps --ignore-installed --editable {saveas}",
]
for cmd in cmds:
print("Running:", cmd)
_run_or_die(cmd)
print("Removing temporary stanalyzer dir from site-packages")
import stanalyzer
sta_dir = stanalyzer.__path__[0]
_run_or_die(f"rm -rv {sta_dir}")
print("Done")