diff --git a/make/py-ns-dir.mk b/make/py-ns-dir.mk index 1c69d559..3529e721 100644 --- a/make/py-ns-dir.mk +++ b/make/py-ns-dir.mk @@ -1,7 +1,26 @@ +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: +all: $(PY_GENERATED_PY) clean: py.clean py.clean: - rm -rf __pycache__ + rm -rf __pycache__ $(PY_GENERATED_PY) + +__init__.py: + @echo "Creating default namespace stub $@.tmp" + $(file >$@.tmp,$(INIT_PY)) + mv $@.tmp $@ diff --git a/src/python/jw/Makefile b/src/python/jw/Makefile index d99ad1c0..78727dfe 100644 --- a/src/python/jw/Makefile +++ b/src/python/jw/Makefile @@ -1,4 +1,6 @@ TOPDIR = ../../.. +PY_UPDATE_INIT_PY = false + include $(TOPDIR)/make/proj.mk include $(JWBDIR)/make/py-ns-dir.mk