Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions src/buildstream/_pluginfactory/pluginoriginpip.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
import os
from pathlib import Path

from .._exceptions import PluginError

Expand All @@ -34,6 +34,7 @@ def get_plugin_paths(self, kind, plugin_type):

from packaging.requirements import Requirement, InvalidRequirement
from importlib.metadata import distribution, PackageNotFoundError
from importlib.util import find_spec

# Sources and elements are looked up in separate
# entrypoint groups from the same package.
Expand Down Expand Up @@ -86,17 +87,19 @@ def get_plugin_paths(self, kind, plugin_type):
reason="plugin-not-found",
)

location = dist.locate_file(entrypoint.module.replace(".", os.sep) + ".py")
defaults = dist.locate_file(entrypoint.module.replace(".", os.sep) + ".yaml")
location = Path(find_spec(entrypoint.module).origin)
defaults = location.with_suffix(".yaml")

if not defaults.exists():
# The plugin didn't have an accompanying YAML file
defaults = None

directory = str(location.parent)

return (
os.path.dirname(location),
directory,
str(defaults),
"python package '{}' version {} at: {}".format(dist.name, dist.version, dist.locate_file("")),
"python package '{}' version {} at: {}".format(dist.name, dist.version, directory),
)

def load_config(self, origin_node):
Expand Down
Loading