From c0077930c02de358ce401db10f9c08bbcc3a07be Mon Sep 17 00:00:00 2001 From: Ben Wolsieffer Date: Mon, 7 Nov 2022 13:00:32 -0500 Subject: [PATCH] buildEnv: add Python packages to environment and set LD_LIBRARY_PATH Now that we set PYTHONPATH in the wrappers, we can add Python packages to the environment as well. This is necessary to make certain ros2cli commands work (e.g. ros2launch). Also, ROS2 loads the RMW implementation dynamically, so we need to set LD_LIBRARY_PATH in the wrappers. --- distros/build-env/default.nix | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/distros/build-env/default.nix b/distros/build-env/default.nix index 907256c57b..e183d5a674 100644 --- a/distros/build-env/default.nix +++ b/distros/build-env/default.nix @@ -3,10 +3,10 @@ # otherwise cause ROS_PACKAGE_PATH or other environment variables to become too # long. # -# All ROS packages in the 'paths' closure are added to the environment, while -# other packages are propagated. This makes it usable in nix-shell, while -# preventing ROS_PACKAGE_PATH and CMAKE_PREFIX_PATH from becoming too large due -# to a huge number of ROS packages. +# All ROS and Python packages in the 'paths' closure are added to the +# environment, while other packages are propagated. This makes it usable in +# nix-shell, while preventing ROS_PACKAGE_PATH and CMAKE_PREFIX_PATH from +# becoming too large due to a huge number of ROS packages. # # By default, all binaries in the environment are wrapped, setting the relevant # ROS environment variables, allowing use outside of nix-shell. @@ -18,7 +18,7 @@ with lib; let propagatePackages = packages: let validPackages = filter (d: d != null) packages; - partitionedPackages = partition (d: d.rosPackage or false) validPackages; + partitionedPackages = partition (d: (d.rosPackage or false) || (hasAttr "pythonModule" d)) validPackages; rosPackages = partitionedPackages.right; otherPackages = partitionedPackages.wrong; rosPropagatedPackages = unique (concatLists (catAttrs "propagatedBuildInputs" rosPackages)); @@ -58,6 +58,7 @@ let makeWrapper "$file" "$link" \ --prefix PATH : "$out/bin" \ + --prefix LD_LIBRARY_PATH : "$out/lib" \ --prefix PYTHONPATH : "$out/${python.sitePackages}" \ --prefix CMAKE_PREFIX_PATH : "$out" \ --prefix AMENT_PREFIX_PATH : "$out" \