Compare commits

..

1 commit

Author SHA1 Message Date
80248dec88
python-tools.sh, py-mod.mk: Use --symbol-filter
Some checks failed
CI / Packaging - Kali Linux (pull_request) Failing after 2m8s
CI / Packaging - OpenSUSE Tumbleweed (pull_request) Failing after 2m34s
CI / Packaging test (pull_request) Failing after 0s

Letting python-tools.sh rewrite symbols is more robust than rewriting an entire __init__.py with PY_INIT_FILTER in the including Makefile. The latter can break in non-obvious ways if python-tools.sh changes __init__.py's format.

Make python-tools.sh support --symbol-filter to remedy that. The option takes an sed script which should expect a string of two non-whitespace tokens: The module from which the symbol is imported, and the name of the symbol in that module. It's output will then be used as the symbol to be exported from __init__.py.

Also, support the PY_SYMBOL_FILTER variable in py-mod.mk. If it's defined, it is used for --symbol-filter.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-06-12 07:17:51 +02:00

View file

@ -59,11 +59,6 @@ cmd_create_init()
if [ "$sed_extract_cmd" ]; then
local src_type types=$(sed "$sed_extract_cmd" $f)
for src_type in $types; do
if [ -z "$sed_symbol_filter_cmd" ]; then
dst_type="$src_type"
else
dst_type=$(echo $base $src_type | sed "$sed_symbol_filter_cmd")
fi
[ "$sed_symbol_filter_cmd" ] && dst_type=$(echo $base $src_type | sed "$sed_symbol_filter_cmd")
echo "from `module_path $base` import $src_type as $dst_type"
__add_seen $dst_type