From 4381bcba70153a0ee0385ef440c7a6e2d7745536 Mon Sep 17 00:00:00 2001 From: Maxim Belkin Date: Thu, 5 Dec 2019 10:46:38 -0600 Subject: [PATCH] Makefile: detect Python 3 --- Makefile | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 89a3105..ecdb230 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,21 @@ JEKYLL=jekyll JEKYLL_VERSION=3.8.5 PARSER=bin/markdown_ast.rb DST=_site -PYTHON=python3 + +# Check Python 3 (https://stackoverflow.com/a/4933395) +ifneq (, $(shell which python3)) + PYTHON := python3 +else ifneq (, $(shell which python)) + PYTHON_VERSION_FULL := $(wordlist 2,4,$(subst ., ,$(shell python --version 2>&1))) + PYTHON_VERSION_MAJOR := $(word 1,${PYTHON_VERSION_FULL}) + ifneq (3, ${PYTHON_VERSION_MAJOR}) + $(error "Your system does not appear to have Python 3 installed.") + endif + PYTHON := python +else + $(error "Your system does not appear to have any Python installed.") +endif + # Controls .PHONY : commands clean files -- 2.30.2