-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNuSol_version_checker_edited.py
64 lines (56 loc) · 2.54 KB
/
NuSol_version_checker_edited.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
import numpy as numpy
import scipy as scipy
import platform,sys
class NuSol_version():
def __init__(self):
self.python_target_version = (2,7)
self.python_version = ()
self.python_bool = []
self.check_python_interpreter()
self.numpy_target_version = (1,16)
self.numpy_version = ()
self.numpy_bool = []
self.check_numpy()
self.scipy_target_version = (1,2)
self.scipy_version = ()
self.scipy_bool = []
self.check_scipy()
def version_check(self):
if self.python_bool and self.scipy_bool and self.numpy_bool:
return True
else:
print ('Your Python/Numpy/Scipy versions do not meet the following requirements:')
print ('\tRequired: Python %d.%d.x\n\tYour version: %s\n' % (self.python_target_version[0],self.python_target_version[1],platform.python_version()))
print ('\tRequired: Numpy %d.%d.x\n\tYour version: %s\n' % (self.numpy_target_version[0],self.numpy_target_version[1],numpy.version.version))
print ('\tRequired: Scipy %d.%d.x\n\tYour version: %s\n' % (self.scipy_target_version[0],self.scipy_target_version[1],scipy.version.version))
if not hasattr(sys, 'real_prefix'):
print ('\nIt seems like you are not running in a virtual environment.')
print ('You can setup a python virtual environment which includes\nthe required numpy/scipy versions via the install.sh script\nin the main NuSol folder')
c = raw_input('\nTry to continue anyway (will most likely not work):[y/n]')
if c[0] == 'y':
print ('Attempting to run NuSol without the required dependencies.')
return True
else:
print ('Please install the missing dependencies.')
return False
def check_python_interpreter(self):
self.python_version = (int(platform.python_version().split('.')[0]),int(platform.python_version().split('.')[1]))
if self.python_version == self.python_target_version:
self.python_bool = True
else:
self.python_bool = False
def check_numpy(self):
self.numpy_version = (int(numpy.version.version.split('.')[0]),int(numpy.version.version.split('.')[1]))
if self.numpy_version == self.numpy_target_version:
self.numpy_bool = True
else:
self.numpy_bool = False
def check_scipy(self):
self.scipy_version = (int(scipy.version.version.split('.')[0]), int(scipy.version.version.split('.')[1]))
if self.scipy_version == self.scipy_target_version:
self.scipy_bool = True
else:
self.scipy_bool = False
if __name__ == "__main__":
NuV = NuSol_version()
res = NuV.version_check()