2021-04-13 10:45:05 +02:00
|
|
|
# Copyright: Ankitects Pty Ltd and contributors
|
|
|
|
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|
|
|
|
2020-11-01 05:26:58 +01:00
|
|
|
import os
|
|
|
|
import subprocess
|
|
|
|
import sys
|
2021-12-10 01:46:38 +01:00
|
|
|
import tempfile
|
|
|
|
from pathlib import Path
|
2020-11-01 05:26:58 +01:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2021-06-16 08:04:59 +02:00
|
|
|
(module, ini, pyqt_init, extendsitepkgs) = sys.argv[1:]
|
2020-11-01 05:26:58 +01:00
|
|
|
ini = os.path.abspath(ini)
|
|
|
|
pyqt_init = os.path.abspath(pyqt_init)
|
|
|
|
pyqt_folder = os.path.dirname(pyqt_init)
|
2021-06-16 08:04:59 +02:00
|
|
|
extendsitepkgs = os.path.abspath(extendsitepkgs)
|
|
|
|
extra_site = os.path.abspath(os.getenv("EXTRA_SITE_PACKAGES"))
|
2020-11-01 05:26:58 +01:00
|
|
|
|
|
|
|
folder = os.path.join(os.path.dirname(__file__), "..")
|
|
|
|
os.chdir(folder)
|
|
|
|
|
|
|
|
if sys.platform.startswith("win32"):
|
|
|
|
mypy_path = ".;..\\pylib;" + pyqt_folder
|
|
|
|
else:
|
|
|
|
mypy_path = ".:../pylib:" + pyqt_folder
|
|
|
|
|
2021-06-16 08:04:59 +02:00
|
|
|
os.environ["EXTRA_SITE_PACKAGES"] = extra_site
|
|
|
|
|
|
|
|
args = [
|
|
|
|
sys.executable,
|
|
|
|
"-m",
|
|
|
|
"mypy",
|
|
|
|
module,
|
|
|
|
"--config-file",
|
|
|
|
ini,
|
2021-12-10 01:46:38 +01:00
|
|
|
"--cache-dir",
|
|
|
|
Path(tempfile.gettempdir()) / ".mypy-anki-qt",
|
|
|
|
"--sqlite-cache",
|
2021-06-16 08:04:59 +02:00
|
|
|
"--python-executable",
|
|
|
|
extendsitepkgs,
|
|
|
|
]
|
2020-11-01 05:26:58 +01:00
|
|
|
|
|
|
|
if sys.platform.startswith("win32"):
|
|
|
|
# bazel passes in \\?\c:\... path; mypy can't handle it, so we
|
|
|
|
# strip off prefix
|
|
|
|
for entry in sys.path:
|
2022-01-15 07:09:50 +01:00
|
|
|
if entry.endswith("deps_mypy"):
|
2020-11-01 05:26:58 +01:00
|
|
|
typeshed = entry[4:] + "\\mypy\\typeshed"
|
|
|
|
args.append("--custom-typeshed-dir")
|
|
|
|
args.append(typeshed)
|
|
|
|
|
|
|
|
sys.exit(subprocess.run(args, check=False).returncode)
|