Skip to content

Commit 4381bcb

Browse files
committed
Makefile: detect Python 3
1 parent db22e7b commit 4381bcb

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

Makefile

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,21 @@ JEKYLL=jekyll
77
JEKYLL_VERSION=3.8.5
88
PARSER=bin/markdown_ast.rb
99
DST=_site
10-
PYTHON=python3
10+
11+
# Check Python 3 (https://stackoverflow.com/a/4933395)
12+
ifneq (, $(shell which python3))
13+
PYTHON := python3
14+
else ifneq (, $(shell which python))
15+
PYTHON_VERSION_FULL := $(wordlist 2,4,$(subst ., ,$(shell python --version 2>&1)))
16+
PYTHON_VERSION_MAJOR := $(word 1,${PYTHON_VERSION_FULL})
17+
ifneq (3, ${PYTHON_VERSION_MAJOR})
18+
$(error "Your system does not appear to have Python 3 installed.")
19+
endif
20+
PYTHON := python
21+
else
22+
$(error "Your system does not appear to have any Python installed.")
23+
endif
24+
1125

1226
# Controls
1327
.PHONY : commands clean files

0 commit comments

Comments
 (0)