diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 25642f3..6dfb3d1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -141,7 +141,7 @@ repos: types: [shell] - id: screens-fit name: Every lock screen fits 1366x768 (no scrolling required) - entry: python3 scripts/verify_screen_fits.py + entry: python3 -m scripts.verify_screen_fits language: system files: '^wake_alarm/.*\.py$' pass_filenames: false diff --git a/pyproject.toml b/pyproject.toml index 72d11ab..2354ce2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -95,6 +95,12 @@ color_output = true exclude = [".venv/"] [tool.pylint.main] +# The repo root on the path, so a file outside the package (scripts/) can be +# linted on its own. pylint otherwise infers the path from the files it is +# given, so a script resolved its package imports only when a package file +# happened to be in the same batch -- passing or failing by what else was +# staged. +init-hook = "import sys; sys.path.insert(0, '.')" analyse-fallback-blocks = true persistent = true jobs = 0 diff --git a/scripts/verify_screen_fits.py b/scripts/verify_screen_fits.py index 1c8993b..bb1baec 100755 --- a/scripts/verify_screen_fits.py +++ b/scripts/verify_screen_fits.py @@ -12,7 +12,12 @@ Runs the real builders against a real (throwaway) X display, because widget heights come from the font engine and nothing short of rendering can answer this honestly: - python3 ~/wake-alarm/scripts/verify_screen_fits.py + cd ~/wake-alarm && python3 -m scripts.verify_screen_fits + +Run as a *module*, not a path: ``-m`` puts the repo root on +``sys.path`` so ``wake_alarm`` resolves from the checkout. Running it as a +path only works where the package happens to be pip-installed, which is +why it passed locally and died in CI. """ from __future__ import annotations @@ -71,9 +76,11 @@ def reexec_under_xvfb() -> int: "-s", "-screen 0 1600x1200x24", sys.executable, - str(Path(__file__).resolve()), + "-m", + "scripts.verify_screen_fits", ], check=False, + cwd=Path(__file__).resolve().parent.parent, env=env, ).returncode