1111# See the License for the specific language governing permissions and
1212# limitations under the License.
1313#
14- import os
14+ from pathlib import Path
1515
1616from .._exceptions import PluginError
1717
@@ -34,6 +34,7 @@ def get_plugin_paths(self, kind, plugin_type):
3434
3535 from packaging .requirements import Requirement , InvalidRequirement
3636 from importlib .metadata import distribution , PackageNotFoundError
37+ from importlib .util import find_spec
3738
3839 # Sources and elements are looked up in separate
3940 # entrypoint groups from the same package.
@@ -86,17 +87,19 @@ def get_plugin_paths(self, kind, plugin_type):
8687 reason = "plugin-not-found" ,
8788 )
8889
89- location = dist . locate_file ( entrypoint .module . replace ( "." , os . sep ) + ".py" )
90- defaults = dist . locate_file ( entrypoint . module . replace ( "." , os . sep ) + ".yaml" )
90+ location = Path ( find_spec ( entrypoint .module ). origin )
91+ defaults = location . with_suffix ( ".yaml" )
9192
9293 if not defaults .exists ():
9394 # The plugin didn't have an accompanying YAML file
9495 defaults = None
9596
97+ directory = str (location .parent )
98+
9699 return (
97- os . path . dirname ( location ) ,
100+ directory ,
98101 str (defaults ),
99- "python package '{}' version {} at: {}" .format (dist .name , dist .version , dist . locate_file ( "" ) ),
102+ "python package '{}' version {} at: {}" .format (dist .name , dist .version , directory ),
100103 )
101104
102105 def load_config (self , origin_node ):
0 commit comments