Anki/qt/dmypy.py
Damien Elmes e986304592 replace some bazel-bin references in our scripts
+ fix scripts/mypy-watch, and make it only listen to change events
2022-01-23 20:17:08 +10:00

44 lines
1.1 KiB
Python
Executable file

# Copyright: Ankitects Pty Ltd and contributors
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
"""
Helper to run mypy in daemon mode. See development.md. Windows is not
currently supported.
"""
import os
import subprocess
import sys
import time
from pathlib import Path
workspace = Path(os.environ["BUILD_WORKSPACE_DIRECTORY"])
binroot = workspace / "../bazel/anki/bin"
dmypy_bin = binroot / "external/py_deps_mypy/rules_python_wheel_entry_point_dmypy"
if sys.platform.startswith("win32"):
binext = ".exe"
else:
binext = ""
if subprocess.run(
[
str(dmypy_bin) + binext,
]
+ [
"run",
"--",
"--config-file",
"qt/mypy.ini",
"../bazel/anki/bin/qt/dmypy.runfiles/ankidesktop/pylib/anki",
"../bazel/anki/bin/qt/dmypy.runfiles/ankidesktop/qt/aqt",
"--python-executable",
os.path.abspath("python/stubs/extendsitepkgs"),
],
env={
"MYPYPATH": "../bazel/anki/bin/qt/dmypy.runfiles/pyqt6",
"EXTRA_SITE_PACKAGES": os.path.abspath(os.getenv("EXTRA_SITE_PACKAGES")),
},
cwd=workspace,
).returncode:
sys.exit(1)