Commit graph jw-pkg/make/py-topdir.mk
Author SHA1 Message Date
eea3e5f14b
py-check.mk: Add file
Add py-check.mk and use it from py-topdir.mk and py-rules.mk. This
removes redundant check definitions, making sure that that checks run
from a repo's subdirectory match the checks run from its toplevel
directory.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-07-24 13:28:59 +02:00
36af4a590f
py-xxx.mk: Clean more python tool caches
All checks were successful
CI / Packaging - Kali Linux (pull_request) Successful in 4m6s
CI / Packaging - OpenSUSE Tumbleweed (pull_request) Successful in 4m6s
CI / Packaging test (pull_request) Successful in 0s
CI / Packaging - Kali Linux (push) Successful in 4m2s
CI / Packaging - OpenSUSE Tumbleweed (push) Successful in 3m54s
CI / Packaging test (push) Successful in 0s
.mypy_cache, .ruff_cache and .pytest_cache are not consistently
cleaned in all subdirectories. Fix that.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-07-22 14:41:38 +02:00
193c2ee0bd
py-topdir.mk: PY_CHECK_ROOTS: Don't += assign
py-topdir.mk has this:

  ifndef PY_CHECK_ROOTS
    PY_CHECK_ROOTS += ...
  endif

That is too involved: Either PY_CHECK_ROOTS is defined, then nothing
is appended, or it's undefined, then a simple "=" would be just fine.
Use that instead.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-07-22 12:34:05 +02:00
c8fc6326cb
py-topdir.mk: Use pythonpath --prefix for mypy_path
Make use of the newly introduced --prefix option to the pythonpath
command, and generate what's subseqently used to fill in mypy_path in
pyproject.toml.

By decoupling it from PYTHONPATH, this commit makes the creation of
mypy_path less involved and easier to understand. It also obviates
the need replace the relatively heavy ldlibpath.mk by the relatively
lightweight projects.mk, thereby enhancing performance.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-06-11 12:18:37 +02:00
850efda804
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>
2026-06-09 07:52:15 +02:00
9ba6c70dee
py-topdir.mk: Add --config pyproject.toml
ruff tries to recursivley use every config file it finds and stumbles
over a template:

  /usr/bin/ruff check --select TC,FA --fix --unsafe-fixes .
  ruff failed
    Cause: Failed to parse /home/jan/local/src/jw.dev/proj/jw-pkg/conf/templates/pyproject.toml
    Cause: TOML parse error at line 3, column 3
    |
  3 |   {mypypath}
    |   ^
  invalid key-value pair, expected key

Limiting it to the toplevel pyproject.toml by explicitly specifying
--config fixes the behaviour, so that's what this commit does.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-06-09 07:47:06 +02:00
0b558635a8
py-topdir.mk: Introduce $(PY_CHECK_ROOTS)
Replace variable PY_SRC_ROOT by PY_CHECK_ROOTS. The name PY_SRC_ROOT
was a bad choice, given that it isn't immediately obvious that it a)
can contain multiple root locations to be checked, and that it b)
specifically concerns static type checking.

As of this commit, it's possible to limit the type checking scope
with PY_CHECK_ROOTS as in

  PY_CHECK_ROOTS="src/python/jw/pkg/CmdBase.py src/python/jw/lib" \
    make check

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-06-09 07:45:15 +02:00
b2f0fe2595
py-topdir.mk: Make pyright optional
Be prepared to not have working pyright. This is necessary, because
the next commit will remove it for Debian.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-06-04 23:14:49 +02:00
fdabca79e8
py-topdir.mk: py-format|check-annotation-imports
Add two new targets, basically

  py-check-annotation-imports:
    ruff check --select TC,FA --fix --unsafe-fixes .

  py-format-annotation-imports:
    ruff format --select TC,FA --fix --unsafe-fixes .

They basically import statements merely used for annotation
only during type checking runs:

  if TYPE_CHECKING:
    import AirFrobnicator from frobnication

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-06-03 17:46:14 +02:00
f1456f1d46
project.conf, py-topdir.mk: Fix check target for Kali
"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>
2026-06-02 17:52:07 +02:00
5a1ef45cc0
topdir.mk: Fix: make topdir does only half a job
make topdir doesn't reliably regenerate pyrightconfig.json because of
.SECONDEXPANSION. Adding a second dollar symbol $$(TD_GENERATE_FILES)
solves the problem.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-06-01 14:33:52 +02:00
8c5c98c95a
py-topdir.mk: Use pyright
py-topdir.mk: Use ruff and yapf

  - Use pyright for the target py-check-syntax

  - Generate a $(TOPDIR)/pyrightconfig.json for that

  - Add pyrightconfig-base.json because it's used by
    pyrightconfig.json

  - Add python3-pyright to pkg.requires.release, anticipating the use
    of the py-syntax-check target by CI

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-05-31 18:20:37 +02:00
36d854ce19
py-topdir.mk: Use ruff and yapf
- Use ruff and yapf for the targets py-check-syntax, py-format and
    py-check-format.

  - Add a pyproject.toml for those. It also includes configuration
    for isort, albeit not being directly used in the linter targets.

  - Make .gitignore igore that in newly created projects.

  - Add ruff, yapf and isort to pkg.requires.release, anticipating
    their use by CI.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-05-31 18:20:36 +02:00
22b09dd9aa
py-topdir.mk: Add file
Add a file to be included from every toplevel Makefile of every repo
that owns Python code. It defines the following targets:

  py-check: py-check-syntax py-check-format
  py-check-syntax:
  py-check-format:
  py-format:

Currently, only mypy is run from py-check-syntax, but the targets are
meant as entry point for further linter jobs in the future.

There's also

  py-format-assignments:

which is meant to add spaces around "=" in multi-line assignment
blocks, but, pending future experiments, I thing that target is going
to be removed again. Left in for now.

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-05-31 18:20:35 +02:00