Script returns full binary name
This commit is contained in:
parent
f95979586d
commit
d44570b557
2 changed files with 25 additions and 25 deletions
24
Makefile
24
Makefile
|
@ -96,28 +96,16 @@ build-deps-ubuntu:
|
||||||
docs: docs-deps docs-build
|
docs: docs-deps docs-build
|
||||||
|
|
||||||
docs-build: .PHONY
|
docs-build: .PHONY
|
||||||
@if ! SUFFIX=$$(tools/get-best-python-for-docs-build.sh); then \
|
PY=$$(tools/get-python-bin.sh python) && MKDOCS=$$(which mkdocs) && \
|
||||||
echo "ERROR: could not find a recent version of Python. mkdocs needs >= 3.8"; \
|
$$PY $$MKDOCS build
|
||||||
exit 1; \
|
|
||||||
fi; \
|
|
||||||
echo "python$$SUFFIX $$(which mkdocs) build"; \
|
|
||||||
"python$$SUFFIX" $$(which mkdocs) build
|
|
||||||
|
|
||||||
docs-deps: .PHONY
|
docs-deps: .PHONY
|
||||||
@if ! SUFFIX=$$(tools/get-best-python-for-docs-build.sh); then \
|
PIP=$$(tools/get-python-bin.sh pip) && \
|
||||||
echo "ERROR: could not find a recent version of Python. mkdocs needs >= 3.8"; \
|
$$PIP install -r requirements.txt
|
||||||
exit 1; \
|
|
||||||
fi; \
|
|
||||||
echo "pip$$SUFFIX install -r requirements.txt"; \
|
|
||||||
"pip$$SUFFIX" install -r requirements.txt
|
|
||||||
|
|
||||||
docs-deps-update: .PHONY
|
docs-deps-update: .PHONY
|
||||||
@if ! SUFFIX=$$(tools/get-best-python-for-docs-build.sh); then \
|
PIP=$$(tools/get-python-bin.sh pip) && \
|
||||||
echo "ERROR: could not find a recent version of Python. mkdocs needs >= 3.8"; \
|
$$PIP install -r requirements.txt --upgrade
|
||||||
exit 1; \
|
|
||||||
fi; \
|
|
||||||
echo "pip$$SUFFIX install -r requirements.txt --upgrade"; \
|
|
||||||
"pip$$SUFFIX" install -r requirements.txt --upgrade
|
|
||||||
|
|
||||||
# Web app
|
# Web app
|
||||||
|
|
||||||
|
|
|
@ -1,20 +1,31 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# This script prints the version suffix of the most suitable version of Python
|
# Synopsis:
|
||||||
# for building docs that's installed in this system.
|
# - get-python-bin.sh python
|
||||||
|
# - get-python-bin.sh pip
|
||||||
#
|
#
|
||||||
# Caller can safely append this suffix to `python` or `pip` and expect the
|
# This script selects the most suitable `python` / `pip` binary available
|
||||||
# binary to exist.
|
# for building docs that's installed in this system.
|
||||||
#
|
#
|
||||||
# If no usable version of Python is available, this script will exit with a
|
# If no usable version of Python is available, this script will exit with a
|
||||||
# non-zero code.
|
# non-zero code.
|
||||||
|
|
||||||
set -e
|
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 `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 && \
|
if echo -e "import sys\nif sys.version_info < (3,8):\n exit(1)" | python3 && \
|
||||||
which pip3 1>/dev/null 2>&1; then
|
which pip3 1>/dev/null 2>&1; then
|
||||||
echo "3"
|
echo "${BIN_PREFIX}3"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -24,10 +35,11 @@ for SUFFIX in ${CANDIDATE_SUFFIXES[@]}; do
|
||||||
# if both `python3.N` and `pip3.N` are available, use that
|
# if both `python3.N` and `pip3.N` are available, use that
|
||||||
if which "python$SUFFIX" 1>/dev/null 2>&1 && \
|
if which "python$SUFFIX" 1>/dev/null 2>&1 && \
|
||||||
which "pip$SUFFIX" 1>/dev/null 2>&1; then
|
which "pip$SUFFIX" 1>/dev/null 2>&1; then
|
||||||
echo "$SUFFIX"
|
echo "${BIN_PREFIX}${SUFFIX}"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# none found
|
# none found
|
||||||
exit 1
|
echo "No suitable version of Python found" >&2
|
||||||
|
exit 2
|
Loading…
Add table
Add a link
Reference in a new issue