jw-pkg/make/py-mod.mk
Jan Lindemann 55f9b50562 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>
2017-07-24 10:59:08 +00:00

36 lines
1.1 KiB
Makefile

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
distclean:
py.clean:
rm -f *.done *.pyc
/bin/bash $(MOD_SCRIPT_DIR)/scm.sh clean -f __init__.py
install-dirs.done:
$(INSTALL) -d -m $(PYMODDIRMODE) -o $(PYMODDIROWNER) -g $(PYMODDIRGROUP) $(PY_INSTALL_DIR)
touch $@
install-reg.done: install-dirs.done $(PY_INSTALLED_REG)
touch $@
%.pyc: %.py
python -c "import py_compile; py_compile.compile(\"$<\")"
$(PY_INSTALL_DIR)/%.py: %.py
$(INSTALL) -m $(PYMODMODE) -o $(PYMODOWNER) -g $(PYMODGROUP) $< $@
$(PY_INSTALL_DIR)/%.pyc: %.pyc
$(INSTALL) -m $(PYMODMODE) -o $(PYMODOWNER) -g $(PYMODGROUP) $< $@
__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 $@