2025-02-22 09:04:17 +00:00
|
|
|
# This file strives to be the most minimal piece of code to set the python
|
|
|
|
|
# version up
|
|
|
|
|
|
2026-10-20 08:58:08 +02:00
|
|
|
include $(JWBDIR)/make/common.mk
|
|
|
|
|
|
2025-02-22 09:04:17 +00:00
|
|
|
ifneq ($(PYTHON_VERSION),)
|
|
|
|
|
PYTHON := /usr/bin/python$(PYTHON_VERSION)
|
|
|
|
|
else
|
|
|
|
|
ifeq ($(PYTHON),)
|
|
|
|
|
#PYTHON := $(lastword $(shell /bin/bash -O extglob -c "ls -v /usr/bin/python[0-9].+([0-9])"))
|
common.mk: Set WHICH to command -v
defs.mk derives WHICH from the external which binary, first from a
hardcoded /usr/bin/which path and then with a `which which` fallback, while
the probes for time, ruff, pyright, and python3 call which directly.
Systems that do not ship the which package, such as minimal containers, are
left to the shell's PATH search.
Define WHICH once in common.mk as the POSIX command -v builtin and drop the
old definition from defs.mk. Route the remaining direct which calls through
$(WHICH):
- projects-dir.mk: TIME probe
- py-check.mk: PY_CHECK_RUFF and PY_CHECK_PYRIGHT probes
- py-version.mk: PYTHON lookup
command -v runs in the /bin/sh that $(shell) already uses, so the build no
longer depends on the which package. The builtin names that command -v
reports for echo, test, pwd, and printf are safe, because every use of
those variables runs through the shell, and the bash time keyword keeps the
-p output format identical to the GNU time binary.
Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v1.3.0
Signed-off-by: Jan Lindemann <jan@janware.com>
2026-10-20 08:58:08 +02:00
|
|
|
PYTHON := $(shell $(WHICH) python3 | xargs readlink -f)
|
2025-02-22 09:04:17 +00:00
|
|
|
endif
|
|
|
|
|
PYTHON_VERSION ?= $(patsubst python%,%,$(notdir $(PYTHON)))
|
|
|
|
|
endif
|
|
|
|
|
PYTHON_MAJOR = $(basename $(PYTHON_VERSION))
|
|
|
|
|
|