diff --git a/controller_manager/CMakeLists.txt b/controller_manager/CMakeLists.txt
index 80747eeb4d..e8bc782b18 100644
--- a/controller_manager/CMakeLists.txt
+++ b/controller_manager/CMakeLists.txt
@@ -6,6 +6,7 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
endif()
find_package(ament_cmake REQUIRED)
+find_package(ament_cmake_python REQUIRED)
find_package(ament_cmake_core REQUIRED)
find_package(ament_index_cpp REQUIRED)
find_package(controller_interface REQUIRED)
@@ -53,14 +54,6 @@ install(DIRECTORY include/
DESTINATION include
)
-install(PROGRAMS
- scripts/spawner
- scripts/spawner.py # Deprecated
- scripts/unspawner
- scripts/unspawner.py # Deprecated
- DESTINATION lib/${PROJECT_NAME}
-)
-
if(BUILD_TESTING)
find_package(ament_cmake_gmock REQUIRED)
find_package(ament_cmake_gtest REQUIRED)
@@ -160,7 +153,7 @@ if(BUILD_TESTING)
endif()
# Install Python modules
-ament_python_install_package(${PROJECT_NAME})
+ament_python_install_package(${PROJECT_NAME} SCRIPTS_DESTINATION lib/${PROJECT_NAME})
ament_export_libraries(
controller_manager
diff --git a/controller_manager/scripts/spawner.py b/controller_manager/controller_manager/spawner.py
old mode 100755
new mode 100644
similarity index 100%
rename from controller_manager/scripts/spawner.py
rename to controller_manager/controller_manager/spawner.py
diff --git a/controller_manager/scripts/unspawner.py b/controller_manager/controller_manager/unspawner.py
old mode 100755
new mode 100644
similarity index 100%
rename from controller_manager/scripts/unspawner.py
rename to controller_manager/controller_manager/unspawner.py
diff --git a/controller_manager/package.xml b/controller_manager/package.xml
index adfbea7dbc..1dae4cbfe1 100644
--- a/controller_manager/package.xml
+++ b/controller_manager/package.xml
@@ -8,6 +8,7 @@
Apache License 2.0
ament_cmake
+ ament_cmake_python
ament_index_cpp
controller_interface
diff --git a/controller_manager/scripts/spawner b/controller_manager/scripts/spawner
deleted file mode 100755
index ae4d8d33e5..0000000000
--- a/controller_manager/scripts/spawner
+++ /dev/null
@@ -1,21 +0,0 @@
-#!/usr/bin/env python3
-# Copyright 2021 PAL Robotics S.L.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-import sys
-from spawner import main
-
-if __name__ == "__main__":
- ret = main()
- sys.exit(ret)
diff --git a/controller_manager/scripts/unspawner b/controller_manager/scripts/unspawner
deleted file mode 100755
index 4227e7b7b6..0000000000
--- a/controller_manager/scripts/unspawner
+++ /dev/null
@@ -1,21 +0,0 @@
-#!/usr/bin/env python3
-# Copyright 2021 PAL Robotics S.L.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-import sys
-from unspawner import main
-
-if __name__ == "__main__":
- ret = main()
- sys.exit(ret)
diff --git a/controller_manager/setup.cfg b/controller_manager/setup.cfg
new file mode 100644
index 0000000000..ef02ee65bd
--- /dev/null
+++ b/controller_manager/setup.cfg
@@ -0,0 +1,4 @@
+[options.entry_points]
+console_scripts =
+ spawner = controller_manager.spawner:main
+ unspawner = controller_manager.unspawner:main