jw-pkg/make/py-ns-dir.mk

26 lines
558 B
Makefile
Raw Normal View History

define INIT_PY
from pkgutil import extend_path
__path__ = extend_path(__path__, __name__)
endef
# The __init__.py machinery duplicates (but is independent from) py-mod.mk
PY_UPDATE_INIT_PY ?= true
PY_INSTALL_INIT_PY ?= false
ifneq ($(PY_UPDATE_INIT_PY),false)
PY_GENERATED_PY += __init__.py
endif
include $(JWBDIR)/make/dirs.mk
all: $(PY_GENERATED_PY)
clean: py.clean
py.clean:
rm -rf __pycache__ $(PY_GENERATED_PY)
__init__.py:
@echo "Creating default namespace stub $@.tmp"
$(file >$@.tmp,$(INIT_PY))
mv $@.tmp $@