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

Support for python3 with ROS1 #429

Closed
Closed
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
1 change: 1 addition & 0 deletions industrial_ci/src/docker.env
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ PYTHONUNBUFFERED
ROSDEP_SKIP_KEYS
ROSINSTALL_FILENAME
ROS_DISTRO
ROS_FROM_SCRATCH
ROS_PYTHON_VERSION
TARGET_CMAKE_ARGS
TARGET_REPO_NAME
Expand Down
11 changes: 11 additions & 0 deletions industrial_ci/src/env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,19 @@ function set_ros_variables {
ROS_VERSION_EOL=true
;;
"melodic")
if [ "$ROS_PYTHON_VERSION" = 3 ]; then
BUILDER=${BUILDER:-colcon}
export ROS_FROM_SCRATCH=true
fi
ros1_defaults "bionic"
;;
"noetic")
ros1_defaults "buster"
OS_NAME=debian
DEFAULT_DOCKER_IMAGE=
export ROS_FROM_SCRATCH=true
ROS_PYTHON_VERSION=3
;;
"ardent")
ros2_defaults "xenial"
DEFAULT_DOCKER_IMAGE=
Expand Down
32 changes: 29 additions & 3 deletions industrial_ci/src/tests/source_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ function install_catkin_lint {
ici_asroot pip install catkin-lint
}

function install_catkin_from_source {
ici_prepare_sourcespace /tmp/bootstrap_ws/src "github:ros/catkin#HEAD"
ici_install_dependencies "" "" /tmp/bootstrap_ws/src
ici_exec_in_workspace "" /tmp/bootstrap_ws "python${ROS_PYTHON_VERSION}" ./src/catkin/bin/catkin_make -DCMAKE_INSTALL_PREFIX="/opt/ros/$ROS_DISTRO" install
rm -rf /tmp/bootstrap_ws
}

function run_source_tests {
# shellcheck disable=SC1090
source "${ICI_SRC_PATH}/builders/$BUILDER.sh" || ici_error "Builder '$BUILDER' not supported"
Expand All @@ -40,13 +47,32 @@ function run_source_tests {
ici_run "setup_ccache" ici_asroot apt-get install -qq -y ccache
export PATH="/usr/lib/ccache:$PATH"
fi

ici_run "${BUILDER}_setup" ici_quiet builder_setup

ici_run "setup_rosdep" ici_setup_rosdep

extend="/opt/ros/$ROS_DISTRO"

if [ "$ROS_FROM_SCRATCH" = true ]; then
if [ "$ROS_VERSION" = "1" ]; then
ici_run "install_catkin_from_source" install_catkin_from_source
fi
ici_time_start "generate_rosinstall"
ici_install_pkgs_for_command rosinstall_generator "${PYTHON_VERSION_NAME}-rosinstall-generator"
local alldeps=("$ROSDEP_SKIP_KEYS")
local deps=(" ")
while [ ${#deps} -gt 0 ]; do
mapfile -t deps < <(ROS_DISTRO='' rosdep check -n -i --from-paths "$TARGET_REPO_PATH" "$extend" --skip-keys "${alldeps[*]}" |& grep -oP '(?<=rosdep key : ).*' | sort -u)
alldeps+=("${deps[@]}")
done
echo "${deps[@]}"
rosinstall_generator --rosdistro "$ROS_DISTRO" --deps "${alldeps[@]}" --exclude-path "$extend" > /tmp/target.rosinstall || [ -n "$UPSTREAM_WORKSPACE" ]
if [ -s /tmp/target.rosinstall ]; then
UPSTREAM_WORKSPACE="/tmp/target.rosinstall $UPSTREAM_WORKSPACE"
fi
ici_time_end
fi

ici_run "${BUILDER}_setup" ici_quiet builder_setup

if [ -n "$UPSTREAM_WORKSPACE" ]; then
ici_with_ws "$upstream_ws" ici_build_workspace "upstream" "$extend" "$upstream_ws"
extend="$upstream_ws/install"
Expand Down
12 changes: 9 additions & 3 deletions industrial_ci/src/workspace.sh
Original file line number Diff line number Diff line change
Expand Up @@ -231,14 +231,20 @@ function ici_install_dependencies {
local extend=$1; shift
local skip_keys=$1; shift
local cmake_prefix_path
local rosdep_install=()
cmake_prefix_path="$(ici_exec_in_workspace "$extend" . env | grep -oP '^CMAKE_PREFIX_PATH=\K.*')" || true

rosdep_opts=(-q --from-paths "$@" --ignore-src -y)
if [ "$ROS_FROM_SCRATCH" = true ]; then
rosdep_install+=(env "ROS_DISTRO=")
fi

rosdep_install+=(rosdep install -q --from-paths "$@" --ignore-src -y)
if [ -n "$skip_keys" ]; then
rosdep_opts+=(--skip-keys "$skip_keys")
rosdep_install+=(--skip-keys "$skip_keys")
fi

set -o pipefail # fail if rosdep install fails
ROS_PACKAGE_PATH=$cmake_prefix_path ici_exec_in_workspace "$extend" "." rosdep install "${rosdep_opts[@]}" | { grep "executing command" || true; }
ROS_PACKAGE_PATH=$cmake_prefix_path ici_exec_in_workspace "$extend" "." "${rosdep_install[@]}" | { grep "executing command" || true; }
set +o pipefail
}

Expand Down