py-defs.mk, py-mod.mk, python-tools.sh: Improve python module handling

- Fix superflous dots in module names
- Generate PYTHONPATH in projects.py
- Add support for __init__.py.tmpl

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2017-07-24 10:59:08 +00:00
commit 55f9b50562
3 changed files with 35 additions and 19 deletions

View file

@ -2,6 +2,9 @@ include $(MODDIR)/make/defs.mk
include $(MODDIR)/make/py-defs.mk
include $(MODDIR)/make/dirs.mk
PY_INIT_TMPL = $(wildcard __init__.py.tmpl)
PY_SED_EXTRACT_EXPORT ?= /class ..*\# *export/ !d; s/class *//; s/[(:].*//
all: $(PY_PYC)
install: install-dirs.done install-reg.done
clean: py.clean
@ -27,6 +30,7 @@ $(PY_INSTALL_DIR)/%.py: %.py
$(PY_INSTALL_DIR)/%.pyc: %.pyc
$(INSTALL) -m $(PYMODMODE) -o $(PYMODOWNER) -g $(PYMODGROUP) $< $@
__init__.py:
/bin/bash +H $(MOD_SCRIPT_DIR)/python-tools.sh create-init -m $(PY_MOD) -e "$(PY_SED_EXTRACT_EXPORT)" *.py | tee $@.tmp
__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
/bin/bash +H $(MOD_SCRIPT_DIR)/python-tools.sh create-init -m $(PY_MOD) -e "$(PY_SED_EXTRACT_EXPORT)" *.py | tee -a $@.tmp
mv $@.tmp $@