|
6 | 6 | __author__ = 'Simon Robinson'
|
7 | 7 | __copyright__ = 'Copyright (c) 2024 Simon Robinson'
|
8 | 8 | __license__ = 'Apache 2.0'
|
9 |
| -__version__ = '2024-07-08' # ISO 8601 (YYYY-MM-DD) |
| 9 | +__version__ = '2024-07-29' # ISO 8601 (YYYY-MM-DD) |
10 | 10 | __package_version__ = '.'.join([str(int(i)) for i in __version__.split('-')]) # for pyproject.toml usage only
|
11 | 11 |
|
12 | 12 | import abc
|
@@ -99,14 +99,22 @@ class Icon:
|
99 | 99 | except ImportError as gui_requirement_import_error:
|
100 | 100 | MISSING_GUI_REQUIREMENTS.append(gui_requirement_import_error)
|
101 | 101 |
|
102 |
| -with warnings.catch_warnings(): |
103 |
| - warnings.simplefilter('ignore', DeprecationWarning) |
| 102 | +try: |
| 103 | + # pylint: disable-next=ungrouped-imports |
| 104 | + import importlib.metadata as importlib_metadata # get package version numbers - available in stdlib from python 3.8 |
| 105 | +except ImportError: |
104 | 106 | try:
|
105 |
| - # noinspection PyDeprecation,PyUnresolvedReferences |
106 |
| - import pkg_resources # from setuptools - to change to importlib.metadata and packaging.version once min. is 3.8 |
| 107 | + # noinspection PyUnresolvedReferences |
| 108 | + import importlib_metadata |
107 | 109 | except ImportError as gui_requirement_import_error:
|
108 | 110 | MISSING_GUI_REQUIREMENTS.append(gui_requirement_import_error)
|
109 | 111 |
|
| 112 | +try: |
| 113 | + # noinspection PyUnresolvedReferences |
| 114 | + import packaging.version # parse package version numbers - used to work around various GUI-only package issues |
| 115 | +except ImportError as gui_requirement_import_error: |
| 116 | + MISSING_GUI_REQUIREMENTS.append(gui_requirement_import_error) |
| 117 | + |
110 | 118 | # for macOS-specific functionality
|
111 | 119 | if sys.platform == 'darwin':
|
112 | 120 | try:
|
@@ -2696,13 +2704,12 @@ def macos_nsworkspace_notification_listener_(self, notification):
|
2696 | 2704 | # noinspection PyDeprecation
|
2697 | 2705 | def create_icon(self):
|
2698 | 2706 | # fix pystray <= 0.19.4 incompatibility with PIL 10.0.0+; resolved in 0.19.5 and later via pystray PR #147
|
2699 |
| - with warnings.catch_warnings(): |
2700 |
| - warnings.simplefilter('ignore', DeprecationWarning) |
2701 |
| - pystray_version = pkg_resources.get_distribution('pystray').version |
2702 |
| - pillow_version = pkg_resources.get_distribution('pillow').version |
2703 |
| - if pkg_resources.parse_version(pystray_version) <= pkg_resources.parse_version('0.19.4') and \ |
2704 |
| - pkg_resources.parse_version(pillow_version) >= pkg_resources.parse_version('10.0.0'): |
2705 |
| - Image.ANTIALIAS = Image.LANCZOS if hasattr(Image, 'LANCZOS') else Image.Resampling.LANCZOS |
| 2707 | + pystray_version = packaging.version.Version(importlib_metadata.version('pystray')) |
| 2708 | + pillow_version = packaging.version.Version(importlib_metadata.version('pillow')) |
| 2709 | + if pystray_version <= packaging.version.Version('0.19.4') and \ |
| 2710 | + pillow_version >= packaging.version.Version('10.0.0'): |
| 2711 | + Image.ANTIALIAS = Image.LANCZOS if hasattr(Image, 'LANCZOS') else Image.Resampling.LANCZOS |
| 2712 | + |
2706 | 2713 | icon_class = RetinaIcon if sys.platform == 'darwin' else pystray.Icon
|
2707 | 2714 | return icon_class(APP_NAME, App.get_image(), APP_NAME, menu=pystray.Menu(
|
2708 | 2715 | pystray.MenuItem('Servers and accounts', pystray.Menu(self.create_config_menu)),
|
@@ -2763,9 +2770,7 @@ def get_icon_size(text, font_size):
|
2763 | 2770 | font = ImageFont.truetype(io.BytesIO(zlib.decompress(base64.b64decode(APP_ICON))), size=font_size)
|
2764 | 2771 |
|
2765 | 2772 | # pillow's getsize method was deprecated in 9.2.0 (see docs for PIL.ImageFont.ImageFont.getsize)
|
2766 |
| - # noinspection PyDeprecation |
2767 |
| - if pkg_resources.parse_version( |
2768 |
| - pkg_resources.get_distribution('pillow').version) < pkg_resources.parse_version('9.2.0'): |
| 2773 | + if packaging.version.Version(importlib_metadata.version('pillow')) < packaging.version.Version('9.2.0'): |
2769 | 2774 | font_width, font_height = font.getsize(text)
|
2770 | 2775 | return font, font_width, font_height
|
2771 | 2776 |
|
@@ -2906,11 +2911,9 @@ def create_authorisation_window(self, request):
|
2906 | 2911 | setattr(authorisation_window, 'get_title', lambda window: window.title) # add missing get_title method
|
2907 | 2912 |
|
2908 | 2913 | # pywebview 3.6+ moved window events to a separate namespace in a non-backwards-compatible way
|
2909 |
| - # noinspection PyDeprecation |
2910 |
| - pywebview_version = pkg_resources.parse_version(pkg_resources.get_distribution('pywebview').version) |
| 2914 | + pywebview_version = packaging.version.Version(importlib_metadata.version('pywebview')) |
2911 | 2915 | # the version zero check is due to a bug in the Ubuntu 24.04 python-pywebview package - see GitHub #242
|
2912 |
| - # noinspection PyDeprecation |
2913 |
| - if pkg_resources.parse_version('0') < pywebview_version < pkg_resources.parse_version('3.6'): |
| 2916 | + if packaging.version.Version('0') < pywebview_version < packaging.version.Version('3.6'): |
2914 | 2917 | # noinspection PyUnresolvedReferences
|
2915 | 2918 | authorisation_window.loaded += self.authorisation_window_loaded
|
2916 | 2919 | else:
|
|
0 commit comments