-
Notifications
You must be signed in to change notification settings - Fork 112
/
Copy pathmake.py
38 lines (29 loc) · 852 Bytes
/
make.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
import os
import os.path
import subprocess
import sys
project_name = os.path.basename(os.path.dirname(os.path.abspath(__file__)))
gopath = os.getenv('GOPATH')
if gopath:
gopath = gopath.split(os.pathsep)[0]
else:
gopath = os.path.expanduser('~/go')
def call(command):
print(command)
r = subprocess.call(command, shell=True)
if r != 0:
sys.exit(r)
def link():
src = os.getcwd()
dst = os.path.normpath(os.path.join(gopath, 'src', 'github.com', 'mohanson', project_name))
if os.path.exists(dst):
return
os.makedirs(os.path.dirname(dst), exist_ok=True)
if os.name == 'nt':
call(f'mklink /J {dst} {src}')
else:
call(f'ln -s -f {src} {dst}')
def main():
call(f'go install -i github.com/mohanson/{project_name}/cmd/{project_name}')
if __name__ == '__main__':
main()