py-defs.mk: Support PY_INSTALL[_XXX]

Support the Makefile variables PY_INSTALL, PY_INSTALL_REG, PY_INSTALL_PYC, all
defaulting to true. They can be set to false to stop installation of whatever
file type is undesired in the target. A common use case for this are
__init__.cpython-313.pyc, provided by a package the installing package depends
on. The prerequisite package might already provide these files for common
directories.

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2025-07-16 16:21:35 +00:00
commit a907a5640f

View file

@ -56,10 +56,24 @@ else
PY_INSTALL_DIR_PYC ?= $(PY_INSTALL_DIR_PY)
endif
PY_INSTALL ?= true
PY_INSTALL_REG ?= true
ifneq ($(PY_INSTALL),true)
PY_INSTALL_REG = false
endif
PY_INSTALL_PYC ?= true
ifneq ($(PY_INSTALL_REG),true)
PY_INSTALL_PYC = false
endif
PY_INSTALL_DIRS ?= $(sort $(PY_INSTALL_DIR_PY) $(PY_INSTALL_DIR_PYC))
PY_INSTALLED_PY = $(addprefix $(PY_INSTALL_DIR_PY)/,$(sort $(PY_ALL_PY)))
ifeq ($(PY_INSTALL_PYC),true)
PY_INSTALLED_PYC = $(addprefix $(PY_INSTALL_DIR_PY)/,$(PY_PYC))
endif
ifeq ($(PY_INSTALL_REG),true)
PY_INSTALLED_REG = $(PY_INSTALLED_PY) $(PY_INSTALLED_PYC)
endif
PYTHONPATH ?= $(call proj_query, pythonpath $(PROJECT) $(PY_PREREQ_RUN))
#PYTHONPATH = $(subst $(space),,$(ENV_PYTHONPATH)$(foreach d,$(PY_MODULE_DIRS),:$(d)))