From 97330d95b45696b10f2d6b3334ecf6e2ca1c27a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steven!=20Ragnar=C3=B6k?= Date: Fri, 18 Oct 2019 14:58:23 -0400 Subject: [PATCH] Add ROS_PYTHON_VERSION to dependency conditionals. (#551) * Raise rosdistro requirement to include new index-v4 changes. The python_version key is required to supply ROS_PYTHON_VERSION to conditional dependencies. * Add API method for retrieving the distribution's python version. * Add ROS_PYTHON_VERSION to conditional context. * Fix pep8 conformance. * Explicitly note when the python_version key is missing. This feature will cause interruptions for bloom users whose version 4 rosdistro indexes lack this field. But I think this is preferred to a silent or even vocal acceptance of a possibly invalid release state due to missing conditional variables. --- bloom/generators/common.py | 16 ++++++++++++++++ bloom/rosdistro_api.py | 4 ++++ setup.py | 2 +- stdeb.cfg | 4 ++-- 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/bloom/generators/common.py b/bloom/generators/common.py index 2bfabbed..09ba51d9 100644 --- a/bloom/generators/common.py +++ b/bloom/generators/common.py @@ -42,6 +42,7 @@ from bloom.rosdistro_api import get_distribution_type from bloom.rosdistro_api import get_index +from bloom.rosdistro_api import get_python_version from bloom.util import code from bloom.util import maybe_continue @@ -139,9 +140,24 @@ def package_conditional_context(ros_distro): else: error("Bloom cannot cope with distribution_type '{0}'".format( distribution_type), exit=True) + python_version = get_python_version(ros_distro) + if python_version is None: + error( + 'No python_version found in the rosdistro index. ' + 'The rosdistro index must include this key for bloom to work correctly.', + exit=True) + elif python_version == 2: + ros_python_version = '2' + elif python_version == 3: + ros_python_version = '3' + else: + error("Bloom cannot cope with python_version '{0}'".format( + python_version), exit=True) + return { 'ROS_VERSION': ros_version, 'ROS_DISTRO': ros_distro, + 'ROS_PYTHON_VERSION': ros_python_version, } diff --git a/bloom/rosdistro_api.py b/bloom/rosdistro_api.py index a88b8a9e..bab31576 100644 --- a/bloom/rosdistro_api.py +++ b/bloom/rosdistro_api.py @@ -137,6 +137,10 @@ def get_distribution_type(distro): return get_index().distributions[distro].get('distribution_type') +def get_python_version(distro): + return get_index().distributions[distro].get('python_version') + + def get_most_recent(thing_name, repository, reference_distro): reference_distro_type = get_distribution_type(reference_distro) distros_with_entry = {} diff --git a/setup.py b/setup.py index 0ce619c6..142f9472 100755 --- a/setup.py +++ b/setup.py @@ -10,7 +10,7 @@ 'python-dateutil', 'PyYAML', 'rosdep >= 0.15.0', - 'rosdistro >= 0.7.0', + 'rosdistro >= 0.7.5', 'vcstools >= 0.1.22', ] diff --git a/stdeb.cfg b/stdeb.cfg index 461f7295..20749de5 100755 --- a/stdeb.cfg +++ b/stdeb.cfg @@ -1,6 +1,6 @@ [DEFAULT] -Depends: python-yaml, python-empy, python-argparse, python-rosdep (>= 0.15.0), python-rosdistro (>= 0.7.0), python-vcstools (>= 0.1.22), python-setuptools, python-catkin-pkg (>= 0.4.3) -Depends3: python3-yaml, python3-empy, python3-rosdep (>= 0.15.0), python3-rosdistro (>= 0.7.0), python3-vcstools (>= 0.1.22), python3-setuptools, python3-catkin-pkg (>= 0.4.3) +Depends: python-yaml, python-empy, python-argparse, python-rosdep (>= 0.15.0), python-rosdistro (>= 0.7.5), python-vcstools (>= 0.1.22), python-setuptools, python-catkin-pkg (>= 0.4.3) +Depends3: python3-yaml, python3-empy, python3-rosdep (>= 0.15.0), python3-rosdistro (>= 0.7.5), python3-vcstools (>= 0.1.22), python3-setuptools, python3-catkin-pkg (>= 0.4.3) Conflicts: python3-bloom Conflicts3: python-bloom Copyright-File: LICENSE.txt