mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-23 05:35:13 +00:00
Merge branch 'pybind:master' into master
This commit is contained in:
commit
4cc3b04690
@ -289,7 +289,21 @@ if(PYBIND11_INSTALL)
|
|||||||
|
|
||||||
# pkg-config support
|
# pkg-config support
|
||||||
if(NOT prefix_for_pc_file)
|
if(NOT prefix_for_pc_file)
|
||||||
|
if(IS_ABSOLUTE "${CMAKE_INSTALL_DATAROOTDIR}")
|
||||||
set(prefix_for_pc_file "${CMAKE_INSTALL_PREFIX}")
|
set(prefix_for_pc_file "${CMAKE_INSTALL_PREFIX}")
|
||||||
|
else()
|
||||||
|
set(pc_datarootdir "${CMAKE_INSTALL_DATAROOTDIR}")
|
||||||
|
if(CMAKE_VERSION VERSION_LESS 3.20)
|
||||||
|
set(prefix_for_pc_file "\${pcfiledir}/..")
|
||||||
|
while(pc_datarootdir)
|
||||||
|
get_filename_component(pc_datarootdir "${pc_datarootdir}" DIRECTORY)
|
||||||
|
string(APPEND prefix_for_pc_file "/..")
|
||||||
|
endwhile()
|
||||||
|
else()
|
||||||
|
cmake_path(RELATIVE_PATH CMAKE_INSTALL_PREFIX BASE_DIRECTORY CMAKE_INSTALL_DATAROOTDIR
|
||||||
|
OUTPUT_VARIABLE prefix_for_pc_file)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
join_paths(includedir_for_pc_file "\${prefix}" "${CMAKE_INSTALL_INCLUDEDIR}")
|
join_paths(includedir_for_pc_file "\${prefix}" "${CMAKE_INSTALL_INCLUDEDIR}")
|
||||||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/tools/pybind11.pc.in"
|
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/tools/pybind11.pc.in"
|
||||||
|
@ -57,7 +57,7 @@ def tests_packaging(session: nox.Session) -> None:
|
|||||||
Run the packaging tests.
|
Run the packaging tests.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
session.install("-r", "tests/requirements.txt", "--prefer-binary")
|
session.install("-r", "tests/requirements.txt")
|
||||||
session.run("pytest", "tests/extra_python_package", *session.posargs)
|
session.run("pytest", "tests/extra_python_package", *session.posargs)
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,10 +1,15 @@
|
|||||||
build==0.8.0
|
--only-binary=:all:
|
||||||
numpy==1.21.5; platform_python_implementation=="PyPy" and sys_platform=="linux" and python_version=="3.7"
|
build~=0.9; python_version=="3.6"
|
||||||
numpy==1.19.3; platform_python_implementation!="PyPy" and python_version=="3.6"
|
build~=1.0; python_version>="3.7"
|
||||||
numpy==1.21.5; platform_python_implementation!="PyPy" and python_version>="3.7" and python_version<"3.10"
|
numpy~=1.20.0; python_version=="3.7" and platform_python_implementation=="PyPy"
|
||||||
numpy==1.22.2; platform_python_implementation!="PyPy" and python_version>="3.10" and python_version<"3.11"
|
numpy~=1.23.0; python_version=="3.8" and platform_python_implementation=="PyPy"
|
||||||
pytest==7.0.0; platform_python_implementation!="PyPy" and python_version=="3.6"
|
numpy~=1.25.0; python_version=="3.9" and platform_python_implementation=='PyPy'
|
||||||
pytest==7.2.0; platform_python_implementation!="PyPy" and python_version>="3.7"
|
numpy~=1.19.3; platform_python_implementation!="PyPy" and python_version=="3.6"
|
||||||
|
numpy~=1.21.5; platform_python_implementation!="PyPy" and python_version>="3.7" and python_version<"3.10"
|
||||||
|
numpy~=1.22.2; platform_python_implementation!="PyPy" and python_version=="3.10"
|
||||||
|
numpy~=1.26.0; platform_python_implementation!="PyPy" and python_version>="3.11"
|
||||||
|
pytest~=7.0
|
||||||
pytest-timeout
|
pytest-timeout
|
||||||
scipy==1.5.4; platform_python_implementation!="PyPy" and python_version<"3.10"
|
scipy~=1.5.4; platform_python_implementation!="PyPy" and python_version<"3.10"
|
||||||
scipy==1.10.0; platform_python_implementation!="PyPy" and python_version=="3.10"
|
scipy~=1.8.0; platform_python_implementation!="PyPy" and python_version=="3.10"
|
||||||
|
scipy~=1.11.1; platform_python_implementation!="PyPy" and python_version>="3.11"
|
||||||
|
@ -218,8 +218,15 @@ if(NOT _pybind11_nopython)
|
|||||||
|
|
||||||
execute_process(
|
execute_process(
|
||||||
COMMAND
|
COMMAND
|
||||||
${${_Python}_EXECUTABLE} -c
|
${${_Python}_EXECUTABLE} -c "
|
||||||
"from pkg_resources import get_distribution; print(get_distribution('${PYPI_NAME}').version)"
|
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
|
RESULT_VARIABLE RESULT_PRESENT
|
||||||
OUTPUT_VARIABLE PKG_VERSION
|
OUTPUT_VARIABLE PKG_VERSION
|
||||||
ERROR_QUIET)
|
ERROR_QUIET)
|
||||||
@ -300,21 +307,24 @@ function(_pybind11_generate_lto target prefer_thin_lto)
|
|||||||
set(cxx_append ";-fno-fat-lto-objects")
|
set(cxx_append ";-fno-fat-lto-objects")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(CMAKE_SYSTEM_PROCESSOR MATCHES "ppc64le" OR CMAKE_SYSTEM_PROCESSOR MATCHES "mips64")
|
if(prefer_thin_lto)
|
||||||
set(NO_FLTO_ARCH TRUE)
|
set(thin "=thin")
|
||||||
else()
|
else()
|
||||||
set(NO_FLTO_ARCH FALSE)
|
set(thin "")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang"
|
if(CMAKE_SYSTEM_PROCESSOR MATCHES "ppc64le" OR CMAKE_SYSTEM_PROCESSOR MATCHES "mips64")
|
||||||
AND prefer_thin_lto
|
# Do nothing
|
||||||
AND NOT NO_FLTO_ARCH)
|
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES emscripten)
|
||||||
|
# This compile is very costly when cross-compiling, so set this without checking
|
||||||
|
set(PYBIND11_LTO_CXX_FLAGS "-flto${thin}${cxx_append}")
|
||||||
|
set(PYBIND11_LTO_LINKER_FLAGS "-flto${thin}${linker_append}")
|
||||||
|
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||||
_pybind11_return_if_cxx_and_linker_flags_work(
|
_pybind11_return_if_cxx_and_linker_flags_work(
|
||||||
HAS_FLTO_THIN "-flto=thin${cxx_append}" "-flto=thin${linker_append}"
|
HAS_FLTO_THIN "-flto${thin}${cxx_append}" "-flto=${thin}${linker_append}"
|
||||||
PYBIND11_LTO_CXX_FLAGS PYBIND11_LTO_LINKER_FLAGS)
|
PYBIND11_LTO_CXX_FLAGS PYBIND11_LTO_LINKER_FLAGS)
|
||||||
endif()
|
endif()
|
||||||
|
if(NOT HAS_FLTO_THIN)
|
||||||
if(NOT HAS_FLTO_THIN AND NOT NO_FLTO_ARCH)
|
|
||||||
_pybind11_return_if_cxx_and_linker_flags_work(
|
_pybind11_return_if_cxx_and_linker_flags_work(
|
||||||
HAS_FLTO "-flto${cxx_append}" "-flto${linker_append}" PYBIND11_LTO_CXX_FLAGS
|
HAS_FLTO "-flto${cxx_append}" "-flto${linker_append}" PYBIND11_LTO_CXX_FLAGS
|
||||||
PYBIND11_LTO_LINKER_FLAGS)
|
PYBIND11_LTO_LINKER_FLAGS)
|
||||||
|
@ -39,12 +39,23 @@ if(NOT Python_FOUND AND NOT Python3_FOUND)
|
|||||||
set(_pybind11_dev_component Development.Module OPTIONAL_COMPONENTS Development.Embed)
|
set(_pybind11_dev_component Development.Module OPTIONAL_COMPONENTS Development.Embed)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# Callers need to be able to access Python_EXECUTABLE
|
||||||
|
set(_pybind11_global_keyword "")
|
||||||
|
if(NOT is_config AND NOT DEFINED Python_ARTIFACTS_INTERACTIVE)
|
||||||
|
set(Python_ARTIFACTS_INTERACTIVE TRUE)
|
||||||
|
if(NOT CMAKE_VERSION VERSION_LESS 3.24)
|
||||||
|
set(_pybind11_global_keyword "GLOBAL")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
find_package(Python 3.6 REQUIRED COMPONENTS Interpreter ${_pybind11_dev_component}
|
find_package(Python 3.6 REQUIRED COMPONENTS Interpreter ${_pybind11_dev_component}
|
||||||
${_pybind11_quiet})
|
${_pybind11_quiet} ${_pybind11_global_keyword})
|
||||||
|
|
||||||
# If we are in submodule mode, export the Python targets to global targets.
|
# If we are in submodule mode, export the Python targets to global targets.
|
||||||
# If this behavior is not desired, FindPython _before_ pybind11.
|
# If this behavior is not desired, FindPython _before_ pybind11.
|
||||||
if(NOT is_config)
|
if(NOT is_config
|
||||||
|
AND NOT Python_ARTIFACTS_INTERACTIVE
|
||||||
|
AND _pybind11_global_keyword STREQUAL "")
|
||||||
if(TARGET Python::Python)
|
if(TARGET Python::Python)
|
||||||
set_property(TARGET Python::Python PROPERTY IMPORTED_GLOBAL TRUE)
|
set_property(TARGET Python::Python PROPERTY IMPORTED_GLOBAL TRUE)
|
||||||
endif()
|
endif()
|
||||||
@ -53,6 +64,22 @@ if(NOT Python_FOUND AND NOT Python3_FOUND)
|
|||||||
set_property(TARGET Python::Module PROPERTY IMPORTED_GLOBAL TRUE)
|
set_property(TARGET Python::Module PROPERTY IMPORTED_GLOBAL TRUE)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# Explicitly export version for callers (including our own functions)
|
||||||
|
if(NOT is_config AND Python_ARTIFACTS_INTERACTIVE)
|
||||||
|
set(Python_VERSION
|
||||||
|
"${Python_VERSION}"
|
||||||
|
CACHE INTERNAL "")
|
||||||
|
set(Python_VERSION_MAJOR
|
||||||
|
"${Python_VERSION_MAJOR}"
|
||||||
|
CACHE INTERNAL "")
|
||||||
|
set(Python_VERSION_MINOR
|
||||||
|
"${Python_VERSION_MINOR}"
|
||||||
|
CACHE INTERNAL "")
|
||||||
|
set(Python_VERSION_PATCH
|
||||||
|
"${Python_VERSION_PATCH}"
|
||||||
|
CACHE INTERNAL "")
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(Python_FOUND)
|
if(Python_FOUND)
|
||||||
|
Loading…
Reference in New Issue
Block a user