Skip to content

Commit 06c9445

Browse files
committed
diet CMake
Signed-off-by: MasatoSaeki <masato.saeki@tier4.jp>
1 parent 3aa3330 commit 06c9445

1 file changed

Lines changed: 19 additions & 68 deletions

File tree

driving_log_replayer_v2/CMakeLists.txt

Lines changed: 19 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -5,69 +5,23 @@ find_package(ament_cmake_python REQUIRED)
55
find_package(autoware_cmake REQUIRED)
66
autoware_package()
77

8-
# Extra Python packages (Pydantic v2, nuscenes, analyzer plotly, etc.): not fully covered by apt/rosdep.
9-
# Ubuntu 24.04+ (PEP 668): PIP_BREAK_SYSTEM_PACKAGES=1 allows pip into the same env as /usr/bin/python3
10-
# (typical for Autoware/colcon). Set OFF to skip if you pre-install (venv, custom image) or use rosdep+manual pip.
11-
option(
12-
DRIVING_LOG_REPLAYER_V2_INSTALL_PYTHON_DEPS
13-
"Run pip install -r ../requirements.txt during configure (recommended for colcon+ROS use)"
14-
ON
8+
set(ROS_REQUIREMENTS "${CMAKE_CURRENT_SOURCE_DIR}/../requirements.txt")
9+
set(PIP_CONSTRAINTS "${CMAKE_CURRENT_SOURCE_DIR}/../constraints-pip.txt")
10+
set(PIP_ENV
11+
"PIP_BREAK_SYSTEM_PACKAGES=1"
12+
"PIP_CONSTRAINT=${PIP_CONSTRAINTS}"
1513
)
14+
find_package(Python3 REQUIRED COMPONENTS Interpreter)
1615

17-
# requirements.txt / constraints-pip.txt: repository root (parent of this package)
18-
set(_DRIVING_LOG_REPLAYER_V2_REQUIREMENTS "${CMAKE_CURRENT_SOURCE_DIR}/../requirements.txt")
19-
set(_DRIVING_LOG_REPLAYER_V2_PIP_CONSTRAINTS "${CMAKE_CURRENT_SOURCE_DIR}/../constraints-pip.txt")
16+
execute_process(
17+
COMMAND ${CMAKE_COMMAND} -E env ${PIP_ENV}
18+
${Python3_EXECUTABLE} -m pip install -q -U --ignore-installed -r "${PIP_CONSTRAINTS}"
19+
)
2020

21-
if(DRIVING_LOG_REPLAYER_V2_INSTALL_PYTHON_DEPS AND EXISTS "${_DRIVING_LOG_REPLAYER_V2_REQUIREMENTS}")
22-
find_package(Python3 REQUIRED COMPONENTS Interpreter)
23-
# PIP_NO_CACHE_DIR: some CI/home layouts have a non-writable pip cache
24-
set(_dlr2_pip_env
25-
"PIP_BREAK_SYSTEM_PACKAGES=1"
26-
"PIP_NO_CACHE_DIR=1"
27-
"PIP_CONSTRAINT=${_DRIVING_LOG_REPLAYER_V2_PIP_CONSTRAINTS}"
28-
"PIP_BUILD_CONSTRAINT=${_DRIVING_LOG_REPLAYER_V2_PIP_CONSTRAINTS}"
29-
)
30-
set(_driving_log_replayer_v2_pip 0)
31-
# Python 3.12: old setuptools in pip build env hits pkgutil.ImpImporter; versions in constraints-pip.txt
32-
if(_driving_log_replayer_v2_pip EQUAL 0)
33-
execute_process(
34-
COMMAND ${CMAKE_COMMAND} -E env ${_dlr2_pip_env}
35-
${Python3_EXECUTABLE} -m pip install -q -U --ignore-installed -r "${_DRIVING_LOG_REPLAYER_V2_PIP_CONSTRAINTS}"
36-
RESULT_VARIABLE _driving_log_replayer_v2_pip
37-
)
38-
endif()
39-
if(_driving_log_replayer_v2_pip EQUAL 0)
40-
if(EXISTS "${_DRIVING_LOG_REPLAYER_V2_PIP_CONSTRAINTS}")
41-
# --ignore-installed: debian/apt python packages often have no pip RECORD (e.g. lark) so uninstall fails
42-
execute_process(
43-
COMMAND ${CMAKE_COMMAND} -E env ${_dlr2_pip_env}
44-
${Python3_EXECUTABLE} -m pip install -q --ignore-installed
45-
-c "${_DRIVING_LOG_REPLAYER_V2_PIP_CONSTRAINTS}"
46-
-r "${_DRIVING_LOG_REPLAYER_V2_REQUIREMENTS}"
47-
RESULT_VARIABLE _driving_log_replayer_v2_pip
48-
)
49-
else()
50-
execute_process(
51-
COMMAND ${CMAKE_COMMAND} -E env ${_dlr2_pip_env}
52-
${Python3_EXECUTABLE} -m pip install -q --ignore-installed -r "${_DRIVING_LOG_REPLAYER_V2_REQUIREMENTS}"
53-
RESULT_VARIABLE _driving_log_replayer_v2_pip
54-
)
55-
endif()
56-
endif()
57-
if(NOT _driving_log_replayer_v2_pip EQUAL 0)
58-
message(
59-
WARNING
60-
"pip for driving_log_replayer_v2 failed (exit ${_driving_log_replayer_v2_pip}). On Python 3.12: "
61-
"export PIP_BREAK_SYSTEM_PACKAGES=1 PIP_NO_CACHE_DIR=1 "
62-
"PIP_CONSTRAINT=${_DRIVING_LOG_REPLAYER_V2_PIP_CONSTRAINTS} "
63-
"PIP_BUILD_CONSTRAINT=${_DRIVING_LOG_REPLAYER_V2_PIP_CONSTRAINTS}; "
64-
"${Python3_EXECUTABLE} -m pip install -U --ignore-installed -r ${_DRIVING_LOG_REPLAYER_V2_PIP_CONSTRAINTS}; "
65-
"${Python3_EXECUTABLE} -m pip install --ignore-installed -c ${_DRIVING_LOG_REPLAYER_V2_PIP_CONSTRAINTS} -r "
66-
"${_DRIVING_LOG_REPLAYER_V2_REQUIREMENTS}. Or "
67-
"-DDRIVING_LOG_REPLAYER_V2_INSTALL_PYTHON_DEPS=OFF."
68-
)
69-
endif()
70-
endif()
21+
execute_process(
22+
COMMAND ${CMAKE_COMMAND} -E env ${PIP_ENV}
23+
${Python3_EXECUTABLE} -m pip install -q --ignore-installed -c "${PIP_CONSTRAINTS}" -r "${ROS_REQUIREMENTS}"
24+
)
7125

7226
if(BUILD_TESTING)
7327
find_package(ament_lint_auto REQUIRED)
@@ -101,14 +55,11 @@ install(PROGRAMS
10155
DESTINATION lib/${PROJECT_NAME}
10256
)
10357

104-
if(EXISTS "${_DRIVING_LOG_REPLAYER_V2_REQUIREMENTS}")
105-
install(FILES "${_DRIVING_LOG_REPLAYER_V2_REQUIREMENTS}"
106-
DESTINATION share/${PROJECT_NAME})
107-
endif()
108-
if(EXISTS "${_DRIVING_LOG_REPLAYER_V2_PIP_CONSTRAINTS}")
109-
install(FILES "${_DRIVING_LOG_REPLAYER_V2_PIP_CONSTRAINTS}"
110-
DESTINATION share/${PROJECT_NAME})
111-
endif()
58+
install(FILES "${ROS_REQUIREMENTS}"
59+
DESTINATION share/${PROJECT_NAME})
60+
61+
install(FILES "${PIP_CONSTRAINTS}"
62+
DESTINATION share/${PROJECT_NAME})
11263

11364
ament_auto_package(INSTALL_TO_SHARE
11465
launch

0 commit comments

Comments
 (0)