Skip to content

Commit dc4717b

Browse files
authored
fix: module extension detection for python 3.10 (#3663)
* Fix module extension detection for python 3.10 * Fix for python < 3.10 * Use importlib
1 parent 07103d6 commit dc4717b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

tools/pybind11NewTools.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ if(NOT DEFINED PYTHON_MODULE_EXTENSION)
110110
execute_process(
111111
COMMAND
112112
"${${_Python}_EXECUTABLE}" "-c"
113-
"from distutils import sysconfig as s;print(s.get_config_var('EXT_SUFFIX') or s.get_config_var('SO'))"
113+
"import sys, importlib; s = importlib.import_module('distutils.sysconfig' if sys.version_info < (3, 10) else 'sysconfig'); print(s.get_config_var('EXT_SUFFIX') or s.get_config_var('SO'))"
114114
OUTPUT_VARIABLE _PYTHON_MODULE_EXTENSION
115115
ERROR_VARIABLE _PYTHON_MODULE_EXTENSION_ERR
116116
OUTPUT_STRIP_TRAILING_WHITESPACE)

0 commit comments

Comments
 (0)