Merge pull request #475 from rojkov/python3

Enable python3 compatible ROS builds
This commit is contained in:
Lukas Bulwahn 2017-04-13 05:55:45 +02:00 committed by GitHub
commit 93cc6f4bf8
52 changed files with 405 additions and 137 deletions

View File

@ -24,6 +24,7 @@ resolved in the past.
* Lukas Bulwahn, BMW Car IT GmbH <lukas.bulwahn@oss.bmw-carit.de> * Lukas Bulwahn, BMW Car IT GmbH <lukas.bulwahn@oss.bmw-carit.de>
* Stefan Herbrechtsmeier, Bielefeld University <stefan@herbrechtsmeier.net> * Stefan Herbrechtsmeier, Bielefeld University <stefan@herbrechtsmeier.net>
* Kristof Robot <krirobo@gmail.com> * Kristof Robot <krirobo@gmail.com>
* Dmitry Rozhkov, Intel <dmitry.rozhkov@linux.intel.com>
## CONTRIBUTORS ## ## CONTRIBUTORS ##
@ -47,6 +48,7 @@ resolved in the past.
* Gauthier Monserand <simkim@simkim.net> * Gauthier Monserand <simkim@simkim.net>
* Timo Mueller <timo.mueller@bmw-carit.de> * Timo Mueller <timo.mueller@bmw-carit.de>
* Andreas Baak <andreas.baak@bmw-carit.de> * Andreas Baak <andreas.baak@bmw-carit.de>
* Dmitry Rozhkov, Intel <dmitry.rozhkov@linux.intel.com>
## HOW TO CONTRIBUTE ## ## HOW TO CONTRIBUTE ##
@ -161,6 +163,11 @@ resolved in the past.
/home/me/devel/meta-ros \ /home/me/devel/meta-ros \
" "
By default meta-ros uses python2 in all its recipes. If you want ROS packages
to use python3 then add the following line in your `./conf/local.conf` file:
ROS_USE_PYTHON3 = "yes"
Compile package: Compile package:
bitbake <package-name> bitbake <package-name>

View File

@ -2,9 +2,11 @@
# Copyright (c) 2013 Stefan Herbrechtsmeier, Bielefeld University # Copyright (c) 2013 Stefan Herbrechtsmeier, Bielefeld University
# #
inherit cmake distutils-base ros faulty-solibs ROS_USE_PYTHON3 ??= "no"
DEPENDS_prepend = "${@['catkin-native ', ''][(d.getVar('BPN', True) == 'catkin') | (d.getVar('BPN', True) == 'catkin-runtime')]}" inherit cmake ${@'distutils3-base' if bb.utils.to_boolean(d.getVar('ROS_USE_PYTHON3', True)) else 'distutils-base'} ros faulty-solibs
DEPENDS_prepend = "${@'' if (d.getVar('BPN', True) == 'catkin') or (d.getVar('BPN', True) == 'catkin-runtime') else 'catkin-native '}"
EXTRA_OECMAKE_CATKIN = "\ EXTRA_OECMAKE_CATKIN = "\
-DCMAKE_PREFIX_PATH='${STAGING_DIR_HOST}${ros_prefix};${STAGING_DIR_HOST}${prefix};${STAGING_DIR_NATIVE}${ros_prefix};${STAGING_DIR_NATIVE}${prefix}' \ -DCMAKE_PREFIX_PATH='${STAGING_DIR_HOST}${ros_prefix};${STAGING_DIR_HOST}${prefix};${STAGING_DIR_NATIVE}${ros_prefix};${STAGING_DIR_NATIVE}${prefix}' \

View File

@ -0,0 +1,13 @@
DESCRIPTION = "catkin package library"
SECTION = "devel/python"
LICENSE = "BSD"
LIC_FILES_CHKSUM = "file://PKG-INFO;beginline=8;endline=8;md5=e910b35b0ef4e1f665b9a75d6afb7709"
SRCNAME = "catkin_pkg"
SRC_URI = "https://pypi.python.org/packages/source/c/catkin_pkg/catkin_pkg-${PV}.tar.gz"
SRC_URI[md5sum] = "da93566c65dddfa9f821e18944c5ee5e"
SRC_URI[sha256sum] = "d4d069eaeb29d6a9ee71773b20c41515b6e0feb9ea2765ebaf3e599d0ceef050"
S = "${WORKDIR}/${SRCNAME}-${PV}"
BBCLASSEXTEND = "native"

View File

@ -1,15 +1,3 @@
DESCRIPTION = "catkin package library" require python-catkin-pkg.inc
SECTION = "devel/python"
LICENSE = "BSD"
LIC_FILES_CHKSUM = "file://PKG-INFO;beginline=8;endline=8;md5=e910b35b0ef4e1f665b9a75d6afb7709"
SRCNAME = "catkin_pkg"
SRC_URI = "https://pypi.python.org/packages/source/c/catkin_pkg/catkin_pkg-${PV}.tar.gz"
SRC_URI[md5sum] = "da93566c65dddfa9f821e18944c5ee5e"
SRC_URI[sha256sum] = "d4d069eaeb29d6a9ee71773b20c41515b6e0feb9ea2765ebaf3e599d0ceef050"
S = "${WORKDIR}/${SRCNAME}-${PV}"
inherit distutils inherit distutils
BBCLASSEXTEND = "native"

View File

@ -0,0 +1,13 @@
DESCRIPTION = "A powerful and robust templating system for Python"
SECTION = "devel/python"
LICENSE = "LGPL-2.1"
LIC_FILES_CHKSUM = "file://COPYING;md5=7fbc338309ac38fefcd64b04bb903e34"
SRCNAME = "empy"
SRC_URI = "http://www.alcyone.com/software/empy/empy-${PV}.tar.gz"
SRC_URI[md5sum] = "fbb34761cdf9acc4c65e298c9eced395"
SRC_URI[sha256sum] = "99f016af2770c48ab57a65df7aae251360dc69a1514c15851458a71d4ddfea9c"
S = "${WORKDIR}/${SRCNAME}-${PV}"
BBCLASSEXTEND = "native"

View File

