mvukov / rules_ros

Build ROS (1) with Bazel
Apache License 2.0
21 stars 9 forks source link

Add roslaunch python lib #6

Closed hofbi closed 4 months ago

hofbi commented 4 months ago

Similar to https://github.com/mvukov/rules_ros/pull/5, this adds the missing roslanch python library

mvukov commented 4 months ago

This is not going to work for various reasons with Bazel. One of them is that roslaunch changes cwd to $ROS_HOME, which doesn't work with Bazel. Instead, you should use a cleaned up version from this repo: //third_party/legacy_roslaunch.

hofbi commented 4 months ago

I tried you proposal, but still get

import roslaunch
E   ModuleNotFoundError: No module named 'roslaunch'
mvukov commented 4 months ago

OK, I'll look at this.

mvukov commented 4 months ago

BTW, you need to do the following:

from third_party import legacy_roslaunch # as roslaunch
hofbi commented 4 months ago

What if I cannot change the python code, but only the BUILD.bazel. Having it as propoased in this PR allows for import roslaunch

mvukov commented 4 months ago

Good point.

The proposed Bazel change is fine, it's that the original roslaunch code is not going to fit well with Bazel way of working. So, you'll need to set up a dummy roslaunch package+bazel target (in e.g. your repo) that will depend on //third_party/legacy_roslaunch from this repo and can implement a single __init__.py that only has e.g. from third_party.legacy_roslaunch import *.

Eventually we should have such a package in this repo for use-cases like yours.

hofbi commented 4 months ago

Happy to contribute this here. Where should we put it?

mvukov commented 4 months ago

Fixed. You should depend on //third_party/ros:roslaunch.

BTW, I did a cleanup/modernization. Take a look at .bazelrc for instance.