How do I get catkin to automatically build .so files when I run catkin_make?

asked 2020-04-06 15:27:54 -0500

desertdiver gravatar image

I have a few .pyx files that I'd like to build with catkin and Cython. So far I've been able to get catkin to create the c files but don't know how to get it to create the .so files. My node structure looks like this:

my node
|   |-1.pyx
|   |-2.pyx

Other files and directories have been omitted for brevity. The setup file looks like this:

from setuptools import setup
from catkin_pkg.python_setup import generate_distutils_setup
from Cython.Build import cythonize

setup_args = generate_distutils_setup(
    package_dir={'': 'src'})

The CMakeLists.txt has been modified to include catkin_python_setup()

I can run python build_ext --inplace manually and that then generates the .so files but would rather have catkin take care of it.

edit retag flag offensive close merge delete


Does #q108776 and the linked example repo help? With this (and some knowledge of cython, I guess this is required to get all things done), I've been able to create a python module from a cpp library. But as you want it the other way round I'm not sure this is all you need.

mgruhler gravatar image mgruhler  ( 2020-04-07 08:29:43 -0500 )edit

I've already checked the mentioned repo and found it hard to understand since I come from a python coding background with little experience in cmake. I suspect that I need to change a couple of things in the cmakelists.txt, and maybe add a cmakelists.txt in the src file, but I don't know what I should use from the repo code.

desertdiver gravatar image desertdiver  ( 2020-04-09 14:48:30 -0500 )edit