-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUKFTractography.py
executable file
·63 lines (42 loc) · 1.65 KB
/
UKFTractography.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
57
58
59
60
61
62
63
from pnlpipe_software import downloadGithubRepo, getCommitInfo, getSoftDir, checkExists, envFromDict
import psutil
from plumbum import local, FG
from plumbum.cmd import cmake
import logging
from os import getenv
DEFAULT_HASH = 'fcf83e2'
def make(commit=DEFAULT_HASH):
softdir = getSoftDir()
if commit != 'master':
if checkExists(get_path(commit)):
return
blddir = softdir / "UKFTractography-build"
with local.cwd(softdir):
repo = downloadGithubRepo('pnlbwh/ukftractography', commit)
sha, date = getCommitInfo(repo)
outbinary = get_path(sha)
if checkExists(outbinary):
return
logging.info("Build code:")
blddir.mkdir()
with local.cwd(blddir):
cmake(repo)
import plumbum.cmd
plumbum.cmd.make['-j', getenv('PNLPIPE_BUILD_NCPU','4')] & FG
binary1 = blddir / 'ukf/bin/UKFTractography'
binary2 = blddir / 'UKFTractography-build/UKFTractography/bin/UKFTractography' # later commits
binary = binary1 if binary1.exists() else binary2
outbinary.dirname.mkdir()
binary.move(outbinary)
with open(outbinary.dirname / 'env.sh', 'w') as f:
f.write("export PATH={}:$PATH".format(outbinary.dirname))
symlink = get_path(date).dirname
print("Make symlink: {} -> {}".format(symlink, get_path(sha).dirname))
symlink.unlink()
get_path(sha).dirname.symlink(symlink)
logging.info("Made '{}'".format(outbinary))
logging.info("Made '{}'".format(get_path(date)))
def get_path(hash=DEFAULT_HASH):
return getSoftDir() / ('UKFTractography-' + hash) / 'UKFTractography'
def env_dict(hash):
return { 'PATH': get_path(hash).dirname }