anki/qt/dmypy.py
Damien Elmes f842ab7c9d switch convenience symlinks to .bazel/
Unfortunately 5efaf5a4be broke the Svelte
language tools - presumably having paths outside of the repo is confusing
them.

As a plan B, the symlinks have been shifted to a single subdir. Along
with some exclusions in the VS Code config, this should allow VS Code
to continue to work out of the box, but the docs will need updating
to reflect the extra work required for PyCharm/IntelliJ.

+ fix svelte-check execution on a system without node installed. It
still throws up some errors that are presumably caused by our multiple
rootDirs - not sure if there's an easy way to work around that.
2022-01-24 11:06:02 +10:00

45 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/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/bin/qt/dmypy.runfiles/ankidesktop/pylib/anki",
".bazel/bin/qt/dmypy.runfiles/ankidesktop/qt/aqt",
"--python-executable",
os.path.abspath("python/stubs/extendsitepkgs"),
],
env={
"MYPYPATH": ".bazel/bin/qt/dmypy.runfiles/pyqt6",
"EXTRA_SITE_PACKAGES": os.path.abspath(os.getenv("EXTRA_SITE_PACKAGES")),
},
cwd=workspace,
).returncode:
sys.exit(1)