From 0d88c2f7c93dbb41374aa5c5418b19a5eaf70317 Mon Sep 17 00:00:00 2001 From: Alexey Sheplyakov Date: Wed, 28 Dec 2022 18:57:01 +0400 Subject: [PATCH] wxui: support python 3.9 I get the following exception on start: $ python3 chirpwx.py Traceback (most recent call last): File "/home/asheplyakov/work/radio/chirp/chirpwx.py", line 8, in sys.exit(chirpmain()) File "/home/asheplyakov/work/radio/chirp/chirp/wxui/__init__.py", line 41, in chirpmain from chirp.wxui import main File "/home/asheplyakov/work/radio/chirp/chirp/wxui/main.py", line 28, in import importlib_resources ModuleNotFoundError: No module named 'importlib_resources' $ python3 --version Python 3.9.6 However importlib is available in Python 3.9 (as a part of the standard library). To avoid the problem this patch removes the version check, and checks for importlib_resources/importlib.resources modules instead. --- chirp/wxui/__init__.py | 4 ++-- chirp/wxui/main.py | 4 ++-- setup.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/chirp/wxui/__init__.py b/chirp/wxui/__init__.py index ad01db3b5..c14702967 100644 --- a/chirp/wxui/__init__.py +++ b/chirp/wxui/__init__.py @@ -5,9 +5,9 @@ import os import sys -if sys.version_info < (3, 10): +try: import importlib_resources -else: +except ModuleNotFoundError: import importlib.resources as importlib_resources from chirp import directory diff --git a/chirp/wxui/main.py b/chirp/wxui/main.py index 88f5a50a6..55b0607db 100644 --- a/chirp/wxui/main.py +++ b/chirp/wxui/main.py @@ -24,9 +24,9 @@ import time import webbrowser -if sys.version_info < (3, 10): +try: import importlib_resources -else: +except ModuleNotFoundError: import importlib.resources as importlib_resources import wx diff --git a/setup.py b/setup.py index 3d5dafdc6..cb98aa333 100644 --- a/setup.py +++ b/setup.py @@ -15,7 +15,7 @@ 'pyserial', 'six', 'future', - 'importlib-resources;python_version<"3.10"', + 'importlib-resources;python_version<"3.9"', 'yattag', ], extras_require={