@ -1,15 +1,3 @@
DESCRIPTION = "A powerful and robust templating system for Python" require python-empy.inc
SECTION = "devel/python"
LICENSE = "LGPL-2.1"
LIC_FILES_CHKSUM = "file://COPYING;md5=7fbc338309ac38fefcd64b04bb903e34"
SRCNAME = "empy"
SRC_URI = "http://www.alcyone.com/software/empy/empy-${PV}.tar.gz"
SRC_URI[md5sum] = "fbb34761cdf9acc4c65e298c9eced395"
SRC_URI[sha256sum] = "99f016af2770c48ab57a65df7aae251360dc69a1514c15851458a71d4ddfea9c"
S = "${WORKDIR}/${SRCNAME}-${PV}"
inherit distutils inherit distutils
BBCLASSEXTEND = "native"

View File

@ -0,0 +1,11 @@
DESCRIPTION = "Portable network interface information for Python"
SECTION = "devel/python"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://PKG-INFO;beginline=8;endline=8;md5=a53cbc7cb75660694e138ba973c148df"
SRCNAME = "netifaces"
SRC_URI = "https://pypi.python.org/packages/a7/4c/8e0771a59fd6e55aac993a7cc1b6a0db993f299514c464ae6a1ecf83b31d/netifaces-0.10.5.tar.gz"
SRC_URI[md5sum] = "5b4d1f1310ed279e6df27ef3a9b71519"
SRC_URI[sha256sum] = "59d8ad52dd3116fcb6635e175751b250dc783fb011adba539558bd764e5d628b"
S = "${WORKDIR}/${SRCNAME}-${PV}"

View File

@ -1,13 +1,3 @@
DESCRIPTION = "Portable network interface information for Python" require python-netifaces.inc
SECTION = "devel/python"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://PKG-INFO;beginline=8;endline=8;md5=a53cbc7cb75660694e138ba973c148df"
SRCNAME = "netifaces"
SRC_URI = "https://pypi.python.org/packages/a7/4c/8e0771a59fd6e55aac993a7cc1b6a0db993f299514c464ae6a1ecf83b31d/netifaces-0.10.5.tar.gz"
SRC_URI[md5sum] = "5b4d1f1310ed279e6df27ef3a9b71519"
SRC_URI[sha256sum] = "59d8ad52dd3116fcb6635e175751b250dc783fb011adba539558bd764e5d628b"
S = "${WORKDIR}/${SRCNAME}-${PV}"
inherit setuptools inherit setuptools

View File

@ -0,0 +1,17 @@
DESCRIPTION = "rosdep package manager abstraction tool for ROS"
SECTION = "devel/python"
LICENSE = "BSD"
LIC_FILES_CHKSUM = "file://PKG-INFO;beginline=8;endline=8;md5=e910b35b0ef4e1f665b9a75d6afb7709"
SRCNAME = "rosdep"
SRC_URI = "http://download.ros.org/downloads/rosdep/rosdep-${PV}.tar.gz \
file://0001-Remove-build-dependency-on-nose-from-setup.py-491.patch \
"
SRC_URI[md5sum] = "2c5669bc5cafcb1df8cd21ce14844cc4"
SRC_URI[sha256sum] = "46e072074270a1ea25411829814f4bdc1f34b358c950e9b8a7b75b4a40efd96a"
S = "${WORKDIR}/${SRCNAME}-${PV}"
RDEPENDS_${PN} += "${PYTHON_PN}-catkin-pkg ${PYTHON_PN}-rospkg ${PYTHON_PN}-pyyaml ${PYTHON_PN}-netclient ${PYTHON_PN}-rosdistro"
BBCLASSEXTEND += "native"

View File

@ -1,19 +1,3 @@
DESCRIPTION = "rosdep package manager abstraction tool for ROS" require python-rosdep.inc
SECTION = "devel/python"
LICENSE = "BSD"
LIC_FILES_CHKSUM = "file://PKG-INFO;beginline=8;endline=8;md5=e910b35b0ef4e1f665b9a75d6afb7709"
SRCNAME = "rosdep"
SRC_URI = "http://download.ros.org/downloads/rosdep/rosdep-${PV}.tar.gz \
file://0001-Remove-build-dependency-on-nose-from-setup.py-491.patch \
"
SRC_URI[md5sum] = "2c5669bc5cafcb1df8cd21ce14844cc4"
SRC_URI[sha256sum] = "46e072074270a1ea25411829814f4bdc1f34b358c950e9b8a7b75b4a40efd96a"
S = "${WORKDIR}/${SRCNAME}-${PV}"
RDEPENDS_${PN} += "python-catkin-pkg python-rospkg python-pyyaml python-netclient python-rosdistro"
inherit setuptools inherit setuptools
BBCLASSEXTEND += "native"

View File

@ -0,0 +1,15 @@
DESCRIPTION = "ROS package library"
SECTION = "devel/python"
LICENSE = "BSD & MIT"
LIC_FILES_CHKSUM = "file://PKG-INFO;beginline=8;endline=8;md5=48623a4c0f1b1f65fae1dedd990a7f54"
SRCNAME = "rosdistro"
SRC_URI = "http://download.ros.org/downloads/rosdistro/rosdistro-${PV}.tar.gz"
SRC_URI[md5sum] = "a699690fab755fd1b92b2ac04933e227"
SRC_URI[sha256sum] = "f44757336bcee4089f6f6d570248e7c4e09eebfe5238d6ae60d8bd35361eedc4"
S = "${WORKDIR}/${SRCNAME}-${PV}"
RDEPENDS_${PN} += "${PYTHON_PN}-pyyaml"
BBCLASSEXTEND = "native"

View File

@ -1,17 +1,3 @@
DESCRIPTION = "ROS package library" require python-rosdistro.inc
SECTION = "devel/python"
LICENSE = "BSD & MIT"
LIC_FILES_CHKSUM = "file://PKG-INFO;beginline=8;endline=8;md5=48623a4c0f1b1f65fae1dedd990a7f54"
SRCNAME = "rosdistro"
SRC_URI = "http://download.ros.org/downloads/rosdistro/rosdistro-${PV}.tar.gz"
SRC_URI[md5sum] = "a699690fab755fd1b92b2ac04933e227"
SRC_URI[sha256sum] = "f44757336bcee4089f6f6d570248e7c4e09eebfe5238d6ae60d8bd35361eedc4"
S = "${WORKDIR}/${SRCNAME}-${PV}"
RDEPENDS_${PN} += "python-pyyaml"
inherit setuptools inherit setuptools
BBCLASSEXTEND = "native"

