How to bloom-generate with python3
Hi, I have an Ubuntu installation with ROS Melodic, and I am trying to build my packages using bloom. ROS Melodic is running on python2, but the python code in my package is running on python3.
I can catkin_make
my package with the argument -DPYTHON_EXECUTABLE="/usr/bin/python3"
, but if I run bloom-generate
and then fakeroot debian/rules binary
, the build fails.
I solve this by manually adding the argument -DPYTHON_EXECUTABLE="/usr/bin/python3"
in override_dh_auto_configure
in the debian/rules file, and now my build succeeds.
Is there a way to add this line automatically, using bloom?
The full (modified) debian/rules file is as follows:
#!/usr/bin/make -f
# -*- makefile -*-
# Sample debian/rules that uses debhelper.
# This file was originally written by Joey Hess and Craig Small.
# As a special exception, when this file is copied by dh-make into a
# dh-make output file, you may use that output file without restriction.
# This special exception was added by Craig Small in version 0.37 of dh-make.
# Uncomment this to turn on verbose mode.
export DH_VERBOSE=1
# TODO: remove the LDFLAGS override. It's here to avoid esoteric problems
# of this sort:
# https://code.ros.org/trac/ros/ticket/2977
# https://code.ros.org/trac/ros/ticket/3842
export LDFLAGS=
export PKG_CONFIG_PATH=/opt/ros/melodic/lib/pkgconfig
# Explicitly enable -DNDEBUG, see:
# https://github.com/ros-infrastructure/bloom/issues/327
export DEB_CXXFLAGS_MAINT_APPEND=-DNDEBUG
ifneq ($(filter nocheck,$(DEB_BUILD_OPTIONS)),)
BUILD_TESTING_ARG=-DBUILD_TESTING=OFF -DCATKIN_ENABLE_TESTING=OFF
endif
DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
%:
dh $@ -v --buildsystem=cmake --builddirectory=.obj-$(DEB_HOST_GNU_TYPE)
override_dh_auto_configure:
# In case we're installing to a non-standard location, look for a setup.sh
# in the install tree that was dropped by catkin, and source it. It will
# set things like CMAKE_PREFIX_PATH, PKG_CONFIG_PATH, and PYTHONPATH.
if [ -f "/opt/ros/melodic/setup.sh" ]; then . "/opt/ros/melodic/setup.sh"; fi && \
dh_auto_configure -- \
-DCATKIN_BUILD_BINARY_PACKAGE="1" \
-DCMAKE_INSTALL_PREFIX="/opt/ros/melodic" \
-DCMAKE_PREFIX_PATH="/opt/ros/melodic" \
-DPYTHON_EXECUTABLE="/usr/bin/python3" \
$(BUILD_TESTING_ARG)
override_dh_auto_build:
# In case we're installing to a non-standard location, look for a setup.sh
# in the install tree that was dropped by catkin, and source it. It will
# set things like CMAKE_PREFIX_PATH, PKG_CONFIG_PATH, and PYTHONPATH.
if [ -f "/opt/ros/melodic/setup.sh" ]; then . "/opt/ros/melodic/setup.sh"; fi && \
dh_auto_build
override_dh_auto_test:
# In case we're installing to a non-standard location, look for a setup.sh
# in the install tree that was dropped by catkin, and source it. It will
# set things like CMAKE_PREFIX_PATH, PKG_CONFIG_PATH, and PYTHONPATH.
echo -- Running tests. Even if one of them fails the build is not canceled.
if [ -f "/opt/ros/melodic/setup.sh" ]; then . "/opt/ros/melodic/setup.sh"; fi && \
dh_auto_test || true
override_dh_shlibdeps:
# In case we're installing to a non-standard location, look for a setup.sh
# in the install tree that was dropped by catkin, and source it. It will
# set things like CMAKE_PREFIX_PATH, PKG_CONFIG_PATH, and PYTHONPATH.
if [ -f "/opt/ros/melodic/setup.sh" ]; then . "/opt/ros/melodic/setup.sh"; fi && \
dh_shlibdeps -l$(CURDIR)/debian/ros-melodic-my-robot-common//opt/ros/melodic/lib/
override_dh_auto_install:
# In case ...
Are you releasing to the public ROS buildfarm? If so: I'm pretty sure this will not be accepted, as Melodic is Python 2 only. Patching files after Blooming is an indication you're doing things which aren't supported.
If you need Python 3, you'd best migrate / switch to Noetic.
Hi @gvdhoorn, I am not publicly releasing it. I want to create a .deb package that I can distribute myself. Switching to Noetic is not an option I believe, since it is running on Ubuntu 18.04.