From 97efd49cd8db15a84d2ae2701d21b8283e37bc8c Mon Sep 17 00:00:00 2001 From: Escape0707 Date: Fri, 5 Apr 2024 21:12:06 +0900 Subject: [PATCH] Ignore exception raised by pip_system_certs not found (#3114) This dependency usually doesn't benefit Linux distros with requests library configured to use system certificate already. And is not packaged by most distros. Making it optional will make most Linux users' installation much easier. --- CONTRIBUTORS | 1 + qt/aqt/__init__.py | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index c7d00dc62..f953dbd16 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -170,6 +170,7 @@ laalsaas ijqq AntoineQ1 jthulhu +Escape0707 ******************** The text of the 3 clause BSD license follows: diff --git a/qt/aqt/__init__.py b/qt/aqt/__init__.py index b6d24080b..3b8872448 100644 --- a/qt/aqt/__init__.py +++ b/qt/aqt/__init__.py @@ -6,7 +6,12 @@ from __future__ import annotations import logging import sys -import pip_system_certs.wrapt_requests +try: + import pip_system_certs.wrapt_requests +except ModuleNotFoundError: + print( + "Python module pip_system_certs is not installed. System certificate store and custom SSL certificates may not work. See: https://github.com/ankitects/anki/issues/3016" + ) if sys.version_info[0] < 3 or sys.version_info[1] < 9: raise Exception("Anki requires Python 3.9+")