2021-04-14 10:06:16 +02:00
|
|
|
# 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"])
|
2022-01-24 02:06:02 +01:00
|
|
|
binroot = workspace / ".bazel/bin"
|
2022-01-23 11:17:08 +01:00
|
|
|
dmypy_bin = binroot / "external/py_deps_mypy/rules_python_wheel_entry_point_dmypy"
|
2021-04-14 10:06:16 +02:00
|
|
|
|
|
|
|
if sys.platform.startswith("win32"):
|
|
|
|
binext = ".exe"
|
|
|
|
else:
|
|
|
|
binext = ""
|
|
|
|
|
|
|
|
if subprocess.run(
|
|
|
|
[
|
2021-10-30 01:06:01 +02:00
|
|
|
str(dmypy_bin) + binext,
|
2021-04-14 10:06:16 +02:00
|
|
|
]
|
|
|
|
+ [
|
|
|
|
"run",
|
|
|
|
"--",
|
|
|
|
"--config-file",
|
|
|
|
"qt/mypy.ini",
|
2022-01-24 02:06:02 +01:00
|
|
|
".bazel/bin/qt/dmypy.runfiles/ankidesktop/pylib/anki",
|
|
|
|
".bazel/bin/qt/dmypy.runfiles/ankidesktop/qt/aqt",
|
2021-06-16 08:04:59 +02:00
|
|
|
"--python-executable",
|
2021-10-30 01:06:01 +02:00
|
|
|
os.path.abspath("python/stubs/extendsitepkgs"),
|
2021-04-14 10:06:16 +02:00
|
|
|
],
|
2021-05-05 07:54:41 +02:00
|
|
|
env={
|
2022-01-24 02:06:02 +01:00
|
|
|
"MYPYPATH": ".bazel/bin/qt/dmypy.runfiles/pyqt6",
|
2021-06-16 08:04:59 +02:00
|
|
|
"EXTRA_SITE_PACKAGES": os.path.abspath(os.getenv("EXTRA_SITE_PACKAGES")),
|
2021-05-05 07:54:41 +02:00
|
|
|
},
|
2021-04-14 11:11:01 +02:00
|
|
|
cwd=workspace,
|
2021-04-14 10:06:16 +02:00
|
|
|
).returncode:
|
|
|
|
sys.exit(1)
|