The __init__.py files as gnerated by python-tools.sh contain multiple issues, fix them:
- Make the machinery fail if the same type name is imported from different modules- Support relative imports from .Module import Module instead of having to use the entire module path as import source- Import types explicitly re-exported with "as":
from .Module import Module as ModuleOtherwise ruff will regard the type as "imported but not used"- Add "# ruff: noqa: E501" near the top. The import lines can get long and are beyond manual control (except for renaming the modules themselves, that is). This can cause ruff to fail, so get it to accept long lines in __init__.py. The style violation doesn't make much of a difference in generated code, anyway, because nobody reads that. Plus what's happening in the code isn't rocket science, so good style wouldn't help much with understanding, either.This promptly digs up two symbol name conflicts lib.pm.dpkg and lib.pm.rpm. Fix them along with this commit to keep it from breaking the build.
Signed-off-by: Jan Lindemann <jan@janware.com>
26 lines
1.1 KiB
Makefile
26 lines
1.1 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 ?= /\(\(class\|def\)\s\+[a-zA-Z_].*\|^ *\S\+\s*=.*\)\# *export/ !d; /^\s*\#/ d; s/\(async\)* *\(class\|def\) *//; s/[(:=].*//
|
|
PY_INIT_FILTER ?= cat
|
|
|
|
#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; /bin/bash $(JWB_SCRIPT_DIR)/python-tools.sh create-init -m . -e "$(PY_SED_EXTRACT_EXPORT)" \
|
|
$(filter-out __init__.py,$(PY_ALL_PY)) $(SUBDIRS_TO_ITERATE) | $(PY_INIT_FILTER) | tee -a $@.tmp
|
|
mv $@.tmp $@
|
|
endif
|