Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Teach rosdep to use ROS_VERSION when resolving conditionals #941

Merged
merged 3 commits into from
Feb 17, 2024
Merged
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions src/rosdep2/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,12 @@ def setup_environment_variables(ros_distro):
del os.environ['ROS_PYTHON_VERSION']
os.environ['ROS_DISTRO'] = ros_distro

if 'ROS_VERSION' not in os.environ and 'ROS_DISTRO' in os.environ:
# Set ROS version to version used by ROS distro
ros_versions = MetaDatabase().get('ROS_VERSION', default=[])
if os.environ['ROS_DISTRO'] in ros_versions:
os.environ['ROS_VERSION'] = str(ros_versions[os.environ['ROS_DISTRO']])

if 'ROS_PYTHON_VERSION' not in os.environ and 'ROS_DISTRO' in os.environ:
# Set python version to version used by ROS distro
python_versions = MetaDatabase().get('ROS_PYTHON_VERSION', default=[])
Expand Down
16 changes: 14 additions & 2 deletions src/rosdep2/sources_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,12 @@ def update_sources_list(sources_list_dir=None, sources_cache_dir=None,
# Additional sources for ros distros
# In compliance with REP137 and REP143
python_versions = {}
ros_versions = {}

ros_version_map = {
'ros1': '1',
'ros2': '2',
}

if not quiet:
print('Query rosdistro index %s' % get_index_url())
Expand All @@ -508,17 +514,23 @@ def update_sources_list(sources_list_dir=None, sources_cache_dir=None,
print('Add distro "%s"' % dist_name)
rds = RosDistroSource(dist_name)
rosdep_data = get_gbprepo_as_rosdep_data(dist_name)
# Store Python version from REP153
# Store metadata from REP153
if distribution.get('python_version'):
python_versions[dist_name] = distribution.get('python_version')
if distribution.get('distribution_type'):
distribution_type = distribution.get('distribution_type')
if distribution_type in ros_version_map:
ros_versions[dist_name] = ros_version_map[distribution_type]
# dist_files can either be a string (single filename) or a list (list of filenames)
dist_files = distribution['distribution']
key = _generate_key_from_urls(dist_files)
retval.append((rds, write_cache_file(sources_cache_dir, key, rosdep_data)))
sources.append(rds)

# cache metadata that isn't a source list
MetaDatabase().set('ROS_PYTHON_VERSION', python_versions)
meta_db = MetaDatabase()
meta_db.set('ROS_PYTHON_VERSION', python_versions)
meta_db.set('ROS_VERSION', ros_versions)

# Create a combined index of *all* the sources. We do all the
# sources regardless of failures because a cache from a previous
Expand Down
Loading