From 298337a973229f59adf6b126b27fb7937640ad16 Mon Sep 17 00:00:00 2001 From: Antoine Pitrou Date: Wed, 2 Sep 2026 15:33:27 +0200 Subject: [PATCH 1/2] GH-51138: [Python] Fix ccache efficiency --- ci/scripts/python_build.sh | 2 +- python/CMakeLists.txt | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/ci/scripts/python_build.sh b/ci/scripts/python_build.sh index f8c1af3982dd..50fb37db1f19 100755 --- a/ci/scripts/python_build.sh +++ b/ci/scripts/python_build.sh @@ -89,7 +89,7 @@ cp -aL "${source_dir}" "${python_build_dir}" pushd "${python_build_dir}" # - Cannot use build isolation as we want to use specific dependency versions # (e.g. Numpy, Pandas) on some CI jobs. -${PYTHON:-python} -m pip install --no-deps --no-build-isolation -vv -C cmake.build-type="${CMAKE_BUILD_TYPE:-Debug}" . +time ${PYTHON:-python} -m pip install --no-deps --no-build-isolation -vv -C cmake.build-type="${CMAKE_BUILD_TYPE:-Debug}" . popd if [ "${BUILD_DOCS_PYTHON}" == "ON" ]; then diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 4bea6e7d8d40..40aa62c79898 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -130,11 +130,14 @@ if(CCACHE_FOUND AND NOT CMAKE_C_COMPILER_LAUNCHER AND NOT CMAKE_CXX_COMPILER_LAUNCHER) message(STATUS "Using ccache: ${CCACHE_FOUND}") - set(CMAKE_C_COMPILER_LAUNCHER ${CCACHE_FOUND}) - set(CMAKE_CXX_COMPILER_LAUNCHER ${CCACHE_FOUND}) - # ARROW-3985: let ccache preserve C++ comments, because some of them may be - # meaningful to the compiler - set(ENV{CCACHE_COMMENTS} "1") + # 1. Let ccache preserve C++ comments, because some of them may be + # meaningful to the compiler (ARROW-3985) + # 2. Set ccache base_dir to the build output directory as it is typically + # a temporary directory, and would otherwise fail caching because of + # using different paths everytime. + set(ccache_command ${CCACHE_FOUND} keep_comments_cpp=true base_dir=${CMAKE_BINARY_DIR}) + set(CMAKE_C_COMPILER_LAUNCHER ${ccache_command}) + set(CMAKE_CXX_COMPILER_LAUNCHER ${ccache_command}) endif() # From a1df242910ff6328a6e718fe42a0a668a63c5e13 Mon Sep 17 00:00:00 2001 From: Antoine Pitrou Date: Thu, 3 Sep 2026 10:33:19 +0200 Subject: [PATCH 2/2] Use `cmake -E env` to set ccache configuration options --- python/CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 40aa62c79898..8eae91e0ed19 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -135,7 +135,11 @@ if(CCACHE_FOUND # 2. Set ccache base_dir to the build output directory as it is typically # a temporary directory, and would otherwise fail caching because of # using different paths everytime. - set(ccache_command ${CCACHE_FOUND} keep_comments_cpp=true base_dir=${CMAKE_BINARY_DIR}) + # Also, we use `cmake -E env` to set environment variables as the + # `ccache option=value ...` form of passing configuration options + # is not supported by ccache < 4.8. + set(ccache_command ${CMAKE_COMMAND} -E env CCACHE_COMMENTS=1 + CCACHE_BASEDIR=${CMAKE_BINARY_DIR} -- ${CCACHE_FOUND}) set(CMAKE_C_COMPILER_LAUNCHER ${ccache_command}) set(CMAKE_CXX_COMPILER_LAUNCHER ${ccache_command}) endif()