View File

@ -0,0 +1,15 @@
DESCRIPTION = "ROS package library"
SECTION = "devel/python"
LICENSE = "BSD"
LIC_FILES_CHKSUM = "file://PKG-INFO;beginline=8;endline=8;md5=e910b35b0ef4e1f665b9a75d6afb7709"
SRCNAME = "rospkg"
SRC_URI = "http://download.ros.org/downloads/rospkg/rospkg-${PV}.tar.gz"
SRC_URI[md5sum] = "36fa86450a397cbe531b214e088d06b7"
SRC_URI[sha256sum] = "ccd1d635319d41b79139b7336af64fc17a48a69ce0d728c1578c78f6350dbe1c"
S = "${WORKDIR}/${SRCNAME}-${PV}"
RDEPENDS_${PN} += "${PYTHON_PN}-xml"
BBCLASSEXTEND = "native"

View File

@ -1,17 +1,3 @@
DESCRIPTION = "ROS package library" require python-rospkg.inc
SECTION = "devel/python"
LICENSE = "BSD"
LIC_FILES_CHKSUM = "file://PKG-INFO;beginline=8;endline=8;md5=e910b35b0ef4e1f665b9a75d6afb7709"
SRCNAME = "rospkg"
SRC_URI = "http://download.ros.org/downloads/rospkg/rospkg-${PV}.tar.gz"
SRC_URI[md5sum] = "36fa86450a397cbe531b214e088d06b7"
SRC_URI[sha256sum] = "ccd1d635319d41b79139b7336af64fc17a48a69ce0d728c1578c78f6350dbe1c"
S = "${WORKDIR}/${SRCNAME}-${PV}"
RDEPENDS_${PN} += "python-xml"
inherit setuptools inherit setuptools
BBCLASSEXTEND = "native"

View File

@ -1,15 +0,0 @@
DESCRIPTION = "A high-level cross-protocol url-grabber"
SECTION = "devel/python"
LICENSE = "LGPL-2.1"
LIC_FILES_CHKSUM = "file://LICENSE;md5=68ad62c64cc6c620126241fd429e68fe"
SRCNAME = "urlgrabber"
DEPENDS = "python-pycurl-native python-pycurl"
SRC_URI = "https://pypi.python.org/packages/source/u/${SRCNAME}/${SRCNAME}-${PV}.tar.gz"
SRC_URI[md5sum] = "00c8359bf71062d0946bacea521f80b4"
SRC_URI[sha256sum] = "4437076c8708e5754ea04540e46c7f4f233734ee3590bb8a96389264fb0650d0"
S = "${WORKDIR}/${SRCNAME}-${PV}"
inherit distutils

View File

@ -0,0 +1,3 @@
require python-catkin-pkg.inc
inherit distutils3

View File

@ -0,0 +1,3 @@
require python-empy.inc
inherit distutils3

View File

@ -0,0 +1,3 @@
require python-netifaces.inc
inherit setuptools3

View File

@ -0,0 +1,5 @@
FILESEXTRAPATHS_prepend := "${THISDIR}/python-rosdep:"
require python-rosdep.inc
inherit setuptools3

View File

@ -0,0 +1,3 @@
require python-rosdistro.inc
inherit setuptools3

View File

@ -0,0 +1,3 @@
require python-rospkg.inc
inherit setuptools3

View File

@ -11,8 +11,8 @@ FILES_${PN} = "${PYTHON_SITEPACKAGES_DIR} ${ros_bindir}/catkin_find"
RDEPENDS_${PN}_class-native = "" RDEPENDS_${PN}_class-native = ""
RDEPENDS_${PN} = "\ RDEPENDS_${PN} = "\
python-catkin-pkg python-argparse python-misc python-multiprocessing \ ${PYTHON_PN}-catkin-pkg ${PYTHON_PN}-argparse ${PYTHON_PN}-misc ${PYTHON_PN}-multiprocessing \
python-shell python-subprocess python-xml python-pkgutil" ${PYTHON_PN}-shell ${PYTHON_PN}-subprocess ${PYTHON_PN}-xml ${PYTHON_PN}-pkgutil"
# Delete everything but the python packages in order to avoid # Delete everything but the python packages in order to avoid
# that the QA error [installed-vs-shipped] hits on us. # that the QA error [installed-vs-shipped] hits on us.

View File

@ -3,7 +3,7 @@ SECTION = "devel"
LICENSE = "BSD" LICENSE = "BSD"
LIC_FILES_CHKSUM = "file://package.xml;beginline=7;endline=7;md5=d566ef916e9dedc494f5f793a6690ba5" LIC_FILES_CHKSUM = "file://package.xml;beginline=7;endline=7;md5=d566ef916e9dedc494f5f793a6690ba5"
DEPENDS = "cmake python-catkin-pkg python-empy-native python-catkin-pkg-native" DEPENDS = "cmake ${PYTHON_PN}-empy-native ${PYTHON_PN}-catkin-pkg-native"
SRC_URI = "https://github.com/ros/${ROS_SPN}/archive/${PV}.tar.gz;downloadfilename=${ROS_SP}.tar.gz" SRC_URI = "https://github.com/ros/${ROS_SPN}/archive/${PV}.tar.gz;downloadfilename=${ROS_SP}.tar.gz"
SRC_URI[md5sum] = "d58460cc9112812d8c4e6ecf98bbcc85" SRC_URI[md5sum] = "d58460cc9112812d8c4e6ecf98bbcc85"
@ -14,6 +14,7 @@ SRC_URI += "\
file://0001-use-python-provided-by-environment-instead-of-the-ge.patch \ file://0001-use-python-provided-by-environment-instead-of-the-ge.patch \
file://0001-avoid-using-host-s-paths-when-cross-compiling.patch \ file://0001-avoid-using-host-s-paths-when-cross-compiling.patch \
file://0001-relocate-dependency-s-headers-to-current-sysroot.patch \ file://0001-relocate-dependency-s-headers-to-current-sysroot.patch \
${@'file://0001-python.cmake-look-for-python3-first.patch' if d.getVar('PYTHON_PN', True) == 'python3' else ''} \
" "
inherit catkin inherit catkin

