def __init__(self, *workspaces):
"""
:param workspaces: can be a devel or install workspace (including a distro install directory), but also a directory containing packages (like a source workspace)
These should all work, without catkin build necessary.
"""
super(ROSDistroMetaFinder, self).__init__()
# TODO : prevent that when we are in virtualenv and we have not allowed system site packages
self.src_rospkgs = []
broken_workspaces = []
for w in workspaces:
# Adding the share path (where we can find all packages and their messages)
share_path = os.path.join(w, 'share')
if os.path.exists(share_path):
self.share_path = share_path
else: # this is not a workspace, maybe we are expected to get the package directly from source ?
found_one = False
for root, dirs, files in os.walk(w, topdown=False):
if 'package.xml' in files: # we have found a ros package
self.src_rospkgs.append(root)
found_one = True
if not found_one:
broken_workspaces.append(w)
raise ImportError
python_libpath = os.path.join(w, 'lib', 'python' + sys.version_info.major + '.' + sys.version_info.minor)
if os.path.exists(python_libpath):
# adding python site directories for the ROS distro (to find python modules as usual with ROS)
if os.path.exists(os.path.join(python_libpath, 'dist-packages')):
site.addsitedir(os.path.join(python_libpath, 'dist-packages'))
if os.path.exists(os.path.join(python_libpath, 'site-packages')):
site.addsitedir(os.path.join(python_libpath, 'site-packages'))
else: # this is not a workspace, maybe we are expected to get the package directly from source ?
for root, dirs, files in os.walk(w, topdown=False):
if 'package.xml' in files: # we have found a ros package
self.src_rospkgs.append(root)
raise ImportError
评论列表
文章目录