-
Notifications
You must be signed in to change notification settings - Fork 11
/
setup.py
152 lines (112 loc) · 4.12 KB
/
setup.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
from __future__ import print_function, unicode_literals
from pyfiglet import Figlet
import subprocess
import argparse
import os
import regex
#import PyInquirer
from PyInquirer import style_from_dict, Token, prompt, Validator, ValidationError
from pprint import pprint
style = style_from_dict({
Token.QuestionMark: '#E91E63 bold',
Token.Selected: '#673AB7 bold',
Token.Instruction: '', # default
Token.Answer: '#2196f3 bold',
Token.Question: '',
})
class directoryValidator(Validator):
def validate(self, document):
if not document.text=='':
if not os.path.isdir("/home/el"):
raise ValidationError(
message='Please enter valid directory for galapagos path',
cursor_position=len(document.text)
)
f = Figlet(font='slant')
print(f.renderText('Welcome to Galapagos Setup'))
parser = argparse.ArgumentParser(description='Galapagos Menu')
parser.add_argument("-d", "--dir", help="absolute path where galapagos directory is located", default='')
parser.add_argument("-vd", "--viv_dir", help="absolute path of vivado", default='')
parser.add_argument("-hd", "--hls_dir", help="absolute path of vivado_hls", default='')
parser.add_argument("-vv", "--viv_ver", help="version of vivado", default='')
parser.add_argument("-hv", "--hls_ver", help="version of vivado_hls", default='')
args = parser.parse_args()
questions = []
path_q = {
'type': 'input',
'name': 'galapagos_dir',
'message': 'What is the absolute path where the galapagos directory is located? (default=$PWD)',
'validate': directoryValidator
}
viv_path_q = {
'type': 'input',
'name': 'vivado_dir',
'message': 'What is the directory vivado is located? (default=/opt/Xilinx/Vivado)',
'validate': directoryValidator
}
hls_path_q = {
'type': 'input',
'name': 'hls_dir',
'message': 'What is the directory vivado_hls is located? (default=/opt/Xilinx/Vivado)',
'validate': directoryValidator
}
viv_ver_q = {
'type': 'list',
'name': 'vivado_ver',
'message': 'What is the vivado version you want to use?',
'choices': ['2018.1', '2018.2', '2018.3', '2019.1'],
'filter': lambda val: val.lower()
}
hls_ver_q = {
'type': 'list',
'name': 'hls_ver',
'message': 'What is the vivado_hls version you want to use?',
'choices': ['2018.1', '2018.2', '2018.3', '2019.1'],
'filter': lambda val: val.lower()
}
if(args.dir ==''):
questions.append(path_q)
galapagos_dir = ''
else:
galapagos_dir = args.dir
if(args.viv_dir == ''):
questions.append(viv_path_q)
vivado_dir = ''
else:
vivado_dir = args.viv_dir
if(args.hls_dir == ''):
questions.append(hls_path_q)
hls_dir = ''
else:
hls_dir = args.hls_dir
if(args.viv_ver == ''):
questions.append(viv_ver_q)
vivado_ver = ''
else:
vivado_ver = args.viv_ver
if(args.viv_ver == ''):
questions.append(hls_ver_q)
hls_ver = ''
else:
hls_ver = args.hls_ver
answers = prompt(questions, style=style)
if answers['galapagos_dir'] == '':
answers['galapagos_dir']=os.getcwd()
if answers['vivado_dir'] == '':
answers['vivado_dir'] = '/opt/Xilinx/Vivado'
if answers['hls_dir'] == '':
answers['hls_dir'] = '/opt/Xilinx/Vivado'
if answers['vivado_ver'] == '':
answers['vivado_ver'] = '2018.1'
if answers['hls_ver'] == '':
answers['hls_ver'] = '2018.1'
print('ENVIRONMENT VARIABLES SET:')
env_var = {'GALAPAGOS_PATH': answers['galapagos_dir'],
'GALAPAGOS_VIVADO_PATH' : answers['vivado_dir'],
'GALAPAGOS_HLS_PATH' : answers['hls_dir'],
'GALAPAGOS_VIVADO_VERSION' : answers['vivado_ver'],
'GALAPAGOS_HLS_VERSION' : answers['hls_ver']
}
pprint(env_var)
out_file = open("my_init.sh", "w")
out_file.write("source init.sh " + answers['galapagos_dir'] + ' ' + answers['vivado_dir'] + ' ' + answers['hls_dir'] + ' ' + answers['vivado_ver'] + ' ' + answers['hls_ver'])