diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a7f183a..efaa0ca 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -155,7 +155,7 @@ repos: types: [python] - 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: '^screen_locker/.*\.py$' pass_filenames: false diff --git a/pyproject.toml b/pyproject.toml index 21a6473..04fb5b0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,7 +8,7 @@ requires-python = ">=3.10" # also used by diet_guard; here for phone-workout GitHub sync (Workstream C) dependencies = [ "gatelock @ git+https://github.com/kuhyx/utils@gatelock-v0.4.0#subdirectory=gatelock", - "crdt-sync @ git+https://github.com/kuhyx/utils@crdt-sync-v0.1.0#subdirectory=crdt-sync", + "crdt-sync @ git+https://github.com/kuhyx/utils@crdt-sync-v0.3.0#subdirectory=crdt-sync", ] [project.scripts] @@ -152,6 +152,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 `scripts/verify_screen_fits.py` resolved `screen_locker` 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 86b27f9..eb46d4a 100755 --- a/scripts/verify_screen_fits.py +++ b/scripts/verify_screen_fits.py @@ -18,7 +18,12 @@ whole ``tk`` module for every test so the suite can never reach a display, and widget heights can only be measured by really rendering them. Like ``verify_lock_popup_safety.py``, this re-executes itself under Xvfb: - python3 ~/screen-locker/scripts/verify_screen_fits.py + cd ~/screen-locker && python3 -m scripts.verify_screen_fits + +Run as a *module*, not a path: ``-m`` puts the repo root on ``sys.path`` so +``screen_locker`` resolves from the checkout. Running it as a path only works +where the package happens to be pip-installed, which is why it passed here and +died in CI. """ from __future__ import annotations @@ -88,9 +93,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