"make check" fails on Kali Linux, because the machinery lacks pieces:
- Add mypy, yapf3, python3-pyright to project.conf for Debian. The pyright package is not in upstream Kali, but is now supplied by the jw-foss repo.- ifdef ruff out from "make check" in py-topdir.mk, because it's too much work to get that to work from packages on Kali Linux for now.project.conf, py-topdir.mk: Make Kali work
Signed-off-by: Jan Lindemann <jan@janware.com>
55 lines
1.7 KiB
Makefile
55 lines
1.7 KiB
Makefile
TD_COPY_FILES += pyproject.toml
|
|
TD_GENERATE_FILES += pyrightconfig.json
|
|
|
|
PY_CHECK_EXCLUDE ?=
|
|
PY_SRC_ROOT += $(wildcard $(TOPDIR)/src $(TOPDIR)/tools)
|
|
|
|
ifndef PY_CHECK_RUFF
|
|
PY_CHECK_RUFF := $(shell which ruff 2>/dev/null)
|
|
endif
|
|
|
|
ifndef PY_CHECK_YAPF
|
|
PY_CHECK_YAPF := $(firstword $(wildcard /usr/bin/yapf /usr/bin/yapf3))
|
|
endif
|
|
|
|
all:
|
|
|
|
format: py-format
|
|
check-syntax: py-check-syntax
|
|
check-format: py-check-format
|
|
|
|
py-check: py-check-syntax py-check-format
|
|
py-check-syntax:
|
|
ifneq ($(PY_CHECK_RUFF),)
|
|
$(PY_CHECK_RUFF) check $(addprefix --exclude ,$(PY_CHECK_EXCLUDE)) $(PY_SRC_ROOT)
|
|
endif
|
|
mypy $(addprefix --exclude ,$(PY_CHECK_EXCLUDE)) $(PY_SRC_ROOT)
|
|
pyright
|
|
|
|
py-check-format:
|
|
ifneq ($(PY_CHECK_YAPF),)
|
|
$(PY_CHECK_YAPF) --diff --recursive .
|
|
endif
|
|
|
|
py-format:
|
|
find . -type f -name '*.py' -print0 | \
|
|
xargs -0 sed -i -E '1{/^# -\*- coding: utf-8 -\*-$$/{:a;N;/\n[[:space:]]*$$/ba;s/^# -\*- coding: utf-8 -\*-\n([[:space:]]*\n)*/ /;s/^ //}}'
|
|
ifneq ($(PY_CHECK_YAPF),)
|
|
$(PY_CHECK_YAPF) --in-place --recursive .
|
|
endif
|
|
|
|
py-format-assignments:
|
|
find . \
|
|
-path './.git' -prune -o \
|
|
-type f -name '*.py' \
|
|
-execdir /usr/bin/sed -i 's/^\(\s\+[a-zA-Z0-9_]\+\)=\([^,[:space:]]\+\)\([,(]\)*\s*$$/\1 = \2\3/g' {} '+'
|
|
git diff --exit-code
|
|
|
|
clean.topdir: clean.py-check
|
|
clean.py-check:
|
|
rm -rf .mypy_cache
|
|
|
|
pyrightconfig.json:
|
|
$(PYTHON) $(JWB_SCRIPT_DIR)/jw-pkg.py -p $(PROJECTS_DIR) -t $(TOPDIR) --topdir-format unaltered projects create-file --format pyright \
|
|
$(PROJECT) --field base=$(JW_PKG_CONF_BASE_DIR)/project/pyrightconfig-base.json $(addprefix --field include=,$(wildcard src/python tools/python)) > $@.tmp
|
|
mv $@.tmp $@
|