jw-pkg/make/py-mod.mk
Jan Lindemann 8f1154892f
All checks were successful
CI / Packaging - Kali Linux (pull_request) Successful in 3m1s
CI / Packaging - OpenSUSE Tumbleweed (pull_request) Successful in 3m6s
CI / Packaging test (pull_request) Successful in 0s
CI / Packaging - Kali Linux (push) Successful in 3m6s
CI / Packaging - OpenSUSE Tumbleweed (push) Successful in 3m1s
CI / Packaging test (push) Successful in 0s
py-mod.mk: Extract symbols in __all__

Symbols in the __all__ list of a module marked with "# export" arent't currently added to __init__.py. Fix that.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-06-17 19:24:49 +02:00

33 lines
1.4 KiB
Makefile

include $(JWBDIR)/make/defs.mk
include $(JWBDIR)/make/py-defs.mk
include $(JWBDIR)/make/dirs.mk
include $(JWBDIR)/make/dev-utils.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
#leftparen := (
#PY_EXPORT ?= $(shell sed '/\(class\|def\) ..*\# *export/ !d; s/\(class\|def\) *//; s/[$(leftparen):].*//' $(PY_SRC_PY))
all: $(PY_PYC)
install: install-dirs.done install-reg.done
clean: 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_ALL_PY)) $(SUBDIRS_TO_ITERATE) | $(PY_INIT_FILTER) | tee -a $@.tmp
mv $@.tmp $@
endif