Hmm I don’t know, I explained this to users on the add-on page, so I think they didn’t report the problem to me. When I developed it the app was detected as a virus on my device, but after that some users said they didn’t have any problems, so maybe it will go undetected after several days.
If I remember correctly this is a common problem with pyinstaller. Many developers use pyinstaller because it is convenient, but malware also uses it so antivirus software detects apps built with pyinstaller. There may be a few ways to avoid detection but malware also uses them so they become unusable, so I think the only reliable workaround is code signing.
Another strange way, maybe possible to run the program using the Python executable file of uv?
sys.executable in uv returns the path to the Python executable file (e.g. ...AnkiProgramFiles\.venv\Scripts\pythonw.exe ). When this Python is used to execute a .py file, it seems to launch a new instance of Python and Qt used by Anki. This Python continues to run even when Anki is closed, like a normal app, so Anki can be restarted. (in short there is no need to build .py with PyInstaller)
e.g.
def make_mini_console(*args, **kwargs):
import subprocess
import sys
import os
script_path = os.path.join(os.path.dirname(__file__), "restart_anki.py")
print("script_path:", script_path)
maybe_python = sys.executable
if not "python" in os.path.basename(maybe_python).lower():
return
creationflags = 0
if sys.platform == "win32":
creationflags = (
subprocess.CREATE_NEW_PROCESS_GROUP | subprocess.DETACHED_PROCESS
)
subprocess.Popen(
[maybe_python, script_path],
start_new_session=True,
stdin=subprocess.DEVNULL,
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
creationflags=creationflags,
)
Advantages:
It is possible to develop add-ons that run after Anki is closed. (e.g. AnkiRestart, AnkiConnect that works even after Anki is closed)
It is possible to develop add-ons with separate UI event loops. e.g. Console: When I developed a console add-on the UI froze due to Anki UI. Using this way the UI will be updated even if Anki’s UI freezes, and the program will not close even if Anki is restarted.
Disadvantages:
not sure if it works cross platform.
not sure if sys.executable will reliably return the Python path.
Perhaps this is not the intended use of Anki or UV, so unexpected problems may occur. (it looks the same to me as using normal Python)
If this works without code signing it seems likely that there will be high security risks. (e.g. the program may continue to run in the background after the user closes Anki. but I think existing add-ns also have almost the same risk when Anki is running.)
If an unexpected error occurs users may not be able to close the program.