From ad9665560597a473774ea19dc87a40aef02090b3 Mon Sep 17 00:00:00 2001 From: Aaron Gokaslan Date: Sun, 3 Oct 2021 20:15:37 -0400 Subject: [PATCH 1/9] fix: replace free() with std::free() (#3321) * Disambiguate free() to use std::free() * Add cstdlib include --- include/pybind11/pybind11.h | 5 +++-- tests/test_embed/test_interpreter.cpp | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/include/pybind11/pybind11.h b/include/pybind11/pybind11.h index 16535f195..370e52cff 100644 --- a/include/pybind11/pybind11.h +++ b/include/pybind11/pybind11.h @@ -16,6 +16,7 @@ #include "detail/class.h" #include "detail/init.h" +#include #include #include #include @@ -1536,7 +1537,7 @@ public: char *doc_prev = rec_fget->doc; /* 'extra' field may include a property-specific documentation string */ detail::process_attributes::init(extra..., rec_fget); if (rec_fget->doc && rec_fget->doc != doc_prev) { - free(doc_prev); + std::free(doc_prev); rec_fget->doc = PYBIND11_COMPAT_STRDUP(rec_fget->doc); } } @@ -1544,7 +1545,7 @@ public: char *doc_prev = rec_fset->doc; detail::process_attributes::init(extra..., rec_fset); if (rec_fset->doc && rec_fset->doc != doc_prev) { - free(doc_prev); + std::free(doc_prev); rec_fset->doc = PYBIND11_COMPAT_STRDUP(rec_fset->doc); } if (! rec_active) rec_active = rec_fset; diff --git a/tests/test_embed/test_interpreter.cpp b/tests/test_embed/test_interpreter.cpp index fae14f751..20bcade0a 100644 --- a/tests/test_embed/test_interpreter.cpp +++ b/tests/test_embed/test_interpreter.cpp @@ -8,6 +8,7 @@ #include +#include #include #include #include @@ -315,7 +316,7 @@ TEST_CASE("sys.argv gets initialized properly") { { char *argv[] = {strdup("a.out")}; py::scoped_interpreter argv_scope(true, 1, argv); - free(argv[0]); + std::free(argv[0]); auto module = py::module::import("test_interpreter"); auto py_widget = module.attr("DerivedWidget")("The question"); const auto &cpp_widget = py_widget.cast(); From d7a7edc12bc4c7aec4afd16aee1ed032bb974164 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Mon, 4 Oct 2021 12:31:53 -0400 Subject: [PATCH 2/9] tests: support Eigen configuration --- tests/CMakeLists.txt | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 70303879f..6ebcba9b6 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -171,6 +171,14 @@ set(PYBIND11_CROSS_MODULE_TESTS test_exceptions.py test_local_bindings.py test_s set(PYBIND11_CROSS_MODULE_GIL_TESTS test_gil_scoped.py) +set(PYBIND11_EIGEN_REPO + "https://gitlab.com/libeigen/eigen.git" + CACHE STRING "Eigen repository to use for tests") +# This hash is for 3.3.8, using a hash for security reasons +set(PYBIND11_EIGEN_VERSION + "dc252fbf00079ccab57948a164b1421703fe4361" + CACHE STRING "Eigen version to use for tests") + # Check if Eigen is available; if not, remove from PYBIND11_TEST_FILES (but # keep it in PYBIND11_PYTEST_FILES, so that we get the "eigen is not installed" # skip message). @@ -184,13 +192,11 @@ if(PYBIND11_TEST_FILES_EIGEN_I GREATER -1) message(FATAL_ERROR "CMake 3.11+ required when using DOWNLOAD_EIGEN") endif() - set(EIGEN3_VERSION_STRING "3.3.8") - include(FetchContent) FetchContent_Declare( eigen - GIT_REPOSITORY https://gitlab.com/libeigen/eigen.git - GIT_TAG ${EIGEN3_VERSION_STRING}) + GIT_REPOSITORY "${PYBIND11_EIGEN_REPO}" + GIT_TAG "${PYBIND11_EIGEN_VERSION}") FetchContent_GetProperties(eigen) if(NOT eigen_POPULATED) From 9f146a56227eab9b3bf5e847fc5610853372f587 Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Sun, 3 Oct 2021 14:57:41 -0700 Subject: [PATCH 3/9] All `-DDOWNLOAD_EIGEN=OFF` (to work around gitlab eigen outage). --- .github/workflows/ci.yml | 8 ++++++++ .github/workflows/format.yml | 1 + 2 files changed, 9 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0b4968cc8..279a1e7a0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -102,6 +102,7 @@ jobs: -DPYBIND11_WERROR=ON -DDOWNLOAD_CATCH=ON -DDOWNLOAD_EIGEN=ON + -DPYBIND11_EIGEN_REPO=https://gitlab.com/libeigen/eigen-backup -DCMAKE_CXX_STANDARD=11 ${{ matrix.args }} @@ -129,6 +130,7 @@ jobs: -DPYBIND11_WERROR=ON -DDOWNLOAD_CATCH=ON -DDOWNLOAD_EIGEN=ON + -DPYBIND11_EIGEN_REPO=https://gitlab.com/libeigen/eigen-backup -DCMAKE_CXX_STANDARD=17 ${{ matrix.args }} ${{ matrix.args2 }} @@ -151,6 +153,7 @@ jobs: -DPYBIND11_WERROR=ON -DDOWNLOAD_CATCH=ON -DDOWNLOAD_EIGEN=ON + -DPYBIND11_EIGEN_REPO=https://gitlab.com/libeigen/eigen-backup -DCMAKE_CXX_STANDARD=17 -DPYBIND11_INTERNALS_VERSION=10000000 "-DPYBIND11_TEST_OVERRIDE=test_call_policies.cpp;test_gil_scoped.cpp;test_thread.cpp" @@ -249,6 +252,7 @@ jobs: -DPYBIND11_WERROR=ON -DDOWNLOAD_CATCH=ON -DDOWNLOAD_EIGEN=ON + -DPYBIND11_EIGEN_REPO=https://gitlab.com/libeigen/eigen-backup -DCMAKE_CXX_STANDARD=17 - name: Build @@ -628,6 +632,7 @@ jobs: -DPYBIND11_WERROR=ON -DDOWNLOAD_CATCH=ON -DDOWNLOAD_EIGEN=ON + -DPYBIND11_EIGEN_REPO=https://gitlab.com/libeigen/eigen-backup -DCMAKE_CXX_STANDARD=11 -DPYTHON_EXECUTABLE=$(python3 -c "import sys; print(sys.executable)") @@ -774,6 +779,7 @@ jobs: -DPYBIND11_WERROR=ON -DDOWNLOAD_CATCH=ON -DDOWNLOAD_EIGEN=ON + -DPYBIND11_EIGEN_REPO=https://gitlab.com/libeigen/eigen-backup ${{ matrix.args }} - name: Build C++11 run: cmake --build build -j 2 @@ -820,6 +826,7 @@ jobs: -DPYBIND11_WERROR=ON -DDOWNLOAD_CATCH=ON -DDOWNLOAD_EIGEN=ON + -DPYBIND11_EIGEN_REPO=https://gitlab.com/libeigen/eigen-backup - name: Build C++14 run: cmake --build build -j 2 @@ -869,6 +876,7 @@ jobs: -DPYBIND11_WERROR=ON -DDOWNLOAD_CATCH=ON -DDOWNLOAD_EIGEN=ON + -DPYBIND11_EIGEN_REPO=https://gitlab.com/libeigen/eigen-backup -DCMAKE_CXX_STANDARD=${{ matrix.std }} ${{ matrix.args }} diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index ab7b40503..7869912bf 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -41,6 +41,7 @@ jobs: cmake -S . -B build -DCMAKE_CXX_CLANG_TIDY="$(which clang-tidy)" -DDOWNLOAD_EIGEN=ON + -DPYBIND11_EIGEN_REPO=https://gitlab.com/libeigen/eigen-backup -DDOWNLOAD_CATCH=ON -DCMAKE_CXX_STANDARD=17 From 591db0b930f6739fe276bce9a7d5b6647bd00851 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Fri, 1 Oct 2021 09:30:55 -0400 Subject: [PATCH 4/9] docs: update CHANGELOG for 2.8 --- docs/changelog.rst | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 04e2714fc..4a58f2d51 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -6,8 +6,8 @@ Changelog Starting with version 1.8.0, pybind11 releases use a `semantic versioning `_ policy. -v2.8.0 (WIP) ------------- +v2.8.0 (Oct 4, 2021) +-------------------- New features: @@ -46,13 +46,17 @@ New features: references instead of copies. `#3293 `_ +* Improve the classes generated by ``bind_map``: `#3310 `_ + * Change ``.items`` from an iterator to a dictionary view. + * Add ``.keys`` and ``.values`` (both dictionary views). + * Allow ``__contains__`` to take any object. + * ``pybind11::custom_type_setup`` was added, for customizing the ``PyHeapTypeObject`` corresponding to a class, which may be useful for enabling garbage collection support, among other things. `#3287 `_ - Changes: * Set ``__file__`` constant when running ``eval_file`` in an embedded interpreter. @@ -106,6 +110,9 @@ Build system improvements: * Fix a harmless warning from CMake 3.21 with the classic Python discovery. `#3220 `_ +* Eigen repo and version can now be specified as cmake options. + `#3324 `_ + Backend and tidying up: From 20aae3e61a91dbae5d71c3b11677369d94a82884 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Mon, 4 Oct 2021 14:47:45 -0400 Subject: [PATCH 5/9] ci: disable Eigen due to Cert issue on CentOS --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 279a1e7a0..416d2a4ec 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -624,6 +624,7 @@ jobs: if: matrix.centos == 8 run: echo Release > VAR_BUILD_TYPE + # Temporally disabling EIGEN due to SSL issue in CentOS 7 - name: Configure shell: bash run: > @@ -631,8 +632,7 @@ jobs: -DCMAKE_BUILD_TYPE=$(cat VAR_BUILD_TYPE) -DPYBIND11_WERROR=ON -DDOWNLOAD_CATCH=ON - -DDOWNLOAD_EIGEN=ON - -DPYBIND11_EIGEN_REPO=https://gitlab.com/libeigen/eigen-backup + -DDOWNLOAD_EIGEN=OFF -DCMAKE_CXX_STANDARD=11 -DPYTHON_EXECUTABLE=$(python3 -c "import sys; print(sys.executable)") From c9a319c607a5fcddf14417483a451bd85083da72 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Mon, 4 Oct 2021 15:33:58 -0400 Subject: [PATCH 6/9] chore: version 2.8.0 final --- include/pybind11/detail/common.h | 4 ++-- pybind11/_version.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/pybind11/detail/common.h b/include/pybind11/detail/common.h index 3bd84da57..31716e5bf 100644 --- a/include/pybind11/detail/common.h +++ b/include/pybind11/detail/common.h @@ -11,11 +11,11 @@ #define PYBIND11_VERSION_MAJOR 2 #define PYBIND11_VERSION_MINOR 8 -#define PYBIND11_VERSION_PATCH 0.dev2 +#define PYBIND11_VERSION_PATCH 0 // Similar to Python's convention: https://docs.python.org/3/c-api/apiabiversion.html // Additional convention: 0xD = dev -#define PYBIND11_VERSION_HEX 0x020800D2 +#define PYBIND11_VERSION_HEX 0x02080000 #define PYBIND11_NAMESPACE_BEGIN(name) namespace name { #define PYBIND11_NAMESPACE_END(name) } diff --git a/pybind11/_version.py b/pybind11/_version.py index d212f1dfb..704191b98 100644 --- a/pybind11/_version.py +++ b/pybind11/_version.py @@ -8,5 +8,5 @@ def _to_int(s): return s -__version__ = "2.8.0.dev2" +__version__ = "2.8.0" version_info = tuple(_to_int(s) for s in __version__.split(".")) From 3747dc2c4f807fba952380f7bd9f367ab9c53a0a Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Mon, 4 Oct 2021 16:38:15 -0400 Subject: [PATCH 7/9] Revert "All `-DDOWNLOAD_EIGEN=OFF` (to work around gitlab eigen outage)." (#3326) This reverts commit 9f146a56227eab9b3bf5e847fc5610853372f587. --- .github/workflows/ci.yml | 9 +-------- .github/workflows/format.yml | 1 - 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 416d2a4ec..6843a9243 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -102,7 +102,6 @@ jobs: -DPYBIND11_WERROR=ON -DDOWNLOAD_CATCH=ON -DDOWNLOAD_EIGEN=ON - -DPYBIND11_EIGEN_REPO=https://gitlab.com/libeigen/eigen-backup -DCMAKE_CXX_STANDARD=11 ${{ matrix.args }} @@ -130,7 +129,6 @@ jobs: -DPYBIND11_WERROR=ON -DDOWNLOAD_CATCH=ON -DDOWNLOAD_EIGEN=ON - -DPYBIND11_EIGEN_REPO=https://gitlab.com/libeigen/eigen-backup -DCMAKE_CXX_STANDARD=17 ${{ matrix.args }} ${{ matrix.args2 }} @@ -153,7 +151,6 @@ jobs: -DPYBIND11_WERROR=ON -DDOWNLOAD_CATCH=ON -DDOWNLOAD_EIGEN=ON - -DPYBIND11_EIGEN_REPO=https://gitlab.com/libeigen/eigen-backup -DCMAKE_CXX_STANDARD=17 -DPYBIND11_INTERNALS_VERSION=10000000 "-DPYBIND11_TEST_OVERRIDE=test_call_policies.cpp;test_gil_scoped.cpp;test_thread.cpp" @@ -252,7 +249,6 @@ jobs: -DPYBIND11_WERROR=ON -DDOWNLOAD_CATCH=ON -DDOWNLOAD_EIGEN=ON - -DPYBIND11_EIGEN_REPO=https://gitlab.com/libeigen/eigen-backup -DCMAKE_CXX_STANDARD=17 - name: Build @@ -632,7 +628,7 @@ jobs: -DCMAKE_BUILD_TYPE=$(cat VAR_BUILD_TYPE) -DPYBIND11_WERROR=ON -DDOWNLOAD_CATCH=ON - -DDOWNLOAD_EIGEN=OFF + -DDOWNLOAD_EIGEN=ON -DCMAKE_CXX_STANDARD=11 -DPYTHON_EXECUTABLE=$(python3 -c "import sys; print(sys.executable)") @@ -779,7 +775,6 @@ jobs: -DPYBIND11_WERROR=ON -DDOWNLOAD_CATCH=ON -DDOWNLOAD_EIGEN=ON - -DPYBIND11_EIGEN_REPO=https://gitlab.com/libeigen/eigen-backup ${{ matrix.args }} - name: Build C++11 run: cmake --build build -j 2 @@ -826,7 +821,6 @@ jobs: -DPYBIND11_WERROR=ON -DDOWNLOAD_CATCH=ON -DDOWNLOAD_EIGEN=ON - -DPYBIND11_EIGEN_REPO=https://gitlab.com/libeigen/eigen-backup - name: Build C++14 run: cmake --build build -j 2 @@ -876,7 +870,6 @@ jobs: -DPYBIND11_WERROR=ON -DDOWNLOAD_CATCH=ON -DDOWNLOAD_EIGEN=ON - -DPYBIND11_EIGEN_REPO=https://gitlab.com/libeigen/eigen-backup -DCMAKE_CXX_STANDARD=${{ matrix.std }} ${{ matrix.args }} diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index 7869912bf..ab7b40503 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -41,7 +41,6 @@ jobs: cmake -S . -B build -DCMAKE_CXX_CLANG_TIDY="$(which clang-tidy)" -DDOWNLOAD_EIGEN=ON - -DPYBIND11_EIGEN_REPO=https://gitlab.com/libeigen/eigen-backup -DDOWNLOAD_CATCH=ON -DCMAKE_CXX_STANDARD=17 From 97976c16fb7652f7faf02d76756666ef87adbe7d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 4 Oct 2021 16:38:31 -0400 Subject: [PATCH 8/9] [pre-commit.ci] pre-commit autoupdate (#3325) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/asottile/pyupgrade: v2.28.0 → v2.29.0](https://github.com/asottile/pyupgrade/compare/v2.28.0...v2.29.0) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 05bfce851..2df314606 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -33,7 +33,7 @@ repos: exclude: ^noxfile.py$ - repo: https://github.com/asottile/pyupgrade - rev: v2.28.0 + rev: v2.29.0 hooks: - id: pyupgrade From ba9f919b857f12efd18d3fc43fc62e7ad724c6d9 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Mon, 4 Oct 2021 17:37:27 -0400 Subject: [PATCH 9/9] chore: get back to work after 2.8.0 --- docs/changelog.rst | 6 ++++++ docs/release.rst | 2 ++ include/pybind11/detail/common.h | 6 +++--- pybind11/_version.py | 2 +- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 4a58f2d51..1dab8765f 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -6,6 +6,12 @@ Changelog Starting with version 1.8.0, pybind11 releases use a `semantic versioning `_ policy. + +IN DEVELOPMENT +-------------- + + + v2.8.0 (Oct 4, 2021) -------------------- diff --git a/docs/release.rst b/docs/release.rst index e4f3d1902..7fa254eaf 100644 --- a/docs/release.rst +++ b/docs/release.rst @@ -27,6 +27,7 @@ To release a new version of pybind11: ``include/pybind11/detail/common.h``. PATCH should be a simple integer. - Update the version HEX just below, as well. - Update ``pybind11/_version.py`` (match above) + - Run ``nox -s tests_packaging``` to ensure this was done correctly. - Ensure that all the information in ``setup.cfg`` is up-to-date, like supported Python versions. - Add release date in ``docs/changelog.rst``. @@ -64,6 +65,7 @@ To release a new version of pybind11: - Update version macros in ``include/pybind11/detail/common.h`` (set PATCH to ``0.dev1`` and increment MINOR). - Update ``_version.py`` to match + - Run ``nox -s tests_packaging``` to ensure this was done correctly. - Add a spot for in-development updates in ``docs/changelog.rst``. - ``git add``, ``git commit``, ``git push`` diff --git a/include/pybind11/detail/common.h b/include/pybind11/detail/common.h index 31716e5bf..9ad305a4e 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 8 -#define PYBIND11_VERSION_PATCH 0 +#define PYBIND11_VERSION_MINOR 9 +#define PYBIND11_VERSION_PATCH 0.dev1 // Similar to Python's convention: https://docs.python.org/3/c-api/apiabiversion.html // Additional convention: 0xD = dev -#define PYBIND11_VERSION_HEX 0x02080000 +#define PYBIND11_VERSION_HEX 0x020900D1 #define PYBIND11_NAMESPACE_BEGIN(name) namespace name { #define PYBIND11_NAMESPACE_END(name) } diff --git a/pybind11/_version.py b/pybind11/_version.py index 704191b98..ce894a774 100644 --- a/pybind11/_version.py +++ b/pybind11/_version.py @@ -8,5 +8,5 @@ def _to_int(s): return s -__version__ = "2.8.0" +__version__ = "2.9.0.dev1" version_info = tuple(_to_int(s) for s in __version__.split("."))