1
1
from __future__ import annotations
2
2
3
3
import logging
4
+ import sys
4
5
5
- from typing import Any
6
+ from typing import TYPE_CHECKING
6
7
7
8
import entrypoints
8
9
9
10
from poetry .plugins .application_plugin import ApplicationPlugin
10
11
from poetry .plugins .plugin import Plugin
11
12
12
13
14
+ if TYPE_CHECKING :
15
+ from typing import Any
16
+
17
+ from poetry .utils .env import Env
18
+
19
+
13
20
logger = logging .getLogger (__name__ )
14
21
15
22
@@ -23,17 +30,21 @@ def __init__(self, group: str, disable_plugins: bool = False) -> None:
23
30
self ._disable_plugins = disable_plugins
24
31
self ._plugins : list [Plugin ] = []
25
32
26
- def load_plugins (self ) -> None :
33
+ def load_plugins (self , env : Env | None = None ) -> None :
27
34
if self ._disable_plugins :
28
35
return
29
36
30
- plugin_entrypoints = self .get_plugin_entry_points ()
37
+ plugin_entrypoints = self .get_plugin_entry_points (env = env )
31
38
32
39
for entrypoint in plugin_entrypoints :
33
40
self ._load_plugin_entrypoint (entrypoint )
34
41
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
+ )
37
48
38
49
def add_plugin (self , plugin : Plugin ) -> None :
39
50
if not isinstance (plugin , (Plugin , ApplicationPlugin )):
0 commit comments