Repository: kivy/kivy
Pull request: Makefile: Detect python verion and gracefully fail on unsupported version
fixes https://github.com/kivy/kivy/issues/7109

Problem statement:
Add a check for python version in `make` and gracefully exit rather than fail on python version 2.
**Software Versions**
* Python:
* OS: OSX 10.15.6
* Kivy: master 27 sept 2020
* Kivy installation method: clone master and `make`

**Describe the bug**
Make fails with `python` referring to python2 does not fail gracefully

**Expected behavior**
```
 kivy % make 
python setup.py build_ext —inplace
Python version 2 is not supported, please use python3
```
**To Reproduce**
```
> git clone github.com/kivy/kivy
> cd kivy
> make 
```

**Code and Logs and screenshots**
```
 kivy % make 
python setup.py build_ext --inplace
  File "setup.py", line 1050
    def glob_paths(*patterns, excludes=('.pyc', )):
                                     ^
SyntaxError: invalid syntax
make: *** [build] Error 1
```

**Additional context**
Add any other context about the problem here.

Hints from issue discussion:
maybe something like
```python
PYTHON_MINIMUM_VERSION = (3, 6, 0)

if sys.version_info < PYTHON_MINIMUM_VERSION:
     logger.error("Kivy requires at least Python%d.%d.%d", *PYTHON_MININUM_VERSION)
```

Commit message: Detect python verion and gracefully fail on unsupported ver.

Patch to review:
diff --git a/Makefile b/Makefile
index 0c6ce1c5b8..c0fcfcb939 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,16 @@
+ifeq (, $(shell which python ))
+  $(error "PYTHON=$(PYTHON) not found in $(PATH)")
+endif
+
 PYTHON = python
+PYTHON_VERSION_MIN=3.6
+PYTHON_VERSION=$(shell $(PYTHON) -c 'import sys; print("%d.%d"% sys.version_info[0:2])' )
+PYTHON_VERSION_OK=$(shell $(PYTHON) -c 'import sys;\
+  print(int(float("%d.%d"% sys.version_info[0:2]) >= $(PYTHON_VERSION_MIN)))' )
+
+ifeq ($(PYTHON_VERSION_OK),0)
+  $(error "detected Python $(PYTHON_VERSION) need Python >= $(PYTHON_VERSION_MIN)")
+endif
 CHECKSCRIPT = -m flake8
 KIVY_DIR = kivy/
 PYTEST = $(PYTHON) -m pytest
@@ -28,7 +40,6 @@ ifneq ($(INSTALL_LAYOUT),)
 	INSTALL_OPTIONS += --install-layout=$(INSTALL_LAYOUT)
 endif
 
-
 .PHONY: build force mesabuild pdf style hook test batchtest cover clean distclean theming
 
 build:


Code review comments:
diff_hunk: @@ -1,4 +1,16 @@
+ifeq (, $(shell which python ))
+  $(error "PYTHON=$(PYTHON) not found in $(PATH)")
+endif
+
 PYTHON = python
+PYTHON_VERSION_MIN=3.6
path: Makefile
text: @user1:
I'd only check here for python2. And if it's not python 2 I'd then rely on https://packaging.python.org/guides/distributing-packages-using-setuptools/#python-requires in the setup.cfg, rather than checking it here. That way all the metadata is in one place (going under the assumption people have a updated pip).