-
Notifications
You must be signed in to change notification settings - Fork 0
/
tract_querier.py
executable file
·50 lines (38 loc) · 1.38 KB
/
tract_querier.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
from pnlpipe_software import downloadGithubRepo, getCommitInfo, getSoftDir, checkExists, TemporaryDirectory, envFromDict
from plumbum import local
import logging
log = logging.getLogger(__name__)
DEFAULT_HASH = 'd4a88aa'
NAME = 'tract_querier'
REPO = 'demianw/tract_querier'
def make(commit=DEFAULT_HASH):
"""Downloads a lean version of tract_querier. Output is '$soft/tract_querier-<commit>'."""
if commit != 'master':
out = get_path(commit)
if checkExists(out):
return
with local.tempdir() as tmpdir, local.cwd(tmpdir):
repo = downloadGithubRepo(REPO, commit)
sha, date = getCommitInfo(repo)
out = get_path(sha)
if checkExists(out):
return
# save space
(repo / 'doc').delete()
(repo / '.git').delete()
log.info("Make '{out}'".format(**locals()))
repo.move(out)
with open(out / 'env.sh', 'w') as f:
f.write("export PATH={}:$PATH\n".format(out / 'scripts'))
f.write("export PYTHONPATH={}:$PYTHONPATH\n".format(out))
date_symlink = get_path(date)
date_symlink.unlink()
out.symlink(date_symlink)
def get_path(hash=DEFAULT_HASH):
return getSoftDir() / '{}-{}'.format(NAME, hash)
def env_dict(hash):
return {'PATH': get_path(hash) / 'scripts'
,'PYTHONPATH': get_path(hash)
}
def env(hash):
return envFromDict(env_dict(hash))