-
Notifications
You must be signed in to change notification settings - Fork 13
/
check_env.py
executable file
·133 lines (117 loc) · 3.24 KB
/
check_env.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
#!/usr/bin/env python3
import sys
import subprocess
import re
import os
from distutils.version import LooseVersion, StrictVersion
if sys.version_info < (3, 0):
print("Error: Python 2 is not supported")
sys.exit(1)
print("Python:", sys.version_info)
try:
import numpy
except ImportError:
print("Error: Failed to import required modules: numpy")
sys.exit(1)
# Function to test for tool installation and version
# ==============================================================================
def checkTool(toolName, cmd, pattern, requiredVersion):
status= toolName +": required " + requiredVersion + " (or greater), detected "
output=""
error=1
ret=1
try:
# Note that some tools print out the version information to stderr (e.g spectre)
process = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
output, error = process.communicate()
except:
pass
if (not error):
m = re.search(pattern, output.decode('utf-8'))
# print(output.decode('utf-8'))
if m:
version = m.group(1)
else:
version = "unknown"
if version == "unknown":
status += version + " - FAIL"
elif LooseVersion(version) >= LooseVersion(requiredVersion):
status += version + " - PASS"
ret = 0
else:
status += version + " - FAIL"
else:
status += "no install - FAIL"
print(status)
return ret
# Main
# ==============================================================================
toolList =[
{
"toolName":"PERL",
"cmd":"perl -v",
"pattern": ".*(v\S+)",
"requiredVersion": "v5.10.1"
},
{
"toolName":"Synopsys Design Compiler",
"cmd":"dc_shell -v",
"pattern": "dc_shell\sversion\s+-\s+(\S+)",
"requiredVersion": "O-2018.06"
},
{
"toolName":"Synopsys Library Compiler",
"cmd":"lc_shell -v",
"pattern": "lc_shell\sversion\s+-\s+(\S+)",
"requiredVersion": "O-2018.06"
},
{
"toolName":"Cadence Innovus",
"cmd":"innovus -version | reset",
"pattern": "CDS: Innovus (v\S+)",
"requiredVersion": "v18.10-p002_1"
},
{
"toolName":"Synopsys Primetime",
"cmd":"primetime -version",
"pattern": "pt_shell\sversion\s+-\s+(\S+)",
"requiredVersion": "O-2018.06-1"
},
{
"toolName":"Mentor Graphics Calibre",
"cmd":"calibre -version",
"pattern": "Calibre (v\S+)",
"requiredVersion": "v2019.3_25.15"
},
{
"toolName":"Synopsys HSPICE",
"cmd":"hspice -v",
"pattern": "HSPICE Version (\S+)",
"requiredVersion": "N-2017.12-SP2-1"
},
{
"toolName":"Cadence Spectre",
"cmd":"spectre -version",
"pattern": "spectre\s+version\s+(\S+)",
"requiredVersion": "15.1.0"
}
# {
# "toolName":"Cadence Liberate",
# "cmd":"liberate -v",
# "pattern": "LIBERATE version (\S+)",
# "requiredVersion": "16.1.1.132"
# }
]
status = 0
for tool in toolList:
status += checkTool(tool["toolName"],
tool["cmd"],
tool["pattern"],
tool["requiredVersion"])
# Innovus will often leave the terminal in a bad state. Cleaning up the
# terminal
os.system("stty sane")
if status:
print("\n\nTotal issues detected: " + str(status) + "\n")
else:
print("\n\nEnvironment is successfully setup to run the FASoC flow\n")