From 37aed891c464e5bf06cac703eb6dba8b192f30bd Mon Sep 17 00:00:00 2001 From: coletdjnz Date: Sat, 30 Nov 2024 14:01:44 +1300 Subject: [PATCH] fix no-external not including PYTHONPATH --- yt_dlp/plugins.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/yt_dlp/plugins.py b/yt_dlp/plugins.py index baeafeba7..d91ebf2ef 100644 --- a/yt_dlp/plugins.py +++ b/yt_dlp/plugins.py @@ -109,9 +109,17 @@ def external_plugin_paths(): containing_folder='yt-dlp-plugins', ) - # Load from PYTHONPATH folders + yield from internal_plugin_paths() + + +def internal_plugin_paths(): + # Always try load from PYTHONPATH folders yield from (path for path in map(Path, sys.path) if path != _BASE_PACKAGE_PATH) - # yield from _get_package_paths(*sys.path, containing_folder='') + + +def candidate_plugin_paths(candidate): + yield from Path(candidate).iterdir() + yield from internal_plugin_paths() class PluginFinder(importlib.abc.MetaPathFinder): @@ -131,8 +139,9 @@ class PluginFinder(importlib.abc.MetaPathFinder): ) def search_locations(self, fullname): + candidate_locations = itertools.chain.from_iterable( - external_plugin_paths() if candidate == 'external' else Path(candidate).iterdir() + external_plugin_paths() if candidate == 'external' else candidate_plugin_paths(candidate) for candidate in plugin_dirs.value )