Skip to content

Commit aee9acf

Browse files
authored
Use sysconfig directly to determine python lib dir (#378)
The distutils package is deprecated and will be removed in Python 3.12. We can achieve the same behavior using sysconfig directly. Signed-off-by: Scott K Logan <[email protected]>
1 parent 199ac7a commit aee9acf

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

ament_cmake_python/ament_cmake_python-extras.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ macro(_ament_cmake_python_get_python_install_dir)
4444
if(NOT DEFINED PYTHON_INSTALL_DIR)
4545
# avoid storing backslash in cached variable since CMake will interpret it as escape character
4646
set(_python_code
47-
"from distutils.sysconfig import get_python_lib"
4847
"import os"
49-
"print(os.path.relpath(get_python_lib(prefix='${CMAKE_INSTALL_PREFIX}'), start='${CMAKE_INSTALL_PREFIX}').replace(os.sep, '/'))"
48+
"import sysconfig"
49+
"print(os.path.relpath(sysconfig.get_path('purelib', vars={'base': '${CMAKE_INSTALL_PREFIX}'}), start='${CMAKE_INSTALL_PREFIX}').replace(os.sep, '/'))"
5050
)
5151
get_executable_path(_python_interpreter Python3::Interpreter CONFIGURE)
5252
execute_process(

0 commit comments

Comments
 (0)