diff --git a/.mypy.ini b/.mypy.ini index 5a097cff3..9fb8d3689 100644 --- a/.mypy.ini +++ b/.mypy.ini @@ -165,3 +165,5 @@ ignore_missing_imports = True ignore_missing_imports = True [mypy-pip_system_certs.*] ignore_missing_imports = True +[mypy-anki_audio] +ignore_missing_imports = True diff --git a/qt/aqt/__init__.py b/qt/aqt/__init__.py index 80c4dd081..6645e3599 100644 --- a/qt/aqt/__init__.py +++ b/qt/aqt/__init__.py @@ -3,9 +3,9 @@ from __future__ import annotations -import os import atexit import logging +import os import sys from collections.abc import Callable from typing import TYPE_CHECKING, Any, Union, cast @@ -46,7 +46,6 @@ import builtins import cProfile import getpass import locale -import os import tempfile import traceback from pathlib import Path diff --git a/qt/aqt/_macos_helper.py b/qt/aqt/_macos_helper.py index 482693384..9328b1c4a 100644 --- a/qt/aqt/_macos_helper.py +++ b/qt/aqt/_macos_helper.py @@ -14,9 +14,7 @@ import aqt.utils class _MacOSHelper: def __init__(self) -> None: - path = os.path.join( - aqt.utils.aqt_data_folder(), "lib", "libankihelper.dylib" - ) + path = os.path.join(aqt.utils.aqt_data_folder(), "lib", "libankihelper.dylib") self._dll = CDLL(path) self._dll.system_is_dark.restype = c_bool diff --git a/qt/aqt/package.py b/qt/aqt/package.py index f12cfa6d8..96cfe4b23 100644 --- a/qt/aqt/package.py +++ b/qt/aqt/package.py @@ -4,13 +4,17 @@ """Helpers for the packaged version of Anki.""" from __future__ import annotations -from pathlib import Path + import subprocess +from pathlib import Path + from anki.utils import is_mac + +# pylint: disable=unused-import def first_run_setup() -> None: """Code run the first time after install/upgrade. - + Currently, we just import our main libraries and invoke mpv/lame on macOS, which is slow on the first run, and doing it this way shows progress being made. @@ -18,32 +22,41 @@ def first_run_setup() -> None: if not is_mac: return - + def _dot(): print(".", flush=True, end="") _dot() import anki.collection + _dot() import PyQt6.sip + _dot() import PyQt6.QtCore + _dot() import PyQt6.QtGui + _dot() import PyQt6.QtNetwork + _dot() import PyQt6.QtQuick + _dot() import PyQt6.QtWebChannel + _dot() import PyQt6.QtWebEngineCore + _dot() import PyQt6.QtWebEngineWidgets + _dot() + import anki_audio import PyQt6.QtWidgets - import anki_audio audio_pkg_path = Path(anki_audio.__file__).parent # Invoke mpv and lame @@ -51,6 +64,6 @@ def first_run_setup() -> None: for cmd_name in ["mpv", "lame"]: _dot() cmd[0] = audio_pkg_path / cmd_name - subprocess.run(cmd, check=True, capture_output=True) + subprocess.run([str(cmd[0]), str(cmd[1])], check=True, capture_output=True) - print() \ No newline at end of file + print() diff --git a/qt/aqt/sound.py b/qt/aqt/sound.py index 50f816964..5753ab234 100644 --- a/qt/aqt/sound.py +++ b/qt/aqt/sound.py @@ -283,19 +283,20 @@ def _packagedCmd(cmd: list[str]) -> tuple[Any, dict[str, str]]: if is_win or is_mac: try: import anki_audio + audio_pkg_path = Path(anki_audio.__file__).parent if is_win: packaged_path = audio_pkg_path / (cmd[0] + ".exe") else: # is_mac packaged_path = audio_pkg_path / cmd[0] - + if packaged_path.exists(): cmd[0] = str(packaged_path) return cmd, env except ImportError: # anki-audio not available, fall back to old behavior pass - + packaged_path = Path(sys.prefix) / cmd[0] if packaged_path.exists(): cmd[0] = str(packaged_path) diff --git a/qt/mac/helper_build.py b/qt/mac/helper_build.py index a119a7fe3..0638c9249 100644 --- a/qt/mac/helper_build.py +++ b/qt/mac/helper_build.py @@ -19,7 +19,7 @@ for arch in architectures: target = f"{arch}-apple-macos11" temp_out = out_dir / f"temp_{arch}.dylib" temp_files.append(temp_out) - + args = [ "swiftc", "-target",