ros / ros-overlay

Gentoo Overlay for ROS packages
33 stars 30 forks source link

camera_calibration_parsers and boost_python #581

Open awesomebytes opened 6 years ago

awesomebytes commented 6 years ago

I don't know what would be the approach here. In my Gentoo prefix I had emerged dev-libs/boost. But when I tried to emerge ros-kinetic/camera_calibration_parsers I got an error of not finding boost_python.

The full log of it emerging can be seen here: https://gist.github.com/awesomebytes/bb3bce149b16ea56488930ef242ad1fa

So... I tried with emerge --ask dev-libs/boost[python] which did install the libboost_python* stuff. But then I still can't build camera_calibration_parsers.

The .so files are there

~/gentoo $ find . -name libboost_python*
./usr/lib/libboost_python-3.5.so.1.65.0
./usr/lib/libboost_python-3.5-mt.so
./usr/lib/libboost_python-2.7.so
./usr/lib/libboost_python-3.5.so
./usr/lib/libboost_python-2.7-mt.so
./usr/lib/libboost_python-2.7.so.1.65.0

So is the stuff in ~/gentoo/usr/include/boost/python*.

awesomebytes commented 6 years ago

Just to test I changed the patch file: https://github.com/ros/ros-overlay/blob/master/ros-kinetic/camera_calibration_parsers/files/boost-python.patch

To not check for boost_python, just to see if it would compile. And it did!

+find_package(Boost REQUIRED COMPONENTS filesystem)

