testRequirements.py
33 lines
| 1.1 KiB
| text/x-python
|
PythonLexer
r0 | """testRequirements.py is a python script that tests that all modules listed in required_modules.txt are installed. | ||
If so, succeeds. If not, prints error and returns -1 return code | |||
$Id: testRequirements.py 6167 2017-08-29 17:50:19Z brideout $ | |||
""" | |||
import sys, distutils.version | |||
python_version = sys.version_info.major | |||
if python_version < 3: | |||
print('python 3 (or greater) required') | |||
sys.exit(-1) | |||
f = open('required_modules.txt') | |||
for line in f.readlines(): | |||
if line[0] == '#': | |||
continue | |||
try: | |||
exec('import %s' % (line.strip())) | |||
result = True | |||
except: | |||
result = False | |||
if not result: | |||
print('You need to install the module %s on your default python before installing Madrigal.' % (line.strip())) | |||
sys.exit(-1) | |||
# verify django at least version 1.11 | |||
if distutils.version.LooseVersion(django.get_version()) < distutils.version.LooseVersion('1.11'): | |||
print('django must be at least 1.11, your version is %s' % (django.__version__)) | |||
sys.exit(-1) | |||
print('All required python modules found.') | |||
sys.exit(0) |