mirror of
ssh://git.janware.com/srv/git/janware/proj/jw-pkg
synced 2026-01-15 12:03:31 +01:00
This commit adds support for static typechecking with mypy.
Notable additions:
- A new target "check" which does the type checking
- Py-mods.mk, meant to be included from a directory containing python modules
in subdirectories, but not being a python module itself. It makes the all
target depend on check only if PY_RUN_CHECK_AFTER_BUILD is defined and
true. That's because pypy is under heavy development, and the Ubuntu 18.04
version is too old to work for lots of the code.
Signed-off-by: Jan Lindemann <jan@janware.com>
33 lines
937 B
Makefile
33 lines
937 B
Makefile
all:
|
|
|
|
py.clean:
|
|
$(RM) -f *.done *.pyc *.rep
|
|
/bin/bash $(JWB_SCRIPT_DIR)/scm.sh clean -f __init__.py
|
|
$(RM) -rf __pycache__ .mypy_cache
|
|
|
|
install-dirs.done:
|
|
$(INSTALL) -d -m $(PYJWBDIRMODE) -o $(PYJWBDIROWNER) -g $(PYJWBDIRGROUP) $(PY_INSTALL_DIRS)
|
|
touch $@
|
|
|
|
install-reg.done: install-dirs.done $(PY_INSTALLED_REG)
|
|
touch $@
|
|
|
|
$(PY_INSTALL_DIR_PY)/%.py: %.py
|
|
$(INSTALL) -p -m $(PYMODMODE) -o $(PYMODOWNER) -g $(PYMODGROUP) $< $@
|
|
|
|
ifneq ($(PYTHON_VERSION),3)
|
|
%.pyc: %.py
|
|
else
|
|
__pycache__/%.$(PY_CPYTHON_PREFIX).pyc: %.py
|
|
endif
|
|
$(PYTHON) -c "import py_compile; py_compile.compile(\"$<\", doraise=True)"
|
|
|
|
ifeq ($(PYTHON_VERSION),3)
|
|
$(PY_INSTALL_DIR_PY)/__pycache__/%.$(PY_CPYTHON_PREFIX).pyc: __pycache__/%.$(PY_CPYTHON_PREFIX).pyc
|
|
else
|
|
$(PY_INSTALL_DIR_PY)/%.pyc: %.pyc
|
|
endif
|
|
$(INSTALL) -p -m $(PYMODMODE) -o $(PYMODOWNER) -g $(PYMODGROUP) $< $@
|
|
|
|
check:
|
|
$(PY_MYPY) $(shell /bin/bash $(JWB_SCRIPT_DIR)/scm.sh ls-files | grep '\.py$$')
|