diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cd0f33d27..af5a29d62 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,6 +17,8 @@ env: PIP_ONLY_BINARY: numpy FORCE_COLOR: 3 PYTEST_TIMEOUT: 300 + # For cmake: + VERBOSE: 1 jobs: # This is the "main" test suite, which tests a large number of different @@ -106,7 +108,6 @@ jobs: - name: Configure C++11 ${{ matrix.args }} run: > cmake -S . -B . - -DCMAKE_VERBOSE_MAKEFILE=ON -DPYBIND11_WERROR=ON -DPYBIND11_SIMPLE_GIL_MANAGEMENT=ON -DDOWNLOAD_CATCH=ON @@ -136,7 +137,6 @@ jobs: - name: Configure C++17 run: > cmake -S . -B build2 - -DCMAKE_VERBOSE_MAKEFILE=ON -DPYBIND11_WERROR=ON -DPYBIND11_SIMPLE_GIL_MANAGEMENT=OFF -DDOWNLOAD_CATCH=ON @@ -159,7 +159,6 @@ jobs: - name: Configure (unstable ABI) run: > cmake -S . -B build3 - -DCMAKE_VERBOSE_MAKEFILE=ON -DPYBIND11_WERROR=ON -DDOWNLOAD_CATCH=ON -DDOWNLOAD_EIGEN=ON @@ -246,7 +245,6 @@ jobs: SETUPTOOLS_USE_DISTUTILS: stdlib run: > cmake -S . -B build - -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_BUILD_TYPE=Debug -DPYBIND11_WERROR=ON -DDOWNLOAD_CATCH=ON @@ -311,7 +309,6 @@ jobs: shell: bash run: > cmake -S . -B build - -DCMAKE_VERBOSE_MAKEFILE=ON -DPYBIND11_WERROR=ON -DDOWNLOAD_CATCH=ON -DCMAKE_CXX_STANDARD=${{ matrix.std }} @@ -344,7 +341,7 @@ jobs: run: apt-get update && DEBIAN_FRONTEND="noninteractive" apt-get install -y cmake git python3-dev python3-pytest python3-numpy - name: Configure - run: cmake -S . -B build -DCMAKE_VERBOSE_MAKEFILE=ON -DPYBIND11_CUDA_TESTS=ON -DPYBIND11_WERROR=ON -DDOWNLOAD_CATCH=ON + run: cmake -S . -B build -DPYBIND11_CUDA_TESTS=ON -DPYBIND11_WERROR=ON -DDOWNLOAD_CATCH=ON - name: Build run: cmake --build build -j2 --verbose @@ -382,7 +379,7 @@ jobs: # run: | # source /etc/profile.d/modules.sh # module load /opt/nvidia/hpc_sdk/modulefiles/nvhpc/20.11 -# cmake -S . -B build -DCMAKE_VERBOSE_MAKEFILE=ON -DDOWNLOAD_CATCH=ON -DCMAKE_CXX_STANDARD=14 -DPYTHON_EXECUTABLE=$(python3 -c "import sys; print(sys.executable)") +# cmake -S . -B build -DDOWNLOAD_CATCH=ON -DCMAKE_CXX_STANDARD=14 -DPYTHON_EXECUTABLE=$(python3 -c "import sys; print(sys.executable)") # # - name: Build # run: cmake --build build -j 2 --verbose @@ -480,7 +477,6 @@ jobs: shell: bash run: > cmake -S . -B build - -DCMAKE_VERBOSE_MAKEFILE=ON -DPYBIND11_WERROR=ON -DDOWNLOAD_CATCH=ON -DCMAKE_CXX_STANDARD=${{ matrix.std }} @@ -535,7 +531,6 @@ jobs: run: | set +e; source /opt/intel/oneapi/setvars.sh; set -e cmake -S . -B build-11 \ - -DCMAKE_VERBOSE_MAKEFILE=ON \ -DPYBIND11_WERROR=ON \ -DDOWNLOAD_CATCH=ON \ -DDOWNLOAD_EIGEN=OFF \ @@ -568,7 +563,6 @@ jobs: run: | set +e; source /opt/intel/oneapi/setvars.sh; set -e cmake -S . -B build-17 \ - -DCMAKE_VERBOSE_MAKEFILE=ON \ -DPYBIND11_WERROR=ON \ -DDOWNLOAD_CATCH=ON \ -DDOWNLOAD_EIGEN=OFF \ @@ -635,7 +629,6 @@ jobs: shell: bash run: > cmake -S . -B build - -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_BUILD_TYPE=MinSizeRel -DPYBIND11_WERROR=ON -DDOWNLOAD_CATCH=ON @@ -783,7 +776,6 @@ jobs: run: > cmake -S . -B build -G "Visual Studio 16 2019" -A Win32 - -DCMAKE_VERBOSE_MAKEFILE=ON -DPYBIND11_WERROR=ON -DDOWNLOAD_CATCH=ON -DDOWNLOAD_EIGEN=ON @@ -837,7 +829,6 @@ jobs: run: > cmake -S . -B build -G "Visual Studio 16 2019" -A Win32 - -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_BUILD_TYPE=Debug -DPYBIND11_WERROR=ON -DDOWNLOAD_CATCH=ON @@ -878,7 +869,6 @@ jobs: - name: Configure C++20 run: > cmake -S . -B build - -DCMAKE_VERBOSE_MAKEFILE=ON -DPYBIND11_WERROR=ON -DDOWNLOAD_CATCH=ON -DDOWNLOAD_EIGEN=ON @@ -930,7 +920,7 @@ jobs: - name: Configure C++11 # LTO leads to many undefined reference like # `pybind11::detail::function_call::function_call(pybind11::detail::function_call&&) - run: cmake -G "MinGW Makefiles" -DCMAKE_CXX_STANDARD=11 -DCMAKE_VERBOSE_MAKEFILE=ON -DPYBIND11_WERROR=ON -DDOWNLOAD_CATCH=ON -S . -B build + run: cmake -G "MinGW Makefiles" -DCMAKE_CXX_STANDARD=11 -DPYBIND11_WERROR=ON -DDOWNLOAD_CATCH=ON -S . -B build - name: Build C++11 run: cmake --build build -j 2 @@ -948,7 +938,7 @@ jobs: run: git clean -fdx - name: Configure C++14 - run: cmake -G "MinGW Makefiles" -DCMAKE_CXX_STANDARD=14 -DCMAKE_VERBOSE_MAKEFILE=ON -DPYBIND11_WERROR=ON -DDOWNLOAD_CATCH=ON -S . -B build2 + run: cmake -G "MinGW Makefiles" -DCMAKE_CXX_STANDARD=14 -DPYBIND11_WERROR=ON -DDOWNLOAD_CATCH=ON -S . -B build2 - name: Build C++14 run: cmake --build build2 -j 2 @@ -966,7 +956,7 @@ jobs: run: git clean -fdx - name: Configure C++17 - run: cmake -G "MinGW Makefiles" -DCMAKE_CXX_STANDARD=17 -DCMAKE_VERBOSE_MAKEFILE=ON -DPYBIND11_WERROR=ON -DDOWNLOAD_CATCH=ON -S . -B build3 + run: cmake -G "MinGW Makefiles" -DCMAKE_CXX_STANDARD=17 -DPYBIND11_WERROR=ON -DDOWNLOAD_CATCH=ON -S . -B build3 - name: Build C++17 run: cmake --build build3 -j 2 @@ -1027,7 +1017,6 @@ jobs: - name: Configure Clang run: > cmake -G Ninja -S . -B . - -DCMAKE_VERBOSE_MAKEFILE=ON -DPYBIND11_WERROR=OFF -DPYBIND11_SIMPLE_GIL_MANAGEMENT=OFF -DDOWNLOAD_CATCH=ON @@ -1093,7 +1082,6 @@ jobs: - name: CMake Configure run: > cmake -S . -B . - -DCMAKE_VERBOSE_MAKEFILE=ON -DPYBIND11_WERROR=ON -DPYBIND11_SIMPLE_GIL_MANAGEMENT=OFF -DDOWNLOAD_CATCH=ON diff --git a/.github/workflows/configure.yml b/.github/workflows/configure.yml index 05e972c75..29b041168 100644 --- a/.github/workflows/configure.yml +++ b/.github/workflows/configure.yml @@ -9,6 +9,10 @@ on: - stable - v* +env: + # For cmake: + VERBOSE: 1 + jobs: # This tests various versions of CMake in various combinations, to make sure # the configure step passes. diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index 31d893c47..b18474bc3 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -14,6 +14,8 @@ on: env: FORCE_COLOR: 3 + # For cmake: + VERBOSE: 1 jobs: pre-commit: diff --git a/.github/workflows/upstream.yml b/.github/workflows/upstream.yml index 366284acf..a15861ee4 100644 --- a/.github/workflows/upstream.yml +++ b/.github/workflows/upstream.yml @@ -11,6 +11,8 @@ concurrency: env: PIP_ONLY_BINARY: numpy + # For cmake: + VERBOSE: 1 jobs: standard: diff --git a/docs/changelog.rst b/docs/changelog.rst index 7d6d0c0f5..9ff7281bc 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -15,6 +15,60 @@ IN DEVELOPMENT Changes will be summarized here periodically. +Version 2.10.2 (Dec 20, 2022) +----------------------------- + +Changes: + +* ``scoped_interpreter`` constructor taking ``PyConfig``. + `#4330 `_ + +* ``pybind11/eigen/tensor.h`` adds converters to and from ``Eigen::Tensor`` and + ``Eigen::TensorMap``. + `#4201 `_ + +* ``PyGILState_Check()``'s were integrated to ``pybind11::handle`` + ``inc_ref()`` & ``dec_ref()``. The added GIL checks are guarded by + ``PYBIND11_ASSERT_GIL_HELD_INCREF_DECREF``, which is the default only if + ``NDEBUG`` is not defined. + `#4246 `_ + +* Add option for enable/disable enum members in docstring. + `#2768 `_ + +* Fixed typing of ``KeysView``, ``ValuesView`` and ``ItemsView`` in ``bind_map``. + `#4353 `_ + +Bug fixes: + +* Bug fix affecting only Python 3.6 under very specific, uncommon conditions: + move ``PyEval_InitThreads()`` call to the correct location. + `#4350 `_ + +* Fix segfault bug when passing foreign native functions to functional.h. + `#4254 `_ + +Build system improvements: + +* Support setting PYTHON_LIBRARIES manually for Windows ARM cross-compilation + (classic mode). + `#4406 `_ + +* Extend IPO/LTO detection for ICX (a.k.a IntelLLVM) compiler. + `#4402 `_ + +* Allow calling ``find_package(pybind11 CONFIG)`` multiple times from separate + directories in the same CMake project and properly link Python (new mode). + `#4401 `_ + +* ``multiprocessing_set_spawn`` in pytest fixture for added safety. + `#4377 `_ + +* Fixed a bug in two pybind11/tools cmake scripts causing "Unknown arguments specified" errors. + `#4327 `_ + + + Version 2.10.1 (Oct 31, 2022) ----------------------------- @@ -95,7 +149,6 @@ Bug fixes: finalization. `#4192 `_ - Performance and style: * Reserve space in set and STL map casters if possible. This will prevent diff --git a/include/pybind11/detail/common.h b/include/pybind11/detail/common.h index 9acf10466..068ae0137 100644 --- a/include/pybind11/detail/common.h +++ b/include/pybind11/detail/common.h @@ -10,12 +10,12 @@ #pragma once #define PYBIND11_VERSION_MAJOR 2 -#define PYBIND11_VERSION_MINOR 11 -#define PYBIND11_VERSION_PATCH 0.dev1 +#define PYBIND11_VERSION_MINOR 10 +#define PYBIND11_VERSION_PATCH 2 // Similar to Python's convention: https://docs.python.org/3/c-api/apiabiversion.html // Additional convention: 0xD = dev -#define PYBIND11_VERSION_HEX 0x020B00D1 +#define PYBIND11_VERSION_HEX 0x020A0200 // Define some generic pybind11 helper macros for warning management. // diff --git a/pybind11/_version.py b/pybind11/_version.py index 1cb51fc5c..4c814edfa 100644 --- a/pybind11/_version.py +++ b/pybind11/_version.py @@ -8,5 +8,5 @@ def _to_int(s: str) -> Union[int, str]: return s -__version__ = "2.11.0.dev1" +__version__ = "2.10.2" version_info = tuple(_to_int(s) for s in __version__.split(".")) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index efdd14fc1..b6c0739aa 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -130,7 +130,6 @@ set(PYBIND11_TEST_FILES test_docstring_options test_eigen_matrix test_eigen_tensor - test_eigen_tensor_avoid_stl_array.cpp test_enum test_eval test_exceptions @@ -294,6 +293,11 @@ if(PYBIND11_TEST_FILES_EIGEN_I GREATER -1) set(EIGEN3_VERSION ${EIGEN3_VERSION_STRING}) endif() message(STATUS "Building tests with Eigen v${EIGEN3_VERSION}") + + if(NOT (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0)) + tests_extra_targets("test_eigen_tensor.py" "eigen_tensor_avoid_stl_array") + endif() + else() list(FIND PYBIND11_TEST_FILES test_eigen_matrix.cpp PYBIND11_TEST_FILES_EIGEN_I) if(PYBIND11_TEST_FILES_EIGEN_I GREATER -1) @@ -304,11 +308,6 @@ if(PYBIND11_TEST_FILES_EIGEN_I GREATER -1) if(PYBIND11_TEST_FILES_EIGEN_I GREATER -1) list(REMOVE_AT PYBIND11_TEST_FILES ${PYBIND11_TEST_FILES_EIGEN_I}) endif() - list(FIND PYBIND11_TEST_FILES test_eigen_tensor_avoid_stl_array.cpp - PYBIND11_TEST_FILES_EIGEN_I) - if(PYBIND11_TEST_FILES_EIGEN_I GREATER -1) - list(REMOVE_AT PYBIND11_TEST_FILES ${PYBIND11_TEST_FILES_EIGEN_I}) - endif() message( STATUS "Building tests WITHOUT Eigen, use -DDOWNLOAD_EIGEN=ON on CMake 3.11+ to download") endif() @@ -320,10 +319,6 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_L if(PYBIND11_TEST_FILES_EIGEN_I GREATER -1) list(REMOVE_AT PYBIND11_TEST_FILES ${PYBIND11_TEST_FILES_EIGEN_I}) endif() - list(FIND PYBIND11_TEST_FILES test_eigen_tensor_avoid_stl_array.cpp PYBIND11_TEST_FILES_EIGEN_I) - if(PYBIND11_TEST_FILES_EIGEN_I GREATER -1) - list(REMOVE_AT PYBIND11_TEST_FILES ${PYBIND11_TEST_FILES_EIGEN_I}) - endif() endif() # Optional dependency for some tests (boost::variant is only supported with version >= 1.56) diff --git a/tests/test_eigen_tensor_avoid_stl_array.cpp b/tests/eigen_tensor_avoid_stl_array.cpp similarity index 65% rename from tests/test_eigen_tensor_avoid_stl_array.cpp rename to tests/eigen_tensor_avoid_stl_array.cpp index 58bedf62d..eacc9e9bd 100644 --- a/tests/test_eigen_tensor_avoid_stl_array.cpp +++ b/tests/eigen_tensor_avoid_stl_array.cpp @@ -5,12 +5,10 @@ BSD-style license that can be found in the LICENSE file. */ -constexpr const char *test_eigen_tensor_module_name = "eigen_tensor_avoid_stl_array"; - #ifndef EIGEN_AVOID_STL_ARRAY # define EIGEN_AVOID_STL_ARRAY #endif -#define PYBIND11_TEST_EIGEN_TENSOR_NAMESPACE eigen_tensor_avoid_stl_array - #include "test_eigen_tensor.inl" + +PYBIND11_MODULE(eigen_tensor_avoid_stl_array, m) { eigen_tensor_test::test_module(m); } diff --git a/tests/test_eigen_tensor.cpp b/tests/test_eigen_tensor.cpp index 40b494005..503c69c7d 100644 --- a/tests/test_eigen_tensor.cpp +++ b/tests/test_eigen_tensor.cpp @@ -5,8 +5,6 @@ BSD-style license that can be found in the LICENSE file. */ -constexpr const char *test_eigen_tensor_module_name = "eigen_tensor"; - #define PYBIND11_TEST_EIGEN_TENSOR_NAMESPACE eigen_tensor #ifdef EIGEN_AVOID_STL_ARRAY @@ -14,3 +12,7 @@ constexpr const char *test_eigen_tensor_module_name = "eigen_tensor"; #endif #include "test_eigen_tensor.inl" + +#include "pybind11_tests.h" + +test_initializer egien_tensor("eigen_tensor", eigen_tensor_test::test_module); diff --git a/tests/test_eigen_tensor.inl b/tests/test_eigen_tensor.inl index f46eb1803..d864ce737 100644 --- a/tests/test_eigen_tensor.inl +++ b/tests/test_eigen_tensor.inl @@ -7,9 +7,9 @@ #include -#include "pybind11_tests.h" +PYBIND11_NAMESPACE_BEGIN(eigen_tensor_test) -PYBIND11_NAMESPACE_BEGIN(PYBIND11_TEST_EIGEN_TENSOR_NAMESPACE) +namespace py = pybind11; PYBIND11_WARNING_DISABLE_MSVC(4127) @@ -108,7 +108,7 @@ void init_tensor_module(pybind11::module &m) { return check_tensor(get_tensor()) && check_tensor(get_fixed_tensor()); }); - py::class_>(m, "CustomExample") + py::class_>(m, "CustomExample", py::module_local()) .def(py::init<>()) .def_readonly( "member", &CustomExample::member, py::return_value_policy::reference_internal) @@ -322,8 +322,6 @@ void init_tensor_module(pybind11::module &m) { py::return_value_policy::reference); } -void test_module(py::module_ &); -test_initializer name(test_eigen_tensor_module_name, test_module); void test_module(py::module_ &m) { auto f_style = m.def_submodule("f_style"); auto c_style = m.def_submodule("c_style"); @@ -332,4 +330,4 @@ void test_module(py::module_ &m) { init_tensor_module(c_style); } -PYBIND11_NAMESPACE_END(PYBIND11_TEST_EIGEN_TENSOR_NAMESPACE) +PYBIND11_NAMESPACE_END(eigen_tensor_test) diff --git a/tests/test_eigen_tensor.py b/tests/test_eigen_tensor.py index 653c9f288..dc8aa4643 100644 --- a/tests/test_eigen_tensor.py +++ b/tests/test_eigen_tensor.py @@ -6,17 +6,17 @@ np = pytest.importorskip("numpy") eigen_tensor = pytest.importorskip("pybind11_tests.eigen_tensor") submodules = [eigen_tensor.c_style, eigen_tensor.f_style] try: - from pybind11_tests import eigen_tensor_avoid_stl_array as avoid + import eigen_tensor_avoid_stl_array as avoid submodules += [avoid.c_style, avoid.f_style] except ImportError as e: # Ensure config, build, toolchain, etc. issues are not masked here: raise RuntimeError( - "import pybind11_tests.eigen_tensor_avoid_stl_array FAILED, while " + "import eigen_tensor_avoid_stl_array FAILED, while " "import pybind11_tests.eigen_tensor succeeded. " "Please ensure that " "test_eigen_tensor.cpp & " - "test_eigen_tensor_avoid_stl_array.cpp " + "eigen_tensor_avoid_stl_array.cpp " "are built together (or both are not built if Eigen is not available)." ) from e @@ -42,7 +42,7 @@ def cleanup(): def test_import_avoid_stl_array(): - pytest.importorskip("pybind11_tests.eigen_tensor_avoid_stl_array") + pytest.importorskip("eigen_tensor_avoid_stl_array") assert len(submodules) == 4 diff --git a/tools/FindPythonLibsNew.cmake b/tools/FindPythonLibsNew.cmake index bbbd9f9ec..ce558d4ec 100644 --- a/tools/FindPythonLibsNew.cmake +++ b/tools/FindPythonLibsNew.cmake @@ -208,7 +208,9 @@ string(REGEX REPLACE "\\\\" "/" PYTHON_PREFIX "${PYTHON_PREFIX}") string(REGEX REPLACE "\\\\" "/" PYTHON_INCLUDE_DIR "${PYTHON_INCLUDE_DIR}") string(REGEX REPLACE "\\\\" "/" PYTHON_SITE_PACKAGES "${PYTHON_SITE_PACKAGES}") -if(CMAKE_HOST_WIN32) +if(DEFINED PYTHON_LIBRARY) + # Don't write to PYTHON_LIBRARY if it's already set +elseif(CMAKE_HOST_WIN32) set(PYTHON_LIBRARY "${PYTHON_PREFIX}/libs/python${PYTHON_LIBRARY_SUFFIX}.lib") # when run in a venv, PYTHON_PREFIX points to it. But the libraries remain in the @@ -274,7 +276,7 @@ if(NOT PYTHON_DEBUG_LIBRARY) endif() set(PYTHON_DEBUG_LIBRARIES "${PYTHON_DEBUG_LIBRARY}") -find_package_message(PYTHON "Found PythonLibs: ${PYTHON_LIBRARY}" +find_package_message(PYTHON "Found PythonLibs: ${PYTHON_LIBRARIES}" "${PYTHON_EXECUTABLE}${PYTHON_VERSION_STRING}") set(PYTHONLIBS_FOUND TRUE) diff --git a/tools/pybind11Common.cmake b/tools/pybind11Common.cmake index e1fb601ac..0c985bc8e 100644 --- a/tools/pybind11Common.cmake +++ b/tools/pybind11Common.cmake @@ -311,6 +311,16 @@ function(_pybind11_generate_lto target prefer_thin_lto) HAS_FLTO "-flto${cxx_append}" "-flto${linker_append}" PYBIND11_LTO_CXX_FLAGS PYBIND11_LTO_LINKER_FLAGS) endif() + elseif(CMAKE_CXX_COMPILER_ID MATCHES "IntelLLVM") + # IntelLLVM equivalent to LTO is called IPO; also IntelLLVM is WIN32/UNIX + # WARNING/HELP WANTED: This block of code is currently not covered by pybind11 GitHub Actions! + if(WIN32) + _pybind11_return_if_cxx_and_linker_flags_work( + HAS_INTEL_IPO "-Qipo" "-Qipo" PYBIND11_LTO_CXX_FLAGS PYBIND11_LTO_LINKER_FLAGS) + else() + _pybind11_return_if_cxx_and_linker_flags_work( + HAS_INTEL_IPO "-ipo" "-ipo" PYBIND11_LTO_CXX_FLAGS PYBIND11_LTO_LINKER_FLAGS) + endif() elseif(CMAKE_CXX_COMPILER_ID MATCHES "Intel") # Intel equivalent to LTO is called IPO _pybind11_return_if_cxx_and_linker_flags_work(HAS_INTEL_IPO "-ipo" "-ipo" diff --git a/tools/pybind11NewTools.cmake b/tools/pybind11NewTools.cmake index 5a6a0cb8b..7d7424a79 100644 --- a/tools/pybind11NewTools.cmake +++ b/tools/pybind11NewTools.cmake @@ -9,7 +9,7 @@ if(CMAKE_VERSION VERSION_LESS 3.12) message(FATAL_ERROR "You cannot use the new FindPython module with CMake < 3.12") endif() -include_guard(GLOBAL) +include_guard(DIRECTORY) get_property( is_config