py-defs.mk, py-mod.mk: Support PY_UPDATE_INIT_PY

Allow to disable auto-updating of __init__.py in a directory via
PY_UPDATE_INIT_PY = true | false.

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2025-11-16 18:42:58 +01:00
commit d0c1eac1a9
2 changed files with 3 additions and 0 deletions

View file

@ -56,6 +56,7 @@ else
PY_INSTALL_DIR_PYC ?= $(PY_INSTALL_DIR_PY) PY_INSTALL_DIR_PYC ?= $(PY_INSTALL_DIR_PY)
endif endif
PY_UPDATE_INIT_PY ?= false
PY_INSTALL ?= true PY_INSTALL ?= true
PY_INSTALL_REG ?= true PY_INSTALL_REG ?= true
ifneq ($(PY_INSTALL),true) ifneq ($(PY_INSTALL),true)

View file

@ -17,8 +17,10 @@ distclean:
include $(JWBDIR)/make/py-rules.mk include $(JWBDIR)/make/py-rules.mk
ifeq ($(PY_UPDATE_INIT_PY),true)
__init__.py: $(PY_INIT_TMPL) $(filter-out __init__.py,$(PY_SRC_PY)) __init__.py: $(PY_INIT_TMPL) $(filter-out __init__.py,$(PY_SRC_PY))
if [ "$(PY_INIT_TMPL)" ]; then cat "$(PY_INIT_TMPL)" > $@.tmp; else > $@.tmp; fi if [ "$(PY_INIT_TMPL)" ]; then cat "$(PY_INIT_TMPL)" > $@.tmp; else > $@.tmp; fi
/bin/bash +H $(JWB_SCRIPT_DIR)/python-tools.sh create-init -m $(PY_MOD) -e "$(PY_SED_EXTRACT_EXPORT)" \ /bin/bash +H $(JWB_SCRIPT_DIR)/python-tools.sh create-init -m $(PY_MOD) -e "$(PY_SED_EXTRACT_EXPORT)" \
$(filter-out __init__.py,$(PY_ALL_PY)) $(SUBDIRS_TO_ITERATE) | $(PY_INIT_FILTER) | tee -a $@.tmp $(filter-out __init__.py,$(PY_ALL_PY)) $(SUBDIRS_TO_ITERATE) | $(PY_INIT_FILTER) | tee -a $@.tmp
mv $@.tmp $@ mv $@.tmp $@
endif