View File

@ -2,7 +2,7 @@ require catkin.inc
DEPENDS_class-native += "catkin-runtime" DEPENDS_class-native += "catkin-runtime"
RDEPENDS_${PN}_class-native = "" RDEPENDS_${PN}_class-native = "${PYTHON_PN}-catkin-pkg"
RDEPENDS_${PN} = "cmake make binutils binutils-symlinks gcc gcc-symlinks g++ g++-symlinks \ RDEPENDS_${PN} = "cmake make binutils binutils-symlinks gcc gcc-symlinks g++ g++-symlinks \
catkin-runtime" catkin-runtime"
@ -14,7 +14,7 @@ RDEPENDS_${PN} = "cmake make binutils binutils-symlinks gcc gcc-symlinks g++ g++
do_install_append() { do_install_append() {
rm ${D}${ros_bindir}/catkin_find rm ${D}${ros_bindir}/catkin_find
rm -rf ${D}${PYTHON_SITEPACKAGES_DIR} rm -rf ${D}${PYTHON_SITEPACKAGES_DIR}
rmdir ${D}${ros_libdir}/python2.7 rmdir ${D}${ros_libdir}/${PYTHON_DIR}
} }
BBCLASSEXTEND += "native" BBCLASSEXTEND += "native"

View File

@ -0,0 +1,27 @@
From 224186a1af40cd3b7efb4f0648a3a4ca6ca1e7fa Mon Sep 17 00:00:00 2001
From: Dmitry Rozhkov <dmitry.rozhkov@linux.intel.com>
Date: Thu, 6 Apr 2017 15:25:13 +0300
Subject: [PATCH] python.cmake: look for python3 first
Upstream-Status: Inappropriate [the patch overrides ROS's default to python2]
Signed-off-by: Dmitry Rozhkov <dmitry.rozhkov@linux.intel.com>
---
cmake/python.cmake | 1 +
1 file changed, 1 insertion(+)
diff --git a/cmake/python.cmake b/cmake/python.cmake
index 70f3d26..38f8320 100644
--- a/cmake/python.cmake
+++ b/cmake/python.cmake
@@ -5,6 +5,7 @@ if(PYTHON_VERSION)
set(PythonInterp_FIND_VERSION "${PYTHON_VERSION}")
endif()
+set(Python_ADDITIONAL_VERSIONS "3")
find_package(PythonInterp REQUIRED)
message(STATUS "Using PYTHON_EXECUTABLE: ${PYTHON_EXECUTABLE}")
--
2.9.3

View File

@ -4,7 +4,7 @@ LICENSE = "BSD"
LIC_FILES_CHKSUM = "file://package.xml;beginline=7;endline=7;md5=d566ef916e9dedc494f5f793a6690ba5" LIC_FILES_CHKSUM = "file://package.xml;beginline=7;endline=7;md5=d566ef916e9dedc494f5f793a6690ba5"
DEPENDS = "rosconsole tf roscpp angles message-generation dynamic-reconfigure libtinyxml \ DEPENDS = "rosconsole tf roscpp angles message-generation dynamic-reconfigure libtinyxml \
realtime-tools message-filters python-rospkg" realtime-tools message-filters ${PYTHON_PN}-rospkg"
SRC_URI = "https://github.com/ros-controls/${ROS_SPN}/archive/${PV}.tar.gz;downloadfilename=${ROS_SP}.tar.gz" SRC_URI = "https://github.com/ros-controls/${ROS_SPN}/archive/${PV}.tar.gz;downloadfilename=${ROS_SP}.tar.gz"
SRC_URI[md5sum] = "40bc1f04e5936b7fee824f6717702a62" SRC_URI[md5sum] = "40bc1f04e5936b7fee824f6717702a62"

View File

@ -3,7 +3,7 @@ SECTION = "devel"
LICENSE = "BSD" LICENSE = "BSD"
LIC_FILES_CHKSUM = "file://package.xml;beginline=7;endline=7;md5=d566ef916e9dedc494f5f793a6690ba5" LIC_FILES_CHKSUM = "file://package.xml;beginline=7;endline=7;md5=d566ef916e9dedc494f5f793a6690ba5"
DEPENDS = "roscpp sensor-msgs nodelet image-transport image-geometry dynamic-reconfigure python-rospkg" DEPENDS = "roscpp sensor-msgs nodelet image-transport image-geometry dynamic-reconfigure ${PYTHON_PN}-rospkg"
SRC_URI = "https://github.com/ros-perception/${ROS_SPN}/archive/${PV}.tar.gz;downloadfilename=${ROS_SP}.tar.gz \ SRC_URI = "https://github.com/ros-perception/${ROS_SPN}/archive/${PV}.tar.gz;downloadfilename=${ROS_SP}.tar.gz \
file://0001-Add-missing-std-namespace-prefixes.patch \ file://0001-Add-missing-std-namespace-prefixes.patch \

View File

@ -9,5 +9,5 @@ SRC_URI[sha256sum] = "d7627a2df169e4e8208347d9215e47c723a015b67ef3ed8cda8b61b6cf
inherit catkin inherit catkin
RDEPENDS_${PN} = "python-stringold python-pprint" RDEPENDS_${PN} = "${PYTHON_PN}-stringold ${PYTHON_PN}-pprint"
RDEPENDS_${PN}_class-native = "" RDEPENDS_${PN}_class-native = ""

View File

@ -11,5 +11,5 @@ SRC_URI[sha256sum] = "e4465daffb352b4b45180a6157925b16ab3042996984ad231531134e4d
inherit catkin inherit catkin
RDEPENDS_${PN} = "python-math genmsg python-shell" RDEPENDS_${PN} = "${PYTHON_PN}-math genmsg ${PYTHON_PN}-shell"
RDEPENDS_${PN}_class-native = "" RDEPENDS_${PN}_class-native = ""

View File

@ -9,4 +9,8 @@ require geometry.inc
SRC_URI += "file://0001-Fix-stdlib.h-No-such-file-or-directory-errors-in-GCC.patch;striplevel=2" SRC_URI += "file://0001-Fix-stdlib.h-No-such-file-or-directory-errors-in-GCC.patch;striplevel=2"
RDEPENDS_${PN} = "python-numpy" RDEPENDS_${PN} = "${PYTHON_PN}-numpy"
# This option disables python support in case of python3 flavour of ROS because
# only python2 is supported by tf.
EXTRA_OECMAKE =+ "${@'-DANDROID=ON' if d.getVar('PYTHON_PN', True) == 'python3' else ''}"

View File

@ -0,0 +1,64 @@
From ddf9ddefb51502fb21ba01e31187e4ffebc70cce Mon Sep 17 00:00:00 2001
From: Dmitry Rozhkov <dmitry.rozhkov@linux.intel.com>
Date: Mon, 10 Apr 2017 10:35:26 +0300
Subject: [PATCH] Drop support for python
Upstream-Status: Inappropriate [ROS still supports python2 officially]
Signed-off-by: Dmitry Rozhkov <dmitry.rozhkov@linux.intel.com>
---
CMakeLists.txt | 23 ++---------------------
1 file changed, 2 insertions(+), 21 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c21e54a..3a89d94 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -3,13 +3,8 @@ project(camera_calibration_parsers)
find_package(catkin REQUIRED sensor_msgs rosconsole roscpp roscpp_serialization)
-find_package(PythonLibs REQUIRED)
-if(PYTHONLIBS_VERSION_STRING VERSION_LESS 3)
- find_package(Boost REQUIRED COMPONENTS filesystem python)
-else()
- find_package(Boost REQUIRED COMPONENTS filesystem python3)
-endif()
-include_directories(include ${catkin_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} ${PYTHON_INCLUDE_DIRS})
+
+include_directories(include ${catkin_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS})
catkin_python_setup()
@@ -41,17 +36,7 @@ add_library(${PROJECT_NAME}
src/parse_yml.cpp
)
-add_library(${PROJECT_NAME}_wrapper
- src/parse_wrapper.cpp)
-
target_link_libraries(${PROJECT_NAME} ${catkin_LIBRARIES} ${YAML_CPP_LIBRARIES} ${Boost_FILESYSTEM_LIBRARY})
-target_link_libraries(${PROJECT_NAME}_wrapper ${PROJECT_NAME} ${catkin_LIBRARIES} ${Boost_PYTHON_LIBRARY} ${PYTHON_LIBRARIES})
-
-# Don't prepend wrapper library name with lib and add to Python libs.
-set_target_properties(${PROJECT_NAME}_wrapper PROPERTIES
- PREFIX ""
- LIBRARY_OUTPUT_DIRECTORY ${CATKIN_DEVEL_PREFIX}/${CATKIN_PACKAGE_PYTHON_DESTINATION}
- )
add_dependencies(${PROJECT_NAME} ${catkin_EXPORTED_TARGETS})
@@ -74,10 +59,6 @@ install(
DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)
-install(TARGETS ${PROJECT_NAME}_wrapper
- DESTINATION ${CATKIN_PACKAGE_PYTHON_DESTINATION}
-)
-
if(CATKIN_ENABLE_TESTING)
add_subdirectory(test)
endif()
--
2.9.3

View File

@ -6,3 +6,8 @@ LIC_FILES_CHKSUM = "file://package.xml;beginline=10;endline=10;md5=d566ef916e9de
DEPENDS = "boost rosconsole roscpp roscpp-serialization sensor-msgs yaml-cpp" DEPENDS = "boost rosconsole roscpp roscpp-serialization sensor-msgs yaml-cpp"
require image-common.inc require image-common.inc
# OE upstream doesn't support python2 in Boost, but python3 only.
# So, drop python support from camera-calibration-parsers in case
# we're building a python2 flavour of ROS.
SRC_URI += "${@'file://0001-Drop-support-for-python.patch' if d.getVar('PYTHON_PN', True) != 'python3' else ''}"

View File

@ -3,6 +3,6 @@ SECTION = "devel"
LICENSE = "BSD" LICENSE = "BSD"
LIC_FILES_CHKSUM = "file://package.xml;beginline=9;endline=9;md5=d566ef916e9dedc494f5f793a6690ba5" LIC_FILES_CHKSUM = "file://package.xml;beginline=9;endline=9;md5=d566ef916e9dedc494f5f793a6690ba5"
DEPENDS = "boost camera-calibration-parsers cv-bridge dynamic-reconfigure image-geometry image-transport nodelet opencv roscpp sensor-msgs python-rospkg" DEPENDS = "boost camera-calibration-parsers cv-bridge dynamic-reconfigure image-geometry image-transport nodelet opencv roscpp sensor-msgs ${PYTHON_PN}-rospkg"
require image-pipeline.inc require image-pipeline.inc

View File

@ -3,6 +3,6 @@ SECTION = "devel"
LICENSE = "BSD" LICENSE = "BSD"
LIC_FILES_CHKSUM = "file://package.xml;beginline=12;endline=12;md5=d566ef916e9dedc494f5f793a6690ba5" LIC_FILES_CHKSUM = "file://package.xml;beginline=12;endline=12;md5=d566ef916e9dedc494f5f793a6690ba5"
DEPENDS = "camera-info-manager cv-bridge dynamic-reconfigure image-transport nodelet roscpp sensor-msgs python-rospkg" DEPENDS = "camera-info-manager cv-bridge dynamic-reconfigure image-transport nodelet roscpp sensor-msgs ${PYTHON_PN}-rospkg"
require image-pipeline.inc require image-pipeline.inc

View File

@ -4,6 +4,6 @@ SECTION = "devel"
LICENSE = "BSD" LICENSE = "BSD"
LIC_FILES_CHKSUM = "file://package.xml;beginline=26;endline=26;md5=d566ef916e9dedc494f5f793a6690ba5" LIC_FILES_CHKSUM = "file://package.xml;beginline=26;endline=26;md5=d566ef916e9dedc494f5f793a6690ba5"
DEPENDS = "cmake-modules cv-bridge dynamic-reconfigure eigen-conversions image-transport nodelet opencv roscpp tf2 tf2-geometry-msgs tf2-ros python-rospkg" DEPENDS = "cmake-modules cv-bridge dynamic-reconfigure eigen-conversions image-transport nodelet opencv roscpp tf2 tf2-geometry-msgs tf2-ros ${PYTHON_PN}-rospkg"
require image-pipeline.inc require image-pipeline.inc

View File

@ -4,6 +4,6 @@ SECTION = "devel"
LICENSE = "BSD" LICENSE = "BSD"
LIC_FILES_CHKSUM = "file://package.xml;beginline=9;endline=9;md5=d566ef916e9dedc494f5f793a6690ba5" LIC_FILES_CHKSUM = "file://package.xml;beginline=9;endline=9;md5=d566ef916e9dedc494f5f793a6690ba5"
DEPENDS = "cv-bridge dynamic-reconfigure image-transport tf python-rospkg" DEPENDS = "cv-bridge dynamic-reconfigure image-transport tf ${PYTHON_PN}-rospkg"
require image-transport-plugins.inc require image-transport-plugins.inc

View File

@ -4,6 +4,6 @@ SECTION = "devel"
LICENSE = "BSD" LICENSE = "BSD"
LIC_FILES_CHKSUM = "file://package.xml;beginline=9;endline=9;md5=d566ef916e9dedc494f5f793a6690ba5" LIC_FILES_CHKSUM = "file://package.xml;beginline=9;endline=9;md5=d566ef916e9dedc494f5f793a6690ba5"
DEPENDS = "cv-bridge dynamic-reconfigure image-transport tf python-rospkg" DEPENDS = "cv-bridge dynamic-reconfigure image-transport tf ${PYTHON_PN}-rospkg"
require image-transport-plugins.inc require image-transport-plugins.inc

View File

@ -4,6 +4,6 @@ SECTION = "devel"
LICENSE = "BSD" LICENSE = "BSD"
LIC_FILES_CHKSUM = "file://package.xml;beginline=9;endline=9;md5=d566ef916e9dedc494f5f793a6690ba5" LIC_FILES_CHKSUM = "file://package.xml;beginline=9;endline=9;md5=d566ef916e9dedc494f5f793a6690ba5"
DEPENDS = "cv-bridge dynamic-reconfigure image-transport tf rosbag python-rospkg" DEPENDS = "cv-bridge dynamic-reconfigure image-transport tf rosbag ${PYTHON_PN}-rospkg"
require image-transport-plugins.inc require image-transport-plugins.inc

View File

@ -3,7 +3,7 @@ SECTION = "devel"
LICENSE = "BSD" LICENSE = "BSD"
LIC_FILES_CHKSUM = "file://package.xml;beginline=13;endline=13;md5=d566ef916e9dedc494f5f793a6690ba5" LIC_FILES_CHKSUM = "file://package.xml;beginline=13;endline=13;md5=d566ef916e9dedc494f5f793a6690ba5"
DEPENDS = "moveit-core moveit-ros-perception dynamic-reconfigure python-rospkg libtinyxml" DEPENDS = "moveit-core moveit-ros-perception dynamic-reconfigure ${PYTHON_PN}-rospkg libtinyxml"
require moveit-${PV}.inc require moveit-${PV}.inc

View File

@ -3,6 +3,6 @@ SECTION = "devel"
LICENSE = "LGPL-2.1+" LICENSE = "LGPL-2.1+"
LIC_FILES_CHKSUM = "file://package.xml;beginline=21;endline=21;md5=58d727014cda5ed405b7fb52666a1f97" LIC_FILES_CHKSUM = "file://package.xml;beginline=21;endline=21;md5=58d727014cda5ed405b7fb52666a1f97"
DEPENDS = "dynamic-reconfigure message-filters nav-msgs rosbag roscpp std-srvs tf python-rospkg" DEPENDS = "dynamic-reconfigure message-filters nav-msgs rosbag roscpp std-srvs tf ${PYTHON_PN}-rospkg"
require navigation.inc require navigation.inc

View File

@ -3,6 +3,6 @@ SECTION = "devel"
LICENSE = "BSD" LICENSE = "BSD"
LIC_FILES_CHKSUM = "file://package.xml;beginline=8;endline=8;md5=d566ef916e9dedc494f5f793a6690ba5" LIC_FILES_CHKSUM = "file://package.xml;beginline=8;endline=8;md5=d566ef916e9dedc494f5f793a6690ba5"
DEPENDS = "dynamic-reconfigure python-rospkg" DEPENDS = "dynamic-reconfigure ${PYTHON_PN}-rospkg"
require nodelet-core.inc require nodelet-core.inc

View File

@ -7,7 +7,7 @@ SECTION = "devel"
LICENSE = "BSD" LICENSE = "BSD"
LIC_FILES_CHKSUM = "file://package.xml;beginline=15;endline=15;md5=d566ef916e9dedc494f5f793a6690ba5" LIC_FILES_CHKSUM = "file://package.xml;beginline=15;endline=15;md5=d566ef916e9dedc494f5f793a6690ba5"
DEPENDS = "dynamic-reconfigure python-rospkg" DEPENDS = "dynamic-reconfigure ${PYTHON_PN}-rospkg"
SRC_URI = "https://github.com/KristofRobot/${ROS_SPN}/archive/${PV}.tar.gz;downloadfilename=${ROS_SP}.tar.gz" SRC_URI = "https://github.com/KristofRobot/${ROS_SPN}/archive/${PV}.tar.gz;downloadfilename=${ROS_SP}.tar.gz"
SRC_URI[md5sum] = "4712cbe1d9d8bacd9eebfd51825ada36" SRC_URI[md5sum] = "4712cbe1d9d8bacd9eebfd51825ada36"
@ -17,4 +17,4 @@ S = "${WORKDIR}/${ROS_SP}"
inherit catkin inherit catkin
RDEPENDS_${PN} = "rospy tf sensor-msgs python-pyserial" RDEPENDS_${PN} = "rospy tf sensor-msgs ${PYTHON_PN}-pyserial"

View File

@ -0,0 +1,141 @@
From 2105ad5c201bacd9860ad21fa3b4de96eed0e124 Mon Sep 17 00:00:00 2001
From: Ruben Smits <ruben.smits@intermodalics.eu>
Date: Mon, 13 Feb 2017 18:02:23 +0100
Subject: [PATCH] Python3 compatibility (#10)
* Replace urlgrabber with urllib[2]
As urlgrabber is not supported for Python 3 replace it with either the built-in urllib (Python 2) or urllib2 (Python 3)
* Use rospkg instead of system call for rospack
* Add test for python functionality
* Fix rospkg dependency definition
Upstream-Status: Backported
---
package.xml | 2 +-
src/resource_retriever/__init__.py | 26 ++++++++++++++------------
test/CMakeLists.txt | 2 ++
test/test.py | 36 ++++++++++++++++++++++++++++++++++++
4 files changed, 53 insertions(+), 13 deletions(-)
create mode 100644 test/test.py
diff --git a/package.xml b/package.xml
index fc1d789..4b447dc 100644
--- a/package.xml
+++ b/package.xml
@@ -28,6 +28,6 @@
<run_depend>curl</run_depend>
<run_depend>rosconsole</run_depend>
<run_depend>roslib</run_depend>
- <run_depend>python-urlgrabber</run_depend>
+ <run_depend>python-rospkg</run_depend>
</package>
diff --git a/src/resource_retriever/__init__.py b/src/resource_retriever/__init__.py
index d92baca..747a63f 100644
--- a/src/resource_retriever/__init__.py
+++ b/src/resource_retriever/__init__.py
@@ -33,17 +33,16 @@
import roslib; roslib.load_manifest('resource_retriever')
import subprocess
-import urlgrabber, string
+import rospkg
+try:
+ from urllib.request import urlopen
+ from urllib.error import URLError
+except ImportError:
+ from urllib2 import urlopen
+ from urllib2 import URLError
PACKAGE_PREFIX = 'package://'
-
-def rospack_find(package):
- process = subprocess.Popen(['rospack', 'find', package], shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
- (stdout, stderr) = process.communicate()
- if len(stderr) > 0:
- raise Exception(stderr)
- else:
- return string.strip(stdout)
+r = rospkg.RosPack()
def get_filename(url, use_protocol=True ):
mod_url = url
@@ -55,7 +54,7 @@ def get_filename(url, use_protocol=True ):
package = mod_url[0:pos]
mod_url = mod_url[pos:]
- package_path = rospack_find(package)
+ package_path = r.get_path(package)
if use_protocol:
protocol = "file://"
@@ -65,5 +64,8 @@ def get_filename(url, use_protocol=True ):
return mod_url
def get(url):
- return urlgrabber.urlopen(get_filename(url))
-
+ filename = get_filename(url)
+ try:
+ return urlopen(filename).read()
+ except URLError:
+ raise Exception("Invalid URL: {}".format(filename))
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index f133bf6..e311f59 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -2,3 +2,5 @@ set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR})
catkin_add_gtest(${PROJECT_NAME}_utest test.cpp)
target_link_libraries(${PROJECT_NAME}_utest ${PROJECT_NAME})
+
+catkin_add_nosetests(test.py)
diff --git a/test/test.py b/test/test.py
new file mode 100644
index 0000000..ce1843f
--- /dev/null
+++ b/test/test.py
@@ -0,0 +1,36 @@
+import resource_retriever as r
+
+import os
+import rospkg
+from nose.tools import raises
+
+rospack = rospkg.RosPack()
+
+def test_get_by_package():
+ res = r.get("package://resource_retriever/test/test.txt")
+ assert len(res) == 1
+ assert res == 'A'.encode()
+
+def test_get_large_file():
+ res_path = os.path.join(rospack.get_path("resource_retriever"), "test/large_file.dat")
+ with open(res_path, 'w') as f:
+ for _ in range(1024*1024*50):
+ f.write('A')
+ res = r.get("package://resource_retriever/test/large_file.dat")
+ assert len(res) == 1024*1024*50
+
+def test_http():
+ res = r.get("http://packages.ros.org/ros.key")
+ assert len(res) > 0
+
+@raises(Exception)
+def test_invalid_file():
+ r.get("file://fail")
+
+@raises(Exception)
+def test_no_file():
+ r.get("package://roscpp")
+
+@raises(rospkg.common.ResourceNotFound)
+def test_invalid_package():
+ r.get("package://invalid_package_blah/test.xml")
--
2.9.3

View File

@ -6,7 +6,9 @@ LIC_FILES_CHKSUM = "file://package.xml;beginline=16;endline=16;md5=d566ef916e9de
DEPENDS = "curl rosconsole roslib" DEPENDS = "curl rosconsole roslib"
SRC_URI = "https://github.com/ros/${ROS_SPN}/archive/${PV}.tar.gz;downloadfilename=${ROS_SP}.tar.gz" SRC_URI = "https://github.com/ros/${ROS_SPN}/archive/${PV}.tar.gz;downloadfilename=${ROS_SP}.tar.gz \
file://0001-Python3-compatibility-10.patch \
"
SRC_URI[md5sum] = "1dffd39475ebe70b14390889d3b4b3c4" SRC_URI[md5sum] = "1dffd39475ebe70b14390889d3b4b3c4"
SRC_URI[sha256sum] = "5f00e95c5a086973efa25e26da9cee8f4b10b446fbb5eb6694b32b2201539866" SRC_URI[sha256sum] = "5f00e95c5a086973efa25e26da9cee8f4b10b446fbb5eb6694b32b2201539866"
@ -14,4 +16,4 @@ S = "${WORKDIR}/${ROS_SP}"
inherit catkin inherit catkin
RDEPENDS_${PN} = "python-urlgrabber" RDEPENDS_${PN} = "${PYTHON_PN}-rospkg"

View File

@ -4,7 +4,7 @@ SECTION = "devel"
LICENSE = "BSD" LICENSE = "BSD"
LIC_FILES_CHKSUM = "file://package.xml;beginline=10;endline=10;md5=d566ef916e9dedc494f5f793a6690ba5" LIC_FILES_CHKSUM = "file://package.xml;beginline=10;endline=10;md5=d566ef916e9dedc494f5f793a6690ba5"
RDEPENDS_${PN} = "python-xmlrpc python-threading python-rospkg rospy python-netifaces" RDEPENDS_${PN} = "${PYTHON_PN}-xmlrpc ${PYTHON_PN}-threading ${PYTHON_PN}-rospkg rospy ${PYTHON_PN}-netifaces"
require ros-comm.inc require ros-comm.inc

View File

@ -16,12 +16,12 @@ SRC_URI += "file://0001-increase-rosmaster-timeout.patch \
ROS_PKG_SUBDIR = "tools" ROS_PKG_SUBDIR = "tools"
RDEPENDS_${PN} = "\ RDEPENDS_${PN} = "\
python-textutils \ ${PYTHON_PN}-textutils \
python-logging \ ${PYTHON_PN}-logging \
python-threading \ ${PYTHON_PN}-threading \
python-rospkg \ ${PYTHON_PN}-rospkg \
rosgraph \ rosgraph \
python-pyyaml \ ${PYTHON_PN}-pyyaml \
roslib \ roslib \
rosclean \ rosclean \
rosmaster \ rosmaster \

View File

@ -4,7 +4,7 @@ SECTION = "devel"
LICENSE = "BSD" LICENSE = "BSD"
LIC_FILES_CHKSUM = "file://package.xml;beginline=23;endline=23;md5=d566ef916e9dedc494f5f793a6690ba5" LIC_FILES_CHKSUM = "file://package.xml;beginline=23;endline=23;md5=d566ef916e9dedc494f5f793a6690ba5"
RDEPENDS_${PN} = "std-msgs genpy python-logging python-pyyaml rosgraph roslib rosgraph-msgs roscpp" RDEPENDS_${PN} = "std-msgs genpy ${PYTHON_PN}-logging ${PYTHON_PN}-pyyaml rosgraph roslib rosgraph-msgs roscpp"
require ros-comm.inc require ros-comm.inc

View File

@ -3,7 +3,7 @@ SECTION = "devel"
LICENSE = "BSD" LICENSE = "BSD"
LIC_FILES_CHKSUM = "file://package.xml;beginline=8;endline=8;md5=d566ef916e9dedc494f5f793a6690ba5" LIC_FILES_CHKSUM = "file://package.xml;beginline=8;endline=8;md5=d566ef916e9dedc494f5f793a6690ba5"
DEPENDS = "boost python-nose" DEPENDS = "boost ${PYTHON_PN}-nose"
DEPENDS_class-native = "boost-native rosunit-native" DEPENDS_class-native = "boost-native rosunit-native"
require ros-comm.inc require ros-comm.inc

View File

@ -9,4 +9,4 @@ require ros.inc
ROS_PKG_SUBDIR = "core" ROS_PKG_SUBDIR = "core"
RDEPENDS_${PN} = "python-rospkg catkin-runtime" RDEPENDS_${PN} = "${PYTHON_PN}-rospkg catkin-runtime"

View File

@ -3,7 +3,7 @@ SECTION = "devel"
LICENSE = "BSD" LICENSE = "BSD"
LIC_FILES_CHKSUM = "file://package.xml;beginline=6;endline=6;md5=d566ef916e9dedc494f5f793a6690ba5" LIC_FILES_CHKSUM = "file://package.xml;beginline=6;endline=6;md5=d566ef916e9dedc494f5f793a6690ba5"
DEPENDS = "boost cmake-modules python-rospkg-native libtinyxml" DEPENDS = "boost cmake-modules ${PYTHON_PN}-rospkg-native libtinyxml"
SRC_URI = "https://github.com/ros/${ROS_SPN}/archive/${PV}.tar.gz;downloadfilename=${ROS_SP}.tar.gz" SRC_URI = "https://github.com/ros/${ROS_SPN}/archive/${PV}.tar.gz;downloadfilename=${ROS_SP}.tar.gz"
SRC_URI[md5sum] = "f415d53b620d35ce674959ac7616d202" SRC_URI[md5sum] = "f415d53b620d35ce674959ac7616d202"
@ -11,4 +11,4 @@ SRC_URI[sha256sum] = "a8fecbe03f9757510fe47137642e39a7c31b823d5bf7fa7890acc11691
inherit catkin inherit catkin
RDEPENDS_${PN} = "python-rosdep python-subprocess" RDEPENDS_${PN} = "${PYTHON_PN}-rosdep ${PYTHON_PN}-subprocess"

View File

@ -11,4 +11,4 @@ S = "${WORKDIR}/${ROS_SP}/urdf_parser_py"
inherit catkin inherit catkin
RDEPENDS_${PN} = "python-lxml" RDEPENDS_${PN} = "${PYTHON_PN}-lxml"

View File

@ -3,6 +3,10 @@ SECTION = "devel"
LICENSE = "BSD" LICENSE = "BSD"
LIC_FILES_CHKSUM = "file://package.xml;beginline=11;endline=11;md5=d566ef916e9dedc494f5f793a6690ba5" LIC_FILES_CHKSUM = "file://package.xml;beginline=11;endline=11;md5=d566ef916e9dedc494f5f793a6690ba5"
DEPENDS = "boost opencv rosconsole sensor-msgs python-numpy-native" DEPENDS = "boost opencv rosconsole sensor-msgs ${PYTHON_PN}-numpy-native"
# This option disables python2 support because we can't support both python2
# and python3 since OE upstream has disabled python2 bindings in Boost.
EXTRA_OECMAKE =+ "${@'-DANDROID=ON' if d.getVar('PYTHON_PN', True) != 'python3' else ''}"
require vision-opencv.inc require vision-opencv.inc