rules_ros icon indicating copy to clipboard operation
rules_ros copied to clipboard

Install pyyaml for ros2_config rule

Open bluka4 opened this issue 1 year ago • 4 comments

To run the generate_ros2_config.py script during repository setup, the host system needs to have Python3 and pyyaml modules installed.

  • Check if the python3 binary exists in the PATH and error if not
  • Check if the pyyaml module is installed, and if not, install it via pip

The current solution is inspired by:

  • https://groups.google.com/g/bazel-discuss/c/KOz7jMQb09A

    The typical way to call any executable from a repository rule is to just require it to be in the user's $PATH environment variable, and then call it directly.

  • official maven_rules checks if the mvn binary is present on the host system

bluka4 avatar Aug 02 '24 09:08 bluka4

@bluka4 We have an issue here: we are using the system-installed python3 interpreter. I think we should actually change this in a way that no python interpreter is called during repo setup at all. The lock script should do all the heavy lifting and generate code that does not require any Python processing. So if the lock script directly produces a .bzl file, we should be good.

kilian-funk avatar Aug 02 '24 13:08 kilian-funk

@bluka4 We have an issue here: we are using the system-installed python3 interpreter. I think we should actually change this in a way that no python interpreter is called during repo setup at all. The lock script should do all the heavy lifting and generate code that does not require any Python processing. So if the lock script directly produces a .bzl file, we should be good.

@kilian-funk I drafted approach here: #15. Let's continue our discussion there.

bluka4 avatar Aug 05 '24 10:08 bluka4

@kilian-funk @bluka4 why not use the @python_interpreter//:python3 alias to get the Bazel-provided python3 executable instead of the system one?

evan-flynn-apexai avatar Aug 05 '24 18:08 evan-flynn-apexai

@kilian-funk @bluka4 why not use the @python_interpreter//:python3 alias to get the Bazel-provided python3 executable instead of the system one?

@evan-flynn-apexai, this is executed during the Bazel repository setup, so Bazel labels are unavailable at this phase. In repository_ctx we only have execute function that is simply running shell commands. But I might miss something; please correct me if I am wrong.

bluka4 avatar Aug 05 '24 18:08 bluka4