From 31600f4202605327a6e871d4148f40054eee0271 Mon Sep 17 00:00:00 2001 From: Philipp Wolfer Date: Tue, 12 Sep 2023 13:33:35 +0200 Subject: [PATCH] PICARD-2751: Restore the ability to load compiled .pyc plugins --- picard/pluginmanager.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/picard/pluginmanager.py b/picard/pluginmanager.py index 3ffbcb9f39..0c9d9b8125 100644 --- a/picard/pluginmanager.py +++ b/picard/pluginmanager.py @@ -639,10 +639,13 @@ def _spec_from_zip(self, fullname, file_path): @staticmethod def _plugin_file_paths(plugin_dir, plugin_name): - yield os.path.join(plugin_dir, plugin_name, '__init__.py') - yield os.path.join(plugin_dir, plugin_name + '.py') - if hasattr(zipimport.zipimporter, 'find_spec'): # Python >= 3.10 - yield os.path.join(plugin_dir, plugin_name + '.zip') + for entry in _PACKAGE_ENTRIES: + yield os.path.join(plugin_dir, plugin_name, entry) + for ext in _FILEEXTS: + # On Python < 3.10 ZIP file loading is handled in PluginManager._load_plugin + if ext == '.zip' and not hasattr(zipimport.zipimporter, 'find_spec'): + continue + yield os.path.join(plugin_dir, plugin_name + ext) sys.meta_path.append(PluginMetaPathFinder())