10.12., 9:00 - 11:00: Due to updates GitLab may be unavailable for some minutes between 09:00 and 11:00.

Commit ee02650d authored by Jean-Matthieu Gallard's avatar Jean-Matthieu Gallard

Toolkit - fix version check to properly get an error message when using the wrong python3 version

parent fe55a9b7
#Check Python version
from .configuration import checkPythonVersion
checkPythonVersion()
#High level API
from .controller import Controller
from .configuration import checkDependencies
......@@ -61,13 +61,15 @@ class Configuration:
# set to true to print models runtime
runtimeDebug = False;
@staticmethod
def checkPythonVersion():
"""check version. Python 3.3 required"""
requiredVersion = (3,3)
currentVersion = sys.version_info
if(requiredVersion > currentVersion):
sys.exit("Requires Python 3.3 or newer. Abort.")
def checkPythonVersion():
"""check version. Python 3.6 required"""
requiredVersion = (3,6)
currentVersion = sys.version_info
if(requiredVersion > currentVersion):
sys.exit("Requires Python 3.6 or newer. Abort.")
def checkDependencies():
......
......@@ -50,9 +50,6 @@ class Controller:
def __init__(self, inputConfig = None):
"""Initialize the base config from the command line inputs"""
Configuration.checkPythonVersion()
if inputConfig == None:
args = ArgumentParser.parseArgs()
else:
......
......@@ -4,6 +4,10 @@ This is the exahype.toolkit package and holds the code of the "toolkit2", also c
main glue code generator for ExaHyPE supposed to be runned by users.
"""
#Check Python version
from .configuration import checkPythonVersion
checkPythonVersion()
#High level API
from .controller import Controller
from .configuration import checkDependencies
from .controller import Controller
......@@ -34,13 +34,13 @@ class Configuration:
}
@staticmethod
def checkPythonVersion():
"""check version. Python 3.6 required"""
requiredVersion = (3,6)
currentVersion = sys.version_info
if(requiredVersion > currentVersion):
sys.exit("Requires Python 3.6 or newer. Abort.")
def checkPythonVersion():
"""check version. Python 3.6 required"""
requiredVersion = (3,6)
currentVersion = sys.version_info
if(requiredVersion > currentVersion):
sys.exit("Requires Python 3.6 or newer. Abort.")
......
......@@ -58,8 +58,6 @@ class Controller:
def __init__(self):
"""TODO"""
# Check the python version according to the configuration
Configuration.checkPythonVersion()
logging.basicConfig(format="%(filename)s:%(lineno)s(%(funcName)s):%(levelname)s %(message)s")
self.log = logging.getLogger()
......
......@@ -14,8 +14,14 @@ if has python3; then PYTHON3="python3";
elif python --version | grep -qi "python 3"; then PYTHON3="python"
else echo "$0: Python3 required for running the ExaHyPE toolkit" >&2; exit -1; fi
# check that all required dependencies are there.
if ! $PYTHON3 -c "import sys; sys.path.append(\"$Toolkit\"); import exahype.toolkit; exahype.toolkit.checkDependencies()" 2>&1 >/dev/null; then
# check the python version (hack the sys.path to not load the __init__.py and try to load the dependencies in the import).
if ! $PYTHON3 -c "import sys; sys.path.append(\"$Toolkit/exahype/toolkit\"); from configuration import checkPythonVersion; checkPythonVersion()" 2>&1 >/dev/null; then
echo "$0: Wrong python3 version." >&2
exit -1
fi
# check that all required dependencies are there (hack the sys.path to not load the __init__.py and try to load the dependencies in the import).
if ! $PYTHON3 -c "import sys; sys.path.append(\"$Toolkit/exahype/toolkit\"); from configuration import checkDependencies; checkDependencies()" 2>&1 >/dev/null; then
echo "$0: At least one required Python3 module is not available." >&2
echo "$0: Install the project submodules with ./Submodules/updateSubmodules.sh from ExaHyPE's main directory" >&2
exit -1
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment