mirror of
https://github.com/pybind/pybind11.git
synced 2026-03-14 20:27:47 +00:00
fix(cmake): findpython issues and 3.12 support for pybind11_find_import (#4941)
* fix(cmake): findpython issues and 3.12 support for pybind11_find_import Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> * Update pybind11NewTools.cmake --------- Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
This commit is contained in:
@@ -218,8 +218,15 @@ if(NOT _pybind11_nopython)
|
||||
|
||||
execute_process(
|
||||
COMMAND
|
||||
${${_Python}_EXECUTABLE} -c
|
||||
"from pkg_resources import get_distribution; print(get_distribution('${PYPI_NAME}').version)"
|
||||
${${_Python}_EXECUTABLE} -c "
|
||||
try:
|
||||
from importlib.metadata import version
|
||||
except ImportError:
|
||||
from pkg_resources import get_distribution
|
||||
def version(s):
|
||||
return get_distribution(s).version
|
||||
print(version('${PYPI_NAME}'))
|
||||
"
|
||||
RESULT_VARIABLE RESULT_PRESENT
|
||||
OUTPUT_VARIABLE PKG_VERSION
|
||||
ERROR_QUIET)
|
||||
|
||||
Reference in New Issue
Block a user