projects.mk, py-defs.mk, py-version.mk: Add py-version.mk

This commit adds py-version.mk, eliminating redundancy between projects.mk and
py-defs.mk in setting up the Python version early.
This commit is contained in:
Jan Lindemann 2025-02-22 09:04:17 +00:00
commit 60ef137bc3
3 changed files with 17 additions and 20 deletions

View file

@ -27,16 +27,7 @@ ifndef WHICH
WHICH := $(firstword $(wildcard /usr/bin/which) $(shell which which)) WHICH := $(firstword $(wildcard /usr/bin/which) $(shell which which))
endif endif
# note: This is redundant to py-defs.mk include $(JWBDIR)/make/py-version.mk
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])"))
endif
PYTHON_VERSION ?= $(patsubst python%,%,$(notdir $(PYTHON)))
endif
PYTHON_MAJOR = $(basename $(PYTHON_VERSION))
ifneq ($(TOPDIR),) ifneq ($(TOPDIR),)
proj_query_cmd = $(PYTHON) $(JWB_SCRIPT_DIR)/projects.py -p $(PROJECTS_DIR) -t $(TOPDIR) $(PROJECTS_PY_EXTRA_ARGS) proj_query_cmd = $(PYTHON) $(JWB_SCRIPT_DIR)/projects.py -p $(PROJECTS_DIR) -t $(TOPDIR) $(PROJECTS_PY_EXTRA_ARGS)

View file

@ -1,15 +1,6 @@
ENV_PYTHONPATH := $(PYTHONPATH) ENV_PYTHONPATH := $(PYTHONPATH)
# note: This is redundant to projects.mk include $(JWBDIR)/make/py-version.mk
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])"))
endif
PYTHON_VERSION ?= $(patsubst python%,%,$(notdir $(PYTHON)))
endif
PYTHON_MAJOR = $(basename $(PYTHON_VERSION))
ifeq ($(DEVELOPMENT),true) ifeq ($(DEVELOPMENT),true)
PY_SITE_PACKAGES_PATH := $(PREFIX)/python$(PYTHON_VERSION)/site-packages PY_SITE_PACKAGES_PATH := $(PREFIX)/python$(PYTHON_VERSION)/site-packages
@ -86,6 +77,7 @@ all:
clean: pyc.clean clean: pyc.clean
echo-py: echo-py:
@echo "PYTHON = $(PYTHON)"
@echo "PY_INSTALL_DIR_PY = $(PY_INSTALL_DIR_PY)" @echo "PY_INSTALL_DIR_PY = $(PY_INSTALL_DIR_PY)"
@echo "PROJECT = $(PROJECT)" @echo "PROJECT = $(PROJECT)"
@echo "PY_SITE_PACKAGES_PATH = $(PY_SITE_PACKAGES_PATH)" @echo "PY_SITE_PACKAGES_PATH = $(PY_SITE_PACKAGES_PATH)"

14
make/py-version.mk Normal file
View file

@ -0,0 +1,14 @@
# This file strives to be the most minimal piece of code to set the python
# version up
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])"))
PYTHON := $(shell which python3 | xargs readlink -f)
endif
PYTHON_VERSION ?= $(patsubst python%,%,$(notdir $(PYTHON)))
endif
PYTHON_MAJOR = $(basename $(PYTHON_VERSION))