Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Usage with ament_cmake_python? #35

Open
JWCS opened this issue May 8, 2023 · 1 comment
Open

Usage with ament_cmake_python? #35

JWCS opened this issue May 8, 2023 · 1 comment

Comments

@JWCS
Copy link

JWCS commented May 8, 2023

I tend to write / have a bunch of hybridized packages, C++ and python.
This might sound noob-ish, but I am not familiar with a better way to do this (combined); I've only ever used requirements.txt or poetry ❤️ . And for ros, all best practices go out the door, and everything is installed globally, the setup.cfg/py too complicated, so I've tried to avoid that. I just discovered this wonderful repo today, so I'm willing to convert!

My current solution has been adding python to cmake like the tutorial, then (as in doc) way at the bottom of the CMakeLists.txt, adding the following lines:

install(DIRECTORY scripts/ DESTINATION lib/${PROJECT_NAME})
ament_python_install_package(${PROJECT_NAME}_py)

For dependency installation, each package has a requirements.txt, and I can install / update all my packages either with a rosdep -yr (silencing failures), then a find . -name "requirements.txt" -exec pip install -r {} \;, and then... deal with whatever remaining problems manually.

What "build" steps can be moved into the CMakeLists, and how does using poetry with this change environments?
What marginal work needs to be done in the pyproject.toml that's not in package.xml/CMakeLists.txt, and what is required, but yes is redundant?

@velovix
Copy link
Member

velovix commented May 9, 2023

Thanks for bringing this up! C++/Python hybrid packages are a blind spot for me as I've never used them, so I could be wrong here, but I don't see a straightforward way for this extension to support this workflow.

When Colcon is building a package, each installed Colcon extension inspects the package and decides if it is the right extension for the job. For hybrid packages like yours, I believe the CMake Colcon extension is used and the ament_python_install_package function takes care of the Python side of things independent of Colcon. If this extension wanted to support hybrid packages, it would have to override the CMake extension, do all the things it normally does, and then hook in somewhere to install Python dependencies. That sounds hard to accomplish.

This might sound noob-ish, but I am not familiar with a better way to do this (combined)

Out of curiosity, what's to stop you from splitting your hybrid package into two "pure" packages? Could you tell me more about your requirements?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants