Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python: remove distutils use, fix #623 #624

Merged
merged 1 commit into from
Oct 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions python.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,8 @@ macro(FINDPYTHON)
# Provide some hints according to the current PYTHON_EXECUTABLE
if(NOT DEFINED PYTHON_INCLUDE_DIR)
execute_process(
COMMAND
"${PYTHON_EXECUTABLE}" "-c"
"import distutils.sysconfig as sysconfig; print(sysconfig.get_python_inc())"
COMMAND "${PYTHON_EXECUTABLE}" "-c"
"import sysconfig; print(sysconfig.get_path('include'))"
OUTPUT_VARIABLE PYTHON_INCLUDE_DIR
ERROR_QUIET)
string(STRIP "${PYTHON_INCLUDE_DIR}" PYTHON_INCLUDE_DIR)
Expand Down Expand Up @@ -217,9 +216,8 @@ macro(FINDPYTHON)
# defined
if(NOT DEFINED PYTHON_INCLUDE_DIR)
execute_process(
COMMAND
"${PYTHON_EXECUTABLE}" "-c"
"import distutils.sysconfig as sysconfig; print(sysconfig.get_python_inc())"
COMMAND "${PYTHON_EXECUTABLE}" "-c"
"import sysconfig; print(sysconfig.get_path('include'))"
OUTPUT_VARIABLE PYTHON_INCLUDE_DIR
ERROR_QUIET)
string(STRIP "${PYTHON_INCLUDE_DIR}" PYTHON_INCLUDE_DIR)
Expand Down Expand Up @@ -272,7 +270,7 @@ macro(FINDPYTHON)
)
else(PYTHON_STANDARD_LAYOUT)
set(PYTHON_SITELIB_CMD
"from distutils import sysconfig; print(sysconfig.get_python_lib(prefix='', plat_specific=False))"
"import sysconfig; from pathlib import Path; print(Path(sysconfig.get_path('purelib')).relative_to(sysconfig.get_path('data')))"
)
endif(PYTHON_STANDARD_LAYOUT)

Expand Down Expand Up @@ -306,7 +304,7 @@ macro(FINDPYTHON)
execute_process(
COMMAND
"${PYTHON_EXECUTABLE}" "-c"
"from distutils.sysconfig import get_config_var; print('.' + get_config_var('SOABI'))"
"from sysconfig import get_config_var; print('.' + get_config_var('SOABI'))"
OUTPUT_VARIABLE PYTHON_SOABI)
string(STRIP ${PYTHON_SOABI} PYTHON_SOABI)
endif(PYTHON_VERSION_MAJOR EQUAL 3 AND NOT WIN32)
Expand All @@ -317,7 +315,7 @@ macro(FINDPYTHON)
execute_process(
COMMAND
"${PYTHON_EXECUTABLE}" "-c"
"from distutils.sysconfig import get_config_var; print(get_config_var('EXT_SUFFIX'))"
"from sysconfig import get_config_var; print(get_config_var('EXT_SUFFIX'))"
OUTPUT_VARIABLE PYTHON_EXT_SUFFIX)
string(STRIP ${PYTHON_EXT_SUFFIX} PYTHON_EXT_SUFFIX)
endif(PYTHON_VERSION_MAJOR EQUAL 3)
Expand Down