So this is an error on finding the package via CMake. (Aside from... for some reason my Gentoo prefix didn't emerge the python part from boost).

awesomebytes commented 6 years ago

Well, meanwhile I created:

~/gentoo/etc/portage/patches/ros-kinetic/camera_calibration_parsers-1.11.13/0001-Dirty-hack-to-move-forward-boost-python-is-installed.patch

From e826b31e8fa3d9953b2b83aa2fd497033ed655de Mon Sep 17 00:00:00 2001
From: Sammy Pfeiffer <sammypfeiffer@gmail.com>
Date: Thu, 26 Apr 2018 22:44:07 +1000
Subject: [PATCH] Dirty hack to move forward, boost python is actually there
 but CMake doesnt find it

---
 CMakeLists.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9ed94ef..dc2855c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -4,7 +4,7 @@ project(camera_calibration_parsers)
 find_package(catkin REQUIRED sensor_msgs rosconsole roscpp roscpp_serialization)

 find_package(PythonLibs REQUIRED)
-find_package(Boost REQUIRED COMPONENTS filesystem python)
+find_package(Boost REQUIRED COMPONENTS filesystem)

 include_directories(include ${catkin_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} ${PYTHON_INCLUDE_DIRS})

-- 
1.9.1

(Just learned this patches folder technique, they are applied after the ebuild patches).

awesomebytes commented 6 years ago

Note that this happens to cv_bridge also (and probably to any package trying to find_package boost_python).

I found a discussion about it here: https://gitlab.kitware.com/cmake/cmake/merge_requests/35

And a workaround here: https://forums.gentoo.org/viewtopic-t-948188-start-0.html

So... otherwise a workaround is:

# cd YOUR_EPREFIX
cd usr/lib
ln -s libboost_python-2.7.so libboost_python.so

So no package will complain again... it goes against Gentoo's slot thing of the Python versions tho.

It's less cumbersome than patching every single package linking to boost_python, so I'm going with this way.

pholthaus commented 6 years ago

I always thought the correct fix would be that CMakeLists.txt explicitly requests a specific python version, i.e.:

find_package(Boost REQUIRED COMPONENTS filesystem python27)

Then again, I don't know how to support that in gentoo. For myself, I simply created user patches like this in the mean time (because I only have python 2.7 enabled for ros):

https://github.com/pholthau/gentoo-patches/blob/master/ros-kinetic/camera_calibration_parsers-1.11.13/python.patch

Any thoughts?

CrawlerSpider commented 5 years ago

I get the following error:

I got the same

 * Package:    ros-melodic/camera_calibration_parsers-1.11.13
 * Repository: ros-overlay
 * Maintainer: hunter@openrobotics.org
 * Upstream:   jack.oquin@gmail.com https://github.com/ros-gbp/image_common/issues
 * USE:        amd64 elibc_glibc kernel_linux python_targets_python2_7 userland_GNU
 * FEATURES:   preserve-libs sandbox userpriv usersandbox
>>> Unpacking source...
>>> Unpacking camera_calibration_parsers-melodic-release-1.11.13.tar.gz to /var/tmp/portage/ros-melodic/camera_calibration_parsers-1.11.13/work
>>> Source unpacked in /var/tmp/portage/ros-melodic/camera_calibration_parsers-1.11.13/work
>>> Preparing source in /var/tmp/portage/ros-melodic/camera_calibration_parsers-1.11.13/work/camera_calibration_parsers-1.11.13 ...
>>> Source prepared.
>>> Configuring source in /var/tmp/portage/ros-melodic/camera_calibration_parsers-1.11.13/work/camera_calibration_parsers-1.11.13 ...
>>> Working in BUILD_DIR: "/var/tmp/portage/ros-melodic/camera_calibration_parsers-1.11.13/work/camera_calibration_parsers-1.11.13_build"
cmake -C /var/tmp/portage/ros-melodic/camera_calibration_parsers-1.11.13/work/camera_calibration_parsers-1.11.13_build/gentoo_common_config.cmake -G Unix Makefiles -DCMAKE_INSTALL_PREFIX=/usr -DCATKIN_ENABLE_TESTING=0 -DCATKIN_BUILD_BINARY_PACKAGE=1 -DCMAKE_PREFIX_PATH=/opt/ros/melodic -DCMAKE_INSTALL_PREFIX=/opt/ros/melodic -DCMAKE_BUILD_TYPE=Gentoo -DCMAKE_TOOLCHAIN_FILE=/var/tmp/portage/ros-melodic/camera_calibration_parsers-1.11.13/work/camera_calibration_parsers-1.11.13_build/gentoo_toolchain.cmake  /var/tmp/portage/ros-melodic/camera_calibration_parsers-1.11.13/work/camera_calibration_parsers-1.11.13
loading initial cache file /var/tmp/portage/ros-melodic/camera_calibration_parsers-1.11.13/work/camera_calibration_parsers-1.11.13_build/gentoo_common_config.cmake
-- The C compiler identification is GNU 7.3.1
-- The CXX compiler identification is GNU 7.3.1
-- Check for working C compiler: /usr/bin/x86_64-pc-linux-gnu-gcc
-- Check for working C compiler: /usr/bin/x86_64-pc-linux-gnu-gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/x86_64-pc-linux-gnu-g++
-- Check for working CXX compiler: /usr/bin/x86_64-pc-linux-gnu-g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Using CATKIN_DEVEL_PREFIX: /var/tmp/portage/ros-melodic/camera_calibration_parsers-1.11.13/work/camera_calibration_parsers-1.11.13_build/devel
-- Using CMAKE_PREFIX_PATH: /opt/ros/melodic
-- This workspace overlays: /opt/ros/melodic
-- Found PythonInterp: /usr/bin/python (found suitable version "3.6.6", minimum required is "2") 
-- Using PYTHON_EXECUTABLE: /usr/bin/python
-- Using default Python package layout
-- Found PY_em: /usr/lib64/python3.6/site-packages/em.py  
-- Using empy: /usr/lib64/python3.6/site-packages/em.py
-- Using CATKIN_ENABLE_TESTING: 0
-- catkin 0.7.14
-- Found PythonLibs: /usr/lib/libpython3.6m.so (found version "3.6.6") 
CMake Error at /usr/share/cmake/Modules/FindBoost.cmake:2048 (message):
  Unable to find the requested Boost libraries.

  Boost version: 1.65.0

  Boost include path: /usr/include

  Could not find the following Boost libraries:

          boost_python3

It seems that the problem is back

allenh1 commented 5 years ago

@crawlerspider what does equery uses boost show for you?

CrawlerSpider commented 5 years ago

The output of equery uses boost:

[ Legend : U - final flag setting for installation]
[        : I - package is installed with flag     ]
[ Colors : set, unset                             ]
 * Found these USE flags for dev-libs/boost-1.65.0:
 U I
 - - context                  : Build and install the Boost.Context (and Boost.Fiber) library and all other Boost libraries that depend on it
 - - debug                    : (Restricted to <dev-libs/boost-1.50.0-r3)
                                Build and install debug versions of the Boost libraries. These libraries are not used by default, and should not be used unless you're developing against Boost.
 - - doc                      : Install the full API documentation documentation. This takes over 200MB of extra disk space.
 + + icu                      : Enable ICU (Internationalization Components for Unicode) support, using dev-libs/icu
 - - mpi                      : Add MPI (Message Passing Interface) layer to the apps that support it
 + + nls                      : Build libboost_locale. This library requires compatible C library interfaces, which might not be provided by uClibc or other embedded libraries.
 + + python                   : Add optional support/bindings for the Python language
 + + python_targets_python2_7 : <unknown>
 - - python_targets_python3_4 : <unknown>
 - - python_targets_python3_5 : <unknown>
 + + python_targets_python3_6 : <unknown>
 - - static-libs              : Build static versions of dynamic libraries as well
 + + threads                  : Build multi-thread-compatible libraries instead of single-threaded only.
 - - tools                    : Build and install the boost tools (bcp, quickbook, inspect, wave)

I was able to compile the package using the following two lines: ln -s libboost_python-3.6.so libboost_python3.so ln -s libboost_python-2.7.so libboost_python.so

Hopefully a better solution will be found, since python 3.7 is already on the door, and this solution will fail.

awesomebytes commented 5 years ago

I just fell into this again. What's reported in this issue worked to go thru. Copied here for commodity.

# I needed this first
echo ">=dev-libs/boost-1.65.0 python" >> $EPREFIX/etc/portage/package.use
emerge dev-libs/boost[python]
cd $EPREFIX/usr/lib
ln -s libboost_python-2.7.so libboost_python.so
awesomebytes commented 5 years ago

@allenh1 You mentioned in https://github.com/ros/ros-overlay/issues/729 to add the USE flag [python] as a dependency,

I just made a PR for it: https://github.com/ros/rosdistro/pull/19738

concavegit commented 5 years ago

Since I struggled with getting boost_python to be detected with ros-melodic/camera_calibration_parsers, this seems like the most appropriate place to drop this patch which fixed my issue::

--- a/CMakeLists.txt    2019-05-25 22:00:46.181123322 +0000
+++ b/CMakeLists.txt    2019-05-25 21:59:59.053005605 +0000
@@ -5,16 +5,16 @@

 find_package(PythonLibs REQUIRED)
 if(PYTHONLIBS_VERSION_STRING VERSION_LESS 3)
-  find_package(Boost REQUIRED COMPONENTS filesystem python)
+  find_package(Boost REQUIRED COMPONENTS filesystem python27)
 else()
    if(PYTHONLIBS_VERSION_STRING VERSION_GREATER 3.6)
-     find_package(Boost REQUIRED COMPONENTS filesystem python-3.6)
+     find_package(Boost REQUIRED COMPONENTS filesystem python36)
    else()
        if(PYTHONLIBS_VERSION_STRING VERSION_GREATER 3.5)
-         find_package(Boost REQUIRED COMPONENTS filesystem python-3.5)
+         find_package(Boost REQUIRED COMPONENTS filesystem python35)
        else()
            if(PYTHONLIBS_VERSION_STRING VERSION_GREATER 3.4)
-             find_package(Boost REQUIRED COMPONENTS filesystem python-3.4)
+             find_package(Boost REQUIRED COMPONENTS filesystem python34)
            else()
              message(FATAL_ERROR, "At least Python 3.4 is needed, please consider migrating.")
            endif()

I would pull request this, but I am not sure about the generality of this patch.

tenspd137 commented 5 years ago

The patch is correct, but for some reason it is not yet out in the overlay....

allenh1 commented 5 years ago

I would pull request this, but I am not sure about the generality of this patch.

This is precisely my concern. I don't think it's less general than what was already there, however, so I'm open to a PR with it if someone wants to do so.

flabrosse commented 3 years ago

Same problem with ros-noetic/camera_calibration_parsers. Everything finds python3_6 and is happy with it apart from the boost_python library.

Can't we parse the PYTHONLIBS_VERSION_STRING string and remove the '.' and then concatenate to "python"?

flabrosse commented 3 years ago

Something like that?

string(REPLACE . "" PYTHONLIBS_VERSION_STRING PYTHON_VER)
set(PYTHON_FULL "python"${PYTHON_VER})
find_package(Boost REQUIRED COMPONENTS filesystem ${PYTHON_FULL})
flabrosse commented 3 years ago

No, won't work because PYTHONLIBS_VERSION_STRING is the python version, not the boost python version. Maybe the original patch is best. I'll apply it and do a PR when tested.

flabrosse commented 3 years ago

PR #1008.

flabrosse commented 3 years ago

And obviously, now that I'm creating ebuilds for 3_7 and 3_8, this bites back... There has to be a better solution...

allenh1 commented 3 years ago

@flabrosse I think there needs to be some superflore changes -- that should ease the effort.

flabrosse commented 3 years ago

I was fearing this. All done now, just need to update some of my code to check things work. Unfortunately, rather busy right now. If you have time to update the packages, I can rerun my script and re-apply manually the various additional changes needed. This might also solve issues relating to other packages that I have not yet looked at (different issues, not python related).

flabrosse commented 3 years ago

@allenh1 if you had time to update all the packages ("superflore changes"), that would be great. I now have most of the needed packages installed but am hitting issues likely due to upgrades on other packages. For example bag.py is doing:

from Cryptodome.Cipher import AES

It seems that this needs to be replaced by

from Crypto.Cipher import AES

I don't know how many more packages will be like that, and it could be that this has been fixed in more recent versions of the ROS packages. So I would not to have to patch too many if this is not needed.

I would do the "superflore changes" but I have no idea what this entails and have no time to look into it I'm afraid.

allenh1 commented 3 years ago

@flabrosse I'll try and make that happen for you!

Sorry this has been such a hassle.