Commit 7ed1da26 by Arun Babu Neelicattu

plugin manager: use system env paths for discovery

parent cff1baa1
...@@ -40,12 +40,10 @@ commands respectively. ...@@ -40,12 +40,10 @@ commands respectively.
} }
) )
entry_points = (
PluginManager(ApplicationPlugin.group).get_plugin_entry_points()
+ PluginManager(Plugin.group).get_plugin_entry_points()
)
system_env = EnvManager.get_system_env(naive=True) system_env = EnvManager.get_system_env(naive=True)
entry_points = PluginManager(ApplicationPlugin.group).get_plugin_entry_points(
env=system_env
) + PluginManager(Plugin.group).get_plugin_entry_points(env=system_env)
installed_repository = InstalledRepository.load( installed_repository = InstalledRepository.load(
system_env, with_dependencies=True system_env, with_dependencies=True
) )
......
from __future__ import annotations from __future__ import annotations
import logging import logging
import sys
from typing import Any from typing import TYPE_CHECKING
import entrypoints import entrypoints
...@@ -10,6 +11,12 @@ from poetry.plugins.application_plugin import ApplicationPlugin ...@@ -10,6 +11,12 @@ from poetry.plugins.application_plugin import ApplicationPlugin
from poetry.plugins.plugin import Plugin from poetry.plugins.plugin import Plugin
if TYPE_CHECKING:
from typing import Any
from poetry.utils.env import Env
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
...@@ -23,19 +30,20 @@ class PluginManager: ...@@ -23,19 +30,20 @@ class PluginManager:
self._disable_plugins = disable_plugins self._disable_plugins = disable_plugins
self._plugins: list[Plugin] = [] self._plugins: list[Plugin] = []
def load_plugins(self) -> None: def load_plugins(self, env: Env | None = None) -> None:
if self._disable_plugins: if self._disable_plugins:
return return
plugin_entrypoints = self.get_plugin_entry_points() plugin_entrypoints = self.get_plugin_entry_points(env=env)
for entrypoint in plugin_entrypoints: for entrypoint in plugin_entrypoints:
self._load_plugin_entrypoint(entrypoint) self._load_plugin_entrypoint(entrypoint)
def get_plugin_entry_points(self) -> list[entrypoints.EntryPoint]: def get_plugin_entry_points(
self, env: Env | None = None
) -> list[entrypoints.EntryPoint]:
entry_points: list[entrypoints.EntryPoint] = entrypoints.get_group_all( entry_points: list[entrypoints.EntryPoint] = entrypoints.get_group_all(
self._group self._group, path=env.sys_path if env else sys.path
) )
return entry_points return entry_points
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment