jw-pkg/make/py-mod.mk
Jan Lindemann e6e96d64c2
All checks were successful
CI / Packaging - Kali Linux (pull_request) Successful in 4m17s
CI / Packaging - OpenSUSE Tumbleweed (pull_request) Successful in 4m22s
CI / Packaging test (pull_request) Successful in 0s
CI / Packaging - Kali Linux (push) Successful in 4m11s
CI / Packaging - OpenSUSE Tumbleweed (push) Successful in 3m57s
CI / Packaging test (push) Successful in 0s
py-defs.mk, py-mod.mk: Add PY_LOCAL_PY(C)
The meaning of the many PY_XXX variables isn't easy to tell apart, so
start renaming some of them.

PY_ALL_PY and PY_PYC consistently are now named PY_LOCAL|INSTALL_PY and
PY_LOCAL|INSTALL_PYC, depending on whether or not they are intended to
be installed.

The old PY_INSTALL_PY was renamed to PY_DO_INSTALLL_PY, a move that
would be better applied to all boolean variables. I won't try with this
commit, however, because a lot of downstream packages depend on
PY_UPDATE_INIT_PY and PY_INSTALL_INIT_PY, i.e. without "_DO".

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-08-24 18:14:16 +02:00

39 lines
1.6 KiB
Makefile

include $(JWBDIR)/make/defs.mk
include $(JWBDIR)/make/py-defs.mk
include $(JWBDIR)/make/dirs.mk
include $(JWBDIR)/make/dev-utils.mk
include $(JWBDIR)/make/test-guard.mk
PY_INIT_TMPL = $(wildcard __init__.py.tmpl)
PY_SED_EXTRACT_EXPORT_DEF := /\(\(class\|def\)\s\+[a-zA-Z_].*\|^ *\S\+\s*=.*\|^\s\+\"\S\+\",\)\s*\#\s*export/!d;
PY_SED_EXTRACT_EXPORT_DEF := $(PY_SED_EXTRACT_EXPORT_DEF) /^\s*\#/ d; s/\(async\)*\s*\(class\|def\)\s*//;
PY_SED_EXTRACT_EXPORT_DEF := $(PY_SED_EXTRACT_EXPORT_DEF) s/[(:=].*//; s/^\s\+\"\(\S\+\)\",.*/\1/
PY_SED_EXTRACT_EXPORT ?= $(PY_SED_EXTRACT_EXPORT_DEF)
PY_INIT_FILTER ?= cat
PY_GENERATE_INIT_PY ?= /bin/bash $(JWB_SCRIPT_DIR)/python-tools.sh create-init -m . -e "$(PY_SED_EXTRACT_EXPORT)"
ifneq ($(PY_SYMBOL_FILTER),)
PY_GENERATE_INIT_PY += --symbol-filter "$(PY_SYMBOL_FILTER)"
endif
PY_INIT_SUBMODULES ?=
ifneq ($(PY_INIT_SUBMODULES),)
PY_GENERATE_INIT_PY += --submodules "$(PY_INIT_SUBMODULES)"
endif
#leftparen := (
#PY_EXPORT ?= $(shell sed '/\(class\|def\) ..*\# *export/ !d; s/\(class\|def\) *//; s/[$(leftparen):].*//' $(PY_SRC_PY))
all: $(PY_LOCAL_PYC)
install: install-dirs.done install-reg.done
clean: invalidate-testability py.clean
distclean:
include $(JWBDIR)/make/py-rules.mk
ifeq ($(PY_UPDATE_INIT_PY),true)
__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
set -e -o pipefail; $(PY_GENERATE_INIT_PY) \
$(filter-out __init__.py,$(PY_LOCAL_PY)) $(SUBDIRS_TO_ITERATE) | $(PY_INIT_FILTER) | tee -a $@.tmp
mv $@.tmp $@
endif