Skip to content

Commit 634041d

Browse files
committed
fix(builder): guard python_env activation with existence check for CI environments
1 parent c7389d0 commit 634041d

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

‎microros_utils/library_builder.py‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ def build_dev_environment(self):
107107
print("Building micro-ROS dev dependencies")
108108
self.patch_dev_sources()
109109

110-
colcon_command = '. {} && colcon build --merge-install --packages-ignore-regex=.*_cpp --cmake-args -DPython3_EXECUTABLE=`which python` -DBUILD_TESTING=OFF'.format(self.python_env)
110+
prefix = f". {self.python_env} && " if (self.python_env and os.path.exists(self.python_env)) else ""
111+
colcon_command = '{}colcon build --merge-install --packages-ignore-regex=.*_cpp --cmake-args -DPython3_EXECUTABLE=`which python` -DBUILD_TESTING=OFF'.format(prefix)
111112
command = "cd {} && {}".format(self.dev_folder, colcon_command)
112113
result = run_cmd(command)
113114

@@ -179,7 +180,8 @@ def build_mcu_environment(self, meta_file, toolchain_file, user_meta = ""):
179180
self.patch_mcu_sources()
180181

181182
common_meta_path = self.library_folder + '/metas/common.meta'
182-
colcon_command = '. {} && colcon build --merge-install --packages-ignore-regex=.*_cpp --metas {} {} {} --cmake-args -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=OFF -DTHIRDPARTY=ON -DBUILD_SHARED_LIBS=OFF -DBUILD_TESTING=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE={} -DPython3_EXECUTABLE=`which python`'.format(self.python_env, common_meta_path, meta_file, user_meta, toolchain_file)
183+
prefix = f". {self.python_env} && " if (self.python_env and os.path.exists(self.python_env)) else ""
184+
colcon_command = '{}colcon build --merge-install --packages-ignore-regex=.*_cpp --metas {} {} {} --cmake-args -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=OFF -DTHIRDPARTY=ON -DBUILD_SHARED_LIBS=OFF -DBUILD_TESTING=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE={} -DPython3_EXECUTABLE=`which python`'.format(prefix, common_meta_path, meta_file, user_meta, toolchain_file)
183185
command = "cd {} && . {}/install/setup.sh && {}".format(self.mcu_folder, self.dev_folder, colcon_command)
184186
result = run_cmd(command, env=self.env)
185187

0 commit comments

Comments
 (0)