py-defs.mk, py-mod.mk: Add support for Python3's __pycache__

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2019-03-12 11:35:49 +00:00
commit fe161ff4d6
2 changed files with 31 additions and 12 deletions

View file

@ -17,21 +17,30 @@ distclean:
py.clean:
$(RM) -f *.done *.pyc
/bin/bash $(MOD_SCRIPT_DIR)/scm.sh clean -f __init__.py
$(RM) -rf __pycache__
install-dirs.done:
$(INSTALL) -d -m $(PYMODDIRMODE) -o $(PYMODDIROWNER) -g $(PYMODDIRGROUP) $(PY_INSTALL_DIR)
$(INSTALL) -d -m $(PYMODDIRMODE) -o $(PYMODDIROWNER) -g $(PYMODDIRGROUP) $(PY_INSTALL_DIRS)
touch $@
install-reg.done: install-dirs.done $(PY_INSTALLED_REG)
touch $@
%.pyc: %.py
python2 -c "import py_compile; py_compile.compile(\"$<\")"
$(PY_INSTALL_DIR)/%.py: %.py
$(PY_INSTALL_DIR_PY)/%.py: %.py
$(INSTALL) -p -m $(PYMODMODE) -o $(PYMODOWNER) -g $(PYMODGROUP) $< $@
$(PY_INSTALL_DIR)/%.pyc: %.pyc
ifneq ($(PYTHON),python3)
%.pyc: %.py
else
__pycache__/%.cpython-37.pyc: %.py
endif
$(PYTHON) -c "import py_compile; py_compile.compile(\"$<\")"
ifeq ($(PYTHON),python3)
$(PY_INSTALL_DIR_PY)/__pycache__/%.cpython-37.pyc: __pycache__/%.cpython-37.pyc
else
$(PY_INSTALL_DIR_PY)/%.pyc: %.pyc
endif
$(INSTALL) -p -m $(PYMODMODE) -o $(PYMODOWNER) -g $(PYMODGROUP) $< $@
__init__.py: $(PY_INIT_TMPL) $(filter-out __init__.py,$(PY_SRC_PY))