-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdev_setup
executable file
·57 lines (46 loc) · 1.48 KB
/
dev_setup
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
#!/usr/bin/env python3
import os
import json
import subprocess
import logging
import argparse
import platform
logging.basicConfig(level=logging.INFO, format="%(message)s")
parser = argparse.ArgumentParser(description="Setup tmol development environment.")
parser.add_argument(
"-n", "--name", type=str, default="tmol", help="Name of target conda environment."
)
parser.add_argument(
"--dry-run",
default=False,
action="store_true",
help="Only display what setup commands would have been executed.",
)
args = parser.parse_args()
def check_call(command):
logging.info(command)
if args.dry_run:
return
return subprocess.check_call(command, shell=True)
def call(command):
logging.info(command)
if args.dry_run:
return
return subprocess.call(command, shell=True)
# Requires an active root conda installation see:
# https://conda.io/miniconda.html
check_call(
f"conda create -n {args.name} && conda env update -n {args.name} --file=environments/linux-cuda/env.yml"
)
# Conda 4.4+ compatible activation
conda_envs = json.loads(
subprocess.check_output("conda env list --json", shell=True).decode()
)
envpath = [p for p in conda_envs["envs"] if os.path.basename(p) == args.name]
if len(envpath) >= 1:
envpath = envpath[0]
else:
raise ValueError("Target env not present.")
check_call("%s/bin/pip install -e .[dev]" % envpath)
call("ln -sf ../../.post-checkout .git/hooks/post-checkout")
check_call("%s/bin/pre-commit install " % envpath)