mvukov / rules_ros2

Build ROS 2 with Bazel
Apache License 2.0
75 stars 42 forks source link

Use our own Python for specific py_binaries and py_tests #344

Open lalten opened 1 week ago

lalten commented 1 week ago

Split off https://github.com/mvukov/rules_ros2/pull/238

OK so this one is a slightly bigger change. What's happening is that it changes the rules_ros2 machinery to use its own bundled 3.10 interpreter. This way we can ensure that all the pip requirements we depend on will actually work. The other reason for this change, including the funky python_register_multi_toolchains that registers only a single version, is that this makes it compatible to the Bzlmod way of pinning the interpreter like this.

See also https://rules-python.readthedocs.io/en/latest/toolchains.html#library-modules-with-version-constraints

mvukov commented 1 week ago

OK, I see the big picture here. Please consider this: one writes a python launch file, uses deps for Python != 3.10 (e.g. numpy) and uses that file to launch nodes. What happens is that ros2_launch implicitly depends on Python 3.10 (if the user paid attention to look at which Python rules_ros2 depends on) and the launch app depends on both deps for Python 3.10 and some other Python. This asks for trouble.

This situation may even fail at build time because multi_toolchains go through Bazel transitions -- never tried this TBH.

WDYT?