From 72ba908be1eb9e2158611d7600b19dde9ec7f75f Mon Sep 17 00:00:00 2001 From: sylvain tricot Date: Thu, 21 Jan 2021 11:12:24 +0100 Subject: [PATCH] Improve python path and version checking. In the top Makefile, the Python path and version are first checked before going any further. This is now done in a more cleaner way by looking at the "sys.version_info variable" --- Makefile | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 0440e6b..7767837 100644 --- a/Makefile +++ b/Makefile @@ -1,19 +1,18 @@ include src/options.mk PYTHON = python +PYMAJ = 3 +PYMIN = 6 -# Checking Python version +# Checking Python path and version PYTHON_EXE := $(shell command -v $(PYTHON) 2> /dev/null) ifndef PYTHON_EXE $(error Unable to find the $(PYTHON) executable!) endif -PYTHON_VERSION_MAJOR := $(shell $(PYTHON_EXE) --version 2>&1 | cut -d" " -f2 | cut -d. -f1) -PYTHON_VERSION_MINOR := $(shell $(PYTHON_EXE) --version 2>&1 | cut -d" " -f2 | cut -d. -f2) - -ifneq ($(shell test $(PYTHON_VERSION_MAJOR) -ge 3 -a $(PYTHON_VERSION_MINOR) -ge 6; echo $$?),0) - $(error Python version >= 3.6 is needed!) +ifeq ($(shell python -c "import sys; exit(sys.version_info >= ($(PYMAJ),$(PYMIN)))"; echo $$?),0) + $(error Python version >= $(PYMAJ).$(PYMIN) is needed!) endif