Merge 008ff709c8
into c332c132fa
This commit is contained in:
commit
433ce9e613
2 changed files with 53 additions and 15 deletions
22
Makefile
22
Makefile
|
@ -1,7 +1,11 @@
|
||||||
MAKEFLAGS := --jobs=1
|
MAKEFLAGS := --jobs=1
|
||||||
|
|
||||||
VERSION := $(shell git describe --tag)
|
VERSION := $(shell git describe --tag)
|
||||||
COMMIT := $(shell git rev-parse --short HEAD)
|
COMMIT := $(shell git rev-parse --short HEAD)
|
||||||
|
|
||||||
|
PY_BIN := $(shell tools/get-python-bin.sh python)
|
||||||
|
PIP_BIN := $(shell tools/get-python-bin.sh pip)
|
||||||
|
|
||||||
.PHONY:
|
.PHONY:
|
||||||
|
|
||||||
help:
|
help:
|
||||||
|
@ -111,25 +115,13 @@ build-deps-ubuntu:
|
||||||
docs: docs-deps docs-build
|
docs: docs-deps docs-build
|
||||||
|
|
||||||
docs-build: .PHONY
|
docs-build: .PHONY
|
||||||
@if ! /bin/echo -e "import sys\nif sys.version_info < (3,8):\n exit(1)" | python3; then \
|
PY=$$(which $(PY_BIN)) && MKDOCS=$$(which mkdocs) && $$PY $$MKDOCS build
|
||||||
if which python3.8; then \
|
|
||||||
echo "python3.8 $(shell which mkdocs) build"; \
|
|
||||||
python3.8 $(shell which mkdocs) build; \
|
|
||||||
else \
|
|
||||||
echo "ERROR: Python version too low. mkdocs-material needs >= 3.8"; \
|
|
||||||
exit 1; \
|
|
||||||
fi; \
|
|
||||||
else \
|
|
||||||
echo "mkdocs build"; \
|
|
||||||
mkdocs build; \
|
|
||||||
fi
|
|
||||||
|
|
||||||
docs-deps: .PHONY
|
docs-deps: .PHONY
|
||||||
pip3 install -r requirements.txt
|
PIP=$$(which $(PIP_BIN)) && $$PIP install -r requirements.txt
|
||||||
|
|
||||||
docs-deps-update: .PHONY
|
docs-deps-update: .PHONY
|
||||||
pip3 install -r requirements.txt --upgrade
|
PIP=$$(which $(PIP_BIN)) && $$PIP install -r requirements.txt --upgrade
|
||||||
|
|
||||||
|
|
||||||
# Web app
|
# Web app
|
||||||
|
|
||||||
|
|
46
tools/get-python-bin.sh
Executable file
46
tools/get-python-bin.sh
Executable file
|
@ -0,0 +1,46 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Synopsis:
|
||||||
|
# - get-python-bin.sh python
|
||||||
|
# - get-python-bin.sh pip
|
||||||
|
#
|
||||||
|
# This script selects the most suitable `python` / `pip` binary available
|
||||||
|
# for building docs that's installed in this system.
|
||||||
|
#
|
||||||
|
# If no usable version of Python is available, this script will exit with a
|
||||||
|
# non-zero code.
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
"python" | "pip")
|
||||||
|
BIN_PREFIX="$1"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Incorrect usage" >&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# if `python3` is >= 3.8 and `pip3` is available, use that
|
||||||
|
if echo -e "import sys\nif sys.version_info < (3,8):\n exit(1)" | python3 && \
|
||||||
|
which pip3 1>/dev/null 2>&1; then
|
||||||
|
echo "${BIN_PREFIX}3"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# list all available `python3.N`, then use the newest that passes checks
|
||||||
|
# compgen is bash-specific, but we asked for bash in shebang so it's fine
|
||||||
|
MINOR_VERSION_CANDIDATES=$(compgen -c | grep -P '^python3\.[0-9]+$' | sed 's/python3\.//' | awk 'int($NF) >= 8' | sort -nr)
|
||||||
|
for MINOR in ${MINOR_VERSION_CANDIDATES[@]}; do
|
||||||
|
# if both `python3.N` and `pip3.N` are available, use that
|
||||||
|
if which "python3.${MINOR}" 1>/dev/null 2>&1 && \
|
||||||
|
which "pip3.${MINOR}" 1>/dev/null 2>&1; then
|
||||||
|
echo "${BIN_PREFIX}3.${MINOR}"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# none found
|
||||||
|
echo "No suitable version of Python found" >&2
|
||||||
|
exit 2
|
Loading…
Add table
Add a link
Reference in a new issue