Skip to content

Commit

Permalink
Updates plugin path when module loaded.
Browse files Browse the repository at this point in the history
Signed-off-by: Franco Cipollone <franco.c@ekumenlabs.com>
  • Loading branch information
francocipollone committed Sep 1, 2023
1 parent a4718f9 commit f59ad46
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions maliput/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,28 @@
'math',
'plugin'
]

def get_maliput_backends():
import importlib.metadata as importlib_metadata
return importlib_metadata.entry_points()['maliput.backends']

# Update MALIPUT_PLUGIN_PATH environment variable with paths provided by the `maliput.backends` entry point
# Each backend will have as entry point:
# group: maliput.backends
# name: <backend_name> (e.g. 'maliput_malidrive')
# value: method that returns the path to the location of .so files
def update_plugin_path():
import os

plugin_paths = []
for entry_point in get_maliput_backends():
plugin_paths.append(entry_point.load()())

plugin_path = os.pathsep.join(plugin_paths)
if 'MALIPUT_PLUGIN_PATH' in os.environ:
plugin_path = os.pathsep.join([plugin_path, os.environ['MALIPUT_PLUGIN_PATH']])
os.environ['MALIPUT_PLUGIN_PATH'] = plugin_path


update_plugin_path()

0 comments on commit f59ad46

Please sign in to comment.