1 |
commit: 7f354a0c3f96b77f28ea303007b2f7b7d5d53824 |
2 |
Author: Alexis Ballier <aballier <AT> gentoo <DOT> org> |
3 |
AuthorDate: Thu Jul 6 21:22:18 2017 +0000 |
4 |
Commit: Alexis Ballier <aballier <AT> gentoo <DOT> org> |
5 |
CommitDate: Fri Jul 7 07:10:28 2017 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=7f354a0c |
7 |
|
8 |
ros-catkin.eclass: Use only a single python implementation for all ROS packages. |
9 |
|
10 |
Use only python 2.7: that is the version supported by OSRF. |
11 |
Multi-python the way we did it was not working well, it ended up loading python libs from different interpreters causing weird errors. |
12 |
Add ros-catkin_python_setup function. |
13 |
|
14 |
eclass/ros-catkin.eclass | 142 ++++++++++++++++++----------------------------- |
15 |
1 file changed, 53 insertions(+), 89 deletions(-) |
16 |
|
17 |
diff --git a/eclass/ros-catkin.eclass b/eclass/ros-catkin.eclass |
18 |
index 0972270c415..e6a66be8568 100644 |
19 |
--- a/eclass/ros-catkin.eclass |
20 |
+++ b/eclass/ros-catkin.eclass |
21 |
@@ -42,36 +42,25 @@ if [ "${PV#9999}" != "${PV}" ] ; then |
22 |
SCM="git-r3" |
23 |
fi |
24 |
|
25 |
-# @ECLASS-VARIABLE: PYTHON_COMPAT |
26 |
-# @DESCRIPTION: |
27 |
-# Tells the eclass the package has python code and forwards it to python-r1.eclass. |
28 |
-PYTHON_ECLASS="" |
29 |
-CATKIN_PYTHON_USEDEP="" |
30 |
-if [ -n "${PYTHON_COMPAT}" ] ; then |
31 |
- PYTHON_ECLASS="python-r1" |
32 |
-fi |
33 |
+# This should be temporary. ROS only really works with one global python |
34 |
+# version. The idea here is to have a ROS_COMPAT in the same vein as |
35 |
+# PYTHON_COMPAT where packages would define what distro they can work on, then |
36 |
+# we'd have ros_distro_gentoo_python_2_7 & co plus the OSRF ones (lunar, etc.). |
37 |
+# Note that this uncondtionally pulls python but in the ROS world there will |
38 |
+# most certainly be something pulling python anyway. |
39 |
+PYTHON_COMPAT=( python2_7 ) |
40 |
|
41 |
-inherit ${SCM} ${PYTHON_ECLASS} cmake-utils flag-o-matic |
42 |
+inherit ${SCM} python-r1 cmake-utils flag-o-matic |
43 |
|
44 |
-CATKIN_DO_PYTHON_MULTIBUILD="" |
45 |
-if [ -n "${PYTHON_COMPAT}" ] ; then |
46 |
- CATKIN_PYTHON_USEDEP="[${PYTHON_USEDEP}]" |
47 |
- CATKIN_DO_PYTHON_MULTIBUILD="yes" |
48 |
- REQUIRED_USE="${PYTHON_REQUIRED_USE}" |
49 |
-fi |
50 |
+REQUIRED_USE="${PYTHON_REQUIRED_USE}" |
51 |
|
52 |
IUSE="test" |
53 |
-RDEPEND="" |
54 |
+RDEPEND="${PYTHON_DEPS}" |
55 |
DEPEND="${RDEPEND} |
56 |
- dev-util/catkin${CATKIN_PYTHON_USEDEP} |
57 |
- dev-python/empy${CATKIN_PYTHON_USEDEP} |
58 |
+ dev-util/catkin[${PYTHON_USEDEP}] |
59 |
+ dev-python/empy[${PYTHON_USEDEP}] |
60 |
" |
61 |
|
62 |
-if [ -n "${CATKIN_DO_PYTHON_MULTIBUILD}" ] ; then |
63 |
- RDEPEND="${RDEPEND} ${PYTHON_DEPS}" |
64 |
- DEPEND="${DEPEND} ${PYTHON_DEPS}" |
65 |
-fi |
66 |
- |
67 |
# @ECLASS-VARIABLE: CATKIN_HAS_MESSAGES |
68 |
# @DESCRIPTION: |
69 |
# Set it to a non-empty value before inherit to tell the eclass the package has messages to build. |
70 |
@@ -85,16 +74,16 @@ fi |
71 |
if [ -n "${CATKIN_HAS_MESSAGES}" ] ; then |
72 |
IUSE="${IUSE} +ros_messages_python +ros_messages_cxx ros_messages_eus ros_messages_lisp ros_messages_nodejs" |
73 |
RDEPEND="${RDEPEND} |
74 |
- ros_messages_cxx? ( dev-ros/gencpp:=${CATKIN_PYTHON_USEDEP} ) |
75 |
- ros_messages_eus? ( dev-ros/geneus:=${CATKIN_PYTHON_USEDEP} ) |
76 |
- ros_messages_python? ( dev-ros/genpy:=${CATKIN_PYTHON_USEDEP} ) |
77 |
- ros_messages_lisp? ( dev-ros/genlisp:=${CATKIN_PYTHON_USEDEP} ) |
78 |
- ros_messages_nodejs? ( dev-ros/gennodejs:=${CATKIN_PYTHON_USEDEP} ) |
79 |
+ ros_messages_cxx? ( dev-ros/gencpp:= dev-ros/gencpp[${PYTHON_USEDEP}] ) |
80 |
+ ros_messages_eus? ( dev-ros/geneus:= dev-ros/geneus[${PYTHON_USEDEP}] ) |
81 |
+ ros_messages_python? ( dev-ros/genpy:= dev-ros/genpy[${PYTHON_USEDEP}] ) |
82 |
+ ros_messages_lisp? ( dev-ros/genlisp:= dev-ros/genlisp[${PYTHON_USEDEP}] ) |
83 |
+ ros_messages_nodejs? ( dev-ros/gennodejs:= dev-ros/gennodejs[${PYTHON_USEDEP}] ) |
84 |
dev-ros/message_runtime |
85 |
" |
86 |
DEPEND="${DEPEND} ${RDEPEND} |
87 |
dev-ros/message_generation |
88 |
- dev-ros/genmsg${CATKIN_PYTHON_USEDEP} |
89 |
+ dev-ros/genmsg[${PYTHON_USEDEP}] |
90 |
" |
91 |
if [ -n "${CATKIN_MESSAGES_TRANSITIVE_DEPS}" ] ; then |
92 |
for i in ${CATKIN_MESSAGES_TRANSITIVE_DEPS} ; do |
93 |
@@ -147,7 +136,7 @@ HOMEPAGE="http://wiki.ros.org/${PN}" |
94 |
# by installing a recursive CMakeLists.txt to handle bundles. |
95 |
ros-catkin_src_prepare() { |
96 |
# If no multibuild, just use cmake IN_SOURCE support |
97 |
- [ -n "${CATKIN_IN_SOURCE_BUILD}" ] && [ -z "${CATKIN_DO_PYTHON_MULTIBUILD}" ] && export CMAKE_IN_SOURCE_BUILD=yes |
98 |
+ [ -n "${CATKIN_IN_SOURCE_BUILD}" ] && export CMAKE_IN_SOURCE_BUILD=yes |
99 |
|
100 |
cmake-utils_src_prepare |
101 |
|
102 |
@@ -155,31 +144,20 @@ ros-catkin_src_prepare() { |
103 |
catkin_init_workspace || die |
104 |
fi |
105 |
|
106 |
- # If python multibuild, copy the sources |
107 |
- [ -n "${CATKIN_IN_SOURCE_BUILD}" ] && [ -n "${CATKIN_DO_PYTHON_MULTIBUILD}" ] && python_copy_sources |
108 |
- |
109 |
# Most packages require C++11 these days. Do it here, in src_prepare so that |
110 |
# ebuilds can override it in src_configure. |
111 |
append-cxxflags '-std=c++11' |
112 |
} |
113 |
|
114 |
-# @FUNCTION: ros-catkin_src_configure_internal |
115 |
+# @FUNCTION: ros-catkin_python_setup |
116 |
# @DESCRIPTION: |
117 |
-# Internal decoration of cmake-utils_src_configure to handle multiple python installs. |
118 |
-ros-catkin_src_configure_internal() { |
119 |
- if [ -n "${CATKIN_DO_PYTHON_MULTIBUILD}" ] ; then |
120 |
- local sitedir="$(python_get_sitedir)" |
121 |
- local mycmakeargs=( |
122 |
- "${mycmakeargs[@]}" |
123 |
- -DPYTHON_EXECUTABLE="${PYTHON}" |
124 |
- -DPYTHON_INSTALL_DIR="${sitedir#${EPREFIX}/usr/}" |
125 |
- ) |
126 |
- python_export PYTHON_SCRIPTDIR |
127 |
- if [ -n "${CATKIN_IN_SOURCE_BUILD}" ] ; then |
128 |
- export CMAKE_USE_DIR="${BUILD_DIR}" |
129 |
- fi |
130 |
- fi |
131 |
- cmake-utils_src_configure "${@}" |
132 |
+# Sets up python environment for ROS packages. |
133 |
+ros-catkin_python_setup() { |
134 |
+ # Todo: Need to match this with ros distro. |
135 |
+ local pyimpl="${PYTHON_COMPAT[0]}" |
136 |
+ python_export "${pyimpl}" EPYTHON PYTHON |
137 |
+ python_wrapper_setup |
138 |
+ python_export PYTHON_SCRIPTDIR |
139 |
} |
140 |
|
141 |
# @VARIABLE: mycatkincmakeargs |
142 |
@@ -192,6 +170,8 @@ ros-catkin_src_configure_internal() { |
143 |
# @DESCRIPTION: |
144 |
# Configures a catkin-based package. |
145 |
ros-catkin_src_configure() { |
146 |
+ ros-catkin_python_setup |
147 |
+ |
148 |
export CATKIN_PREFIX_PATH="${EPREFIX}/usr" |
149 |
export ROS_ROOT="${EPREFIX}/usr/share/ros" |
150 |
if [ -n "${CATKIN_HAS_MESSAGES}" ] ; then |
151 |
@@ -203,38 +183,42 @@ ros-catkin_src_configure() { |
152 |
use ros_messages_nodejs || ROS_LANG_DISABLE="${ROS_LANG_DISABLE}:gennodejs" |
153 |
export ROS_LANG_DISABLE |
154 |
fi |
155 |
+ |
156 |
local mycmakeargs=( |
157 |
"$(cmake-utils_use test CATKIN_ENABLE_TESTING)" |
158 |
"-DCATKIN_BUILD_BINARY_PACKAGE=ON" |
159 |
"-DCATKIN_PREFIX_PATH=${SYSROOT:-${EROOT}}/usr" |
160 |
"${mycatkincmakeargs[@]}" |
161 |
) |
162 |
- if [ -n "${CATKIN_DO_PYTHON_MULTIBUILD}" ] ; then |
163 |
- python_foreach_impl ros-catkin_src_configure_internal "${@}" |
164 |
- else |
165 |
- ros-catkin_src_configure_internal "${@}" |
166 |
+ |
167 |
+ local sitedir="$(python_get_sitedir)" |
168 |
+ mycmakeargs+=( |
169 |
+ -DPYTHON_EXECUTABLE="${PYTHON}" |
170 |
+ -DPYTHON_INSTALL_DIR="${sitedir#${EPREFIX}/usr/}" |
171 |
+ ) |
172 |
+ if [ -n "${CATKIN_IN_SOURCE_BUILD}" ] ; then |
173 |
+ export CMAKE_USE_DIR="${BUILD_DIR}" |
174 |
fi |
175 |
+ |
176 |
+ cmake-utils_src_configure "${@}" |
177 |
} |
178 |
|
179 |
# @FUNCTION: ros-catkin_src_compile |
180 |
# @DESCRIPTION: |
181 |
# Builds a catkin-based package. |
182 |
ros-catkin_src_compile() { |
183 |
- if [ -n "${CATKIN_DO_PYTHON_MULTIBUILD}" ] ; then |
184 |
- if [ -n "${CATKIN_IN_SOURCE_BUILD}" ] ; then |
185 |
- export CMAKE_USE_DIR="${BUILD_DIR}" |
186 |
- fi |
187 |
- python_foreach_impl cmake-utils_src_compile "${@}" |
188 |
- else |
189 |
- cmake-utils_src_compile "${@}" |
190 |
- fi |
191 |
+ ros-catkin_python_setup |
192 |
+ cmake-utils_src_compile "${@}" |
193 |
} |
194 |
|
195 |
-# @FUNCTION: ros-catkin_src_test_internal |
196 |
+# @FUNCTION: ros-catkin_src_test |
197 |
# @DESCRIPTION: |
198 |
-# Decorator around cmake-utils_src_test to ensure tests are built before running them. |
199 |
-ros-catkin_src_test_internal() { |
200 |
+# Run the tests of a catkin-based package. |
201 |
+ros-catkin_src_test() { |
202 |
cd "${BUILD_DIR}" || die |
203 |
+ |
204 |
+ ros-catkin_python_setup |
205 |
+ |
206 |
# Regenerate env for tests, PYTHONPATH is not set properly otherwise... |
207 |
if [ -f catkin_generated/generate_cached_setup.py ] ; then |
208 |
einfo "Regenerating setup_cached.sh for tests" |
209 |
@@ -248,25 +232,16 @@ ros-catkin_src_test_internal() { |
210 |
cmake-utils_src_test "${@}" |
211 |
} |
212 |
|
213 |
-# @FUNCTION: ros-catkin_src_test |
214 |
+# @FUNCTION: ros-catkin_src_install |
215 |
# @DESCRIPTION: |
216 |
-# Run the tests of a catkin-based package. |
217 |
-ros-catkin_src_test() { |
218 |
- if [ -n "${CATKIN_DO_PYTHON_MULTIBUILD}" ] ; then |
219 |
- python_foreach_impl ros-catkin_src_test_internal "${@}" |
220 |
- else |
221 |
- ros-catkin_src_test_internal "${@}" |
222 |
- fi |
223 |
-} |
224 |
+# Installs a catkin-based package. |
225 |
+ros-catkin_src_install() { |
226 |
+ ros-catkin_python_setup |
227 |
|
228 |
-# @FUNCTION: ros-catkin_src_install_with_python |
229 |
-# @DESCRIPTION: |
230 |
-# Decorator around cmake-utils_src_install to ensure python scripts are properly handled w.r.t. python-exec2. |
231 |
-ros-catkin_src_install_with_python() { |
232 |
- python_export PYTHON_SCRIPTDIR |
233 |
if [ -n "${CATKIN_IN_SOURCE_BUILD}" ] ; then |
234 |
export CMAKE_USE_DIR="${BUILD_DIR}" |
235 |
fi |
236 |
+ |
237 |
cmake-utils_src_install "${@}" |
238 |
if [ ! -f "${T}/.catkin_python_symlinks_generated" -a -d "${D}/${PYTHON_SCRIPTDIR}" ]; then |
239 |
dodir /usr/bin |
240 |
@@ -277,15 +252,4 @@ ros-catkin_src_install_with_python() { |
241 |
fi |
242 |
} |
243 |
|
244 |
-# @FUNCTION: ros-catkin_src_install |
245 |
-# @DESCRIPTION: |
246 |
-# Installs a catkin-based package. |
247 |
-ros-catkin_src_install() { |
248 |
- if [ -n "${CATKIN_DO_PYTHON_MULTIBUILD}" ] ; then |
249 |
- python_foreach_impl ros-catkin_src_install_with_python "${@}" |
250 |
- else |
251 |
- cmake-utils_src_install "${@}" |
252 |
- fi |
253 |
-} |
254 |
- |
255 |
EXPORT_FUNCTIONS src_prepare src_configure src_compile src_test src_install |