Improve Python config file template substitution #8

Merged
Jan Lindemann merged 10 commits from jan/feature/20260609-pyproject-toml-add-mypypath into master 2026-06-09 08:13:09 +02:00 AGit
2 changed files with 13 additions and 2 deletions
Showing only changes of commit 850efda804 - Show all commits

py-topdir.mk: Add machinery to generate pyproject.toml

pyproject.toml is currently copied unchanged from conf/topdir to the toplevel directory. Set up machinery in py-topdir.mk to render it from a template in conf/templates instead, replacing {mypypath} in the process.

Signed-off-by: Jan Lindemann <jan@janware.com>
Jan Lindemann 2026-06-02 21:22:02 +02:00
Signed by: Jan Lindemann
GPG key ID: 3750640C9E25DD61

View file

@ -1,6 +1,12 @@
TD_COPY_FILES += pyproject.toml include $(JWBDIR)/make/ldlibpath.mk
TD_GENERATE_FILES += pyproject.toml
PY_CHECK_EXCLUDE ?= PY_CHECK_EXCLUDE ?=
MYPY_CONFIG_PATH = $(subst :,:$$MYPY_CONFIG_FILE_DIR/,:$(PYTHONPATH))
MYPY_PATH_DIRECTIVE = mypy_path = "$(MYPY_CONFIG_PATH)"
ifndef PY_CHECK_ROOTS ifndef PY_CHECK_ROOTS
PY_CHECK_ROOTS += $(wildcard $(TOPDIR)/src $(TOPDIR)/tools) PY_CHECK_ROOTS += $(wildcard $(TOPDIR)/src $(TOPDIR)/tools)
endif endif
@ -70,7 +76,12 @@ clean.topdir: clean.py-check
clean.py-check: clean.py-check:
rm -rf .mypy_cache rm -rf .mypy_cache
pyproject.toml:
$(PYTHON) $(JWB_SCRIPT_DIR)/jw-pkg.py -p $(PROJECTS_DIR) -t $(TOPDIR) --topdir-format unaltered projects create-file --format tmpl \
--template-name $@ --search-path $(JW_PKG_CONF_BASE_DIR)/templates --field mypypath='$(MYPY_PATH_DIRECTIVE)' $(PROJECT) > $@.tmp
mv $@.tmp $@
pyrightconfig.json: pyrightconfig.json:
$(PYTHON) $(JWB_SCRIPT_DIR)/jw-pkg.py -p $(PROJECTS_DIR) -t $(TOPDIR) --topdir-format unaltered projects create-file --format pyright \ $(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 --field base=$(JW_PKG_CONF_BASE_DIR)/project/pyrightconfig-base.json $(addprefix --field include=,$(wildcard src/python tools/python)) $(PROJECT) > $@.tmp
mv $@.tmp $@ mv $@.tmp $@