Skip to content

Commit 92c3986

Browse files
committed
plugin manager: use system env paths for discovery
1 parent 0a6e2f8 commit 92c3986

File tree

2 files changed

+19
-10
lines changed

2 files changed

+19
-10
lines changed

src/poetry/console/commands/self/show/plugins.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,10 @@ def _system_project_handle(self) -> int:
4040
}
4141
)
4242

43-
entry_points = (
44-
PluginManager(ApplicationPlugin.group).get_plugin_entry_points()
45-
+ PluginManager(Plugin.group).get_plugin_entry_points()
46-
)
47-
4843
system_env = EnvManager.get_system_env(naive=True)
44+
entry_points = PluginManager(ApplicationPlugin.group).get_plugin_entry_points(
45+
env=system_env
46+
) + PluginManager(Plugin.group).get_plugin_entry_points(env=system_env)
4947
installed_repository = InstalledRepository.load(
5048
system_env, with_dependencies=True
5149
)

src/poetry/plugins/plugin_manager.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,22 @@
11
from __future__ import annotations
22

33
import logging
4+
import sys
45

5-
from typing import Any
6+
from typing import TYPE_CHECKING
67

78
import entrypoints
89

910
from poetry.plugins.application_plugin import ApplicationPlugin
1011
from poetry.plugins.plugin import Plugin
1112

1213

14+
if TYPE_CHECKING:
15+
from typing import Any
16+
17+
from poetry.utils.env import Env
18+
19+
1320
logger = logging.getLogger(__name__)
1421

1522

@@ -23,17 +30,21 @@ def __init__(self, group: str, disable_plugins: bool = False) -> None:
2330
self._disable_plugins = disable_plugins
2431
self._plugins: list[Plugin] = []
2532

26-
def load_plugins(self) -> None:
33+
def load_plugins(self, env: Env | None = None) -> None:
2734
if self._disable_plugins:
2835
return
2936

30-
plugin_entrypoints = self.get_plugin_entry_points()
37+
plugin_entrypoints = self.get_plugin_entry_points(env=env)
3138

3239
for entrypoint in plugin_entrypoints:
3340
self._load_plugin_entrypoint(entrypoint)
3441

35-
def get_plugin_entry_points(self) -> list[entrypoints.EntryPoint]:
36-
return entrypoints.get_group_all(self._group)
42+
def get_plugin_entry_points(
43+
self, env: Env | None = None
44+
) -> list[entrypoints.EntryPoint]:
45+
return entrypoints.get_group_all(
46+
self._group, path=env.sys_path if env else sys.path
47+
)
3748

3849
def add_plugin(self, plugin: Plugin) -> None:
3950
if not isinstance(plugin, (Plugin, ApplicationPlugin)):

0 commit comments

Comments
 (0)