def activate():
"""Install the path-based import components."""
# We should plug filefinder first to avoid plugging ROSDirectoryFinder, when it is not a ROS thing...
filefinder2.activate()
if ros_path_hook not in sys.path_hooks:
# We need to be before FileFinder to be able to find our '.msg' and '.srv' files without making a namespace package
# Note this must be early in the path_hook list, since we change the logic
# and a namespace package becomes a ros importable package.
sys.path_hooks.insert(filefinder2.get_filefinder_index_in_path_hooks(), ros_path_hook)
if ROSPathFinder not in sys.meta_path:
# adding metahook, before the usual pathfinder, to avoid interferences with python namespace mechanism...
sys.meta_path.insert(filefinder2.get_pathfinder_index_in_meta_hooks(), ROSPathFinder)
# Resetting sys.path_importer_cache
# to support the case where we have an implicit (msg/srv) package inside an already loaded package,
# since we need to replace the default importer.
sys.path_importer_cache.clear()
评论列表
文章目录