From 9ec64e37c3972e86a17ef3fefdc30cfbd8f094dd Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Tue, 25 Jun 2024 16:24:54 -0400 Subject: [PATCH 1/8] docs: prepare for 2.13.0 (#5187) * docs: prepare for 2.13.0 Signed-off-by: Henry Schreiner * docs: reword cross-compiling entry Signed-off-by: Henry Schreiner * Update changelog.rst --------- Signed-off-by: Henry Schreiner --- docs/changelog.rst | 94 +++++++++++++++++++++++++++++++++++++++++ setup.cfg | 1 + tools/make_changelog.py | 2 + 3 files changed, 97 insertions(+) diff --git a/docs/changelog.rst b/docs/changelog.rst index e1b7667fae..0a556973ed 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -15,6 +15,100 @@ IN DEVELOPMENT Changes will be summarized here periodically. +Version 2.13.0 (June 25, 2024) +------------------------------ + +New Features: + +* Support free-threaded CPython (3.13t). Add ``py::mod_gil_not_used()`` tag to + indicate if a module supports running with the GIL disabled. + `#5148 `_ + +* Support for Python 3.6 was removed. (Official end-of-life: 2021-12-23). + `#5177 `_ + +* ``py::list`` gained a ``.clear()`` method. + `#5153 `_ + + +.. feat(types) + +* Support for ``type[T]`` was added to pybind11/typing.h. + `#5166 `_ + +* ``Union`` and ``Optional`` were added to ``pybind11/typing.h``. + `#5165 `_ + +.. feat(cmake) + +* In CMake, if ``PYBIND11_USE_CROSSCOMPILING`` is enabled, then + ``CMAKE_CROSSCOMPILING`` will be respected and will keep pybind11 from + accessing the interpreter during configuration. Several CMake variables will + be required in this case, but can be deduced from the environment variable + ``SETUPTOOLS_EXT_SUFFIX``. The default (currently ``OFF``) may be changed in + the future. + `#5083 `_ + + +Bug fixes: + +* A refcount bug (leading to heap-use-after-free) involving trampoline + functions with ``PyObject *`` return type was fixed. + `#5156 `_ + +* Return ``py::ssize_t`` from ``.ref_count()`` instead of ``int``. + `#5139 `_ + +* A subtle bug involving C++ types with unusual ``operator&`` overrides + was fixed. + `#5189 `_ + +* Support Python 3.13 with minor fix, add to CI. + `#5127 `_ + + +.. fix(cmake) + +* Fix mistake affecting old cmake and old boost. + `#5149 `_ + + +Documentation: + +* Build docs updated to feature scikit-build-core and meson-python, and updated + setuptools instructions. + `#5168 `_ + + +Tests: + +* Avoid immortal objects in tests. + `#5150 `_ + + +CI: + +* Compile against Python 3.13t in CI. + +* Use ``macos-13`` (Intel) for CI jobs for now (will drop Python 3.7 soon). + `#5109 `_ + + +Other: + +* Some cleanup in preparation for 3.13 support. + `#5137 `_ + +* Avoid a warning by ensuring an iterator end check is included in release mode. + `#5129 `_ + +* Bump max cmake to 3.29. + `#5075 `_ + +* Update docs and noxfile. + `#5071 `_ + + Version 2.12.0 (March 27, 2024) ------------------------------- diff --git a/setup.cfg b/setup.cfg index 79d75d0cdb..2beca780f9 100644 --- a/setup.cfg +++ b/setup.cfg @@ -20,6 +20,7 @@ classifiers = Programming Language :: Python :: 3.10 Programming Language :: Python :: 3.11 Programming Language :: Python :: 3.12 + Programming Language :: Python :: 3.13 License :: OSI Approved :: BSD License Programming Language :: Python :: Implementation :: PyPy Programming Language :: Python :: Implementation :: CPython diff --git a/tools/make_changelog.py b/tools/make_changelog.py index 89cf664835..daa966f204 100755 --- a/tools/make_changelog.py +++ b/tools/make_changelog.py @@ -32,6 +32,8 @@ missing = [] cats_descr = { "feat": "New Features", + "feat(types)": "", + "feat(cmake)": "", "fix": "Bug fixes", "fix(types)": "", "fix(cmake)": "", From aebcd704d2134dd34710d504b79be8b673a4643b Mon Sep 17 00:00:00 2001 From: Michael Carlstrom Date: Tue, 25 Jun 2024 16:25:40 -0400 Subject: [PATCH 2/8] Add TypeVars / method generics typing (#5167) * typevar prototype * style: pre-commit fixes * change to NameT * style: pre-commit fixes * make string const * add missing closing bracket * style: pre-commit fixes * clean up handle_type_name * style: pre-commit fixes * add back missing < * style: pre-commit fixes * add back NameT * try fixed_string * style: pre-commit fixes * std::basic_fixed_string * test c++20 * style: pre-commit fixes * cleanup * fix object to typevar conversion * style: pre-commit fixes * And CPP20 checks * style: pre-commit fixes * add missing cpp20++ check * style: pre-commit fixes * Add C++20 check to python * Fix python if { * style: pre-commit fixes * update test name * style: pre-commit fixes * remove call on cpp_std * make field const * test nontype_template * update feature check * update name of guard * fix try except in test * fix pre commit * remove extra semi colon * except AttributeError * fix try except in test * remove const * Clean up tests * style: pre-commit fixes * use contextlib.suppres * request changes * lint * Add comments * style: pre-commit fixes * Add support for unions and optionals to be compatible with object * lint * remove comment --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- include/pybind11/typing.h | 25 +++++++++++++++++++++++++ tests/test_pytypes.cpp | 28 +++++++++++++++++++++++++++- tests/test_pytypes.py | 31 ++++++++++++++++++++++++++++++- 3 files changed, 82 insertions(+), 2 deletions(-) diff --git a/include/pybind11/typing.h b/include/pybind11/typing.h index e0d0e45c45..8d91c51d90 100644 --- a/include/pybind11/typing.h +++ b/include/pybind11/typing.h @@ -70,14 +70,32 @@ class Type : public type { template class Union : public object { + PYBIND11_OBJECT_DEFAULT(Union, object, PyObject_Type) using object::object; }; template class Optional : public object { + PYBIND11_OBJECT_DEFAULT(Optional, object, PyObject_Type) using object::object; }; +#if defined(__cpp_nontype_template_parameter_class) +template +struct StringLiteral { + constexpr StringLiteral(const char (&str)[N]) { std::copy_n(str, N, value); } + char value[N]; +}; + +// Example syntax for creating a TypeVar. +// typedef typing::TypeVar<"T"> TypeVarT; +template +class TypeVar : public object { + PYBIND11_OBJECT_DEFAULT(TypeVar, object, PyObject_Type) + using object::object; +}; +#endif + PYBIND11_NAMESPACE_END(typing) PYBIND11_NAMESPACE_BEGIN(detail) @@ -153,5 +171,12 @@ struct handle_type_name> { static constexpr auto name = const_name("Optional[") + make_caster::name + const_name("]"); }; +#if defined(__cpp_nontype_template_parameter_class) +template +struct handle_type_name> { + static constexpr auto name = const_name(StrLit.value); +}; +#endif + PYBIND11_NAMESPACE_END(detail) PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE) diff --git a/tests/test_pytypes.cpp b/tests/test_pytypes.cpp index e5a318ad84..ce003e0926 100644 --- a/tests/test_pytypes.cpp +++ b/tests/test_pytypes.cpp @@ -109,6 +109,13 @@ void m_defs(py::module_ &m) { } // namespace handle_from_move_only_type_with_operator_PyObject +#if defined(__cpp_nontype_template_parameter_class) +namespace typevar { +typedef py::typing::TypeVar<"T"> TypeVarT; +typedef py::typing::TypeVar<"V"> TypeVarV; +} // namespace typevar +#endif + TEST_SUBMODULE(pytypes, m) { m.def("obj_class_name", [](py::handle obj) { return py::detail::obj_class_name(obj.ptr()); }); @@ -844,7 +851,7 @@ TEST_SUBMODULE(pytypes, m) { m.def("annotate_iterator_int", [](const py::typing::Iterator &) {}); m.def("annotate_fn", [](const py::typing::Callable, py::str)> &) {}); - m.def("annotate_type", [](const py::typing::Type &) {}); + m.def("annotate_type", [](const py::typing::Type &t) -> py::type { return t; }); m.def("annotate_union", [](py::typing::List> l, @@ -861,10 +868,29 @@ TEST_SUBMODULE(pytypes, m) { [](py::typing::List> &l) -> py::typing::List> { return l; }); + m.def("annotate_union_to_object", + [](py::typing::Union &o) -> py::object { return o; }); + m.def("annotate_optional", [](py::list &list) -> py::typing::List> { list.append(py::str("hi")); list.append(py::none()); return list; }); + m.def("annotate_optional_to_object", + [](py::typing::Optional &o) -> py::object { return o; }); + +#if defined(__cpp_nontype_template_parameter_class) + m.def("annotate_generic_containers", + [](const py::typing::List &l) -> py::typing::List { + return l; + }); + + m.def("annotate_listT_to_T", + [](const py::typing::List &l) -> typevar::TypeVarT { return l[0]; }); + m.def("annotate_object_to_T", [](const py::object &o) -> typevar::TypeVarT { return o; }); + m.attr("if_defined__cpp_nontype_template_parameter_class") = true; +#else + m.attr("if_defined__cpp_nontype_template_parameter_class") = false; +#endif } diff --git a/tests/test_pytypes.py b/tests/test_pytypes.py index 8e35c70733..19e002de91 100644 --- a/tests/test_pytypes.py +++ b/tests/test_pytypes.py @@ -960,7 +960,7 @@ def test_fn_annotations(doc): def test_type_annotation(doc): - assert doc(m.annotate_type) == "annotate_type(arg0: type[int]) -> None" + assert doc(m.annotate_type) == "annotate_type(arg0: type[int]) -> type" def test_union_annotations(doc): @@ -977,8 +977,37 @@ def test_union_typing_only(doc): ) +def test_union_object_annotations(doc): + assert ( + doc(m.annotate_union_to_object) + == "annotate_union_to_object(arg0: Union[int, str]) -> object" + ) + + def test_optional_annotations(doc): assert ( doc(m.annotate_optional) == "annotate_optional(arg0: list) -> list[Optional[str]]" ) + + +def test_optional_object_annotations(doc): + assert ( + doc(m.annotate_optional_to_object) + == "annotate_optional_to_object(arg0: Optional[int]) -> object" + ) + + +@pytest.mark.skipif( + not m.if_defined__cpp_nontype_template_parameter_class, + reason="C++20 feature not available.", +) +def test_typevar(doc): + assert ( + doc(m.annotate_generic_containers) + == "annotate_generic_containers(arg0: list[T]) -> list[V]" + ) + + assert doc(m.annotate_listT_to_T) == "annotate_listT_to_T(arg0: list[T]) -> T" + + assert doc(m.annotate_object_to_T) == "annotate_object_to_T(arg0: object) -> T" From 183059f9a46b17bb8bd3a7fb4b804b6255c0d2b4 Mon Sep 17 00:00:00 2001 From: Michael Carlstrom Date: Tue, 25 Jun 2024 17:57:34 -0400 Subject: [PATCH 3/8] feat(types): add support for typing.Literal type (#5192) * typevar prototype * style: pre-commit fixes * change to NameT * style: pre-commit fixes * make string const * add missing closing bracket * style: pre-commit fixes * clean up handle_type_name * style: pre-commit fixes * add back missing < * style: pre-commit fixes * add back NameT * try fixed_string * style: pre-commit fixes * std::basic_fixed_string * test c++20 * style: pre-commit fixes * cleanup * fix object to typevar conversion * style: pre-commit fixes * And CPP20 checks * style: pre-commit fixes * add missing cpp20++ check * style: pre-commit fixes * Add C++20 check to python * Fix python if { * style: pre-commit fixes * update test name * style: pre-commit fixes * remove call on cpp_std * make field const * test nontype_template * update feature check * update name of guard * fix try except in test * fix pre commit * remove extra semi colon * except AttributeError * fix try except in test * remove const * Clean up tests * style: pre-commit fixes * start string literal * start int literal * func declare * commit clean * use contextlib.suppres * resolve stash * more literal type * fix annotation name * stash * request changes * lint * Add comments * style: pre-commit fixes * Add support for unions and optionals to be compatible with object * lint * remove comment * Create Literal Type implementation * clean up * Update comment * remove incorrect comment * rerun CI * rerun CI * fix extra line * lint * move if defined block * style: pre-commit fixes --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- include/pybind11/typing.h | 17 ++++++++++++++--- tests/test_pytypes.cpp | 19 +++++++++++++++++++ tests/test_pytypes.py | 11 +++++++++++ 3 files changed, 44 insertions(+), 3 deletions(-) diff --git a/include/pybind11/typing.h b/include/pybind11/typing.h index 8d91c51d90..fb37f0021c 100644 --- a/include/pybind11/typing.h +++ b/include/pybind11/typing.h @@ -83,8 +83,13 @@ class Optional : public object { #if defined(__cpp_nontype_template_parameter_class) template struct StringLiteral { - constexpr StringLiteral(const char (&str)[N]) { std::copy_n(str, N, value); } - char value[N]; + constexpr StringLiteral(const char (&str)[N]) { std::copy_n(str, N, name); } + char name[N]; +}; + +template +class Literal : public object { + PYBIND11_OBJECT_DEFAULT(Literal, object, PyObject_Type) }; // Example syntax for creating a TypeVar. @@ -172,9 +177,15 @@ struct handle_type_name> { }; #if defined(__cpp_nontype_template_parameter_class) +template +struct handle_type_name> { + static constexpr auto name = const_name("Literal[") + + pybind11::detail::concat(const_name(Literals.name)...) + + const_name("]"); +}; template struct handle_type_name> { - static constexpr auto name = const_name(StrLit.value); + static constexpr auto name = const_name(StrLit.name); }; #endif diff --git a/tests/test_pytypes.cpp b/tests/test_pytypes.cpp index ce003e0926..952b5af6eb 100644 --- a/tests/test_pytypes.cpp +++ b/tests/test_pytypes.cpp @@ -110,6 +110,19 @@ void m_defs(py::module_ &m) { } // namespace handle_from_move_only_type_with_operator_PyObject #if defined(__cpp_nontype_template_parameter_class) +namespace literals { +enum Color { RED = 0, BLUE = 1 }; + +typedef py::typing::Literal<"26", + "0x1A", + "\"hello world\"", + "b\"hello world\"", + "u\"hello world\"", + "True", + "Color.RED", + "None"> + LiteralFoo; +} // namespace literals namespace typevar { typedef py::typing::TypeVar<"T"> TypeVarT; typedef py::typing::TypeVar<"V"> TypeVarV; @@ -851,6 +864,7 @@ TEST_SUBMODULE(pytypes, m) { m.def("annotate_iterator_int", [](const py::typing::Iterator &) {}); m.def("annotate_fn", [](const py::typing::Callable, py::str)> &) {}); + m.def("annotate_type", [](const py::typing::Type &t) -> py::type { return t; }); m.def("annotate_union", @@ -881,6 +895,11 @@ TEST_SUBMODULE(pytypes, m) { [](py::typing::Optional &o) -> py::object { return o; }); #if defined(__cpp_nontype_template_parameter_class) + py::enum_(m, "Color") + .value("RED", literals::Color::RED) + .value("BLUE", literals::Color::BLUE); + + m.def("annotate_literal", [](literals::LiteralFoo &o) -> py::object { return o; }); m.def("annotate_generic_containers", [](const py::typing::List &l) -> py::typing::List { return l; diff --git a/tests/test_pytypes.py b/tests/test_pytypes.py index 19e002de91..b265512c8e 100644 --- a/tests/test_pytypes.py +++ b/tests/test_pytypes.py @@ -998,6 +998,17 @@ def test_optional_object_annotations(doc): ) +@pytest.mark.skipif( + not m.if_defined__cpp_nontype_template_parameter_class, + reason="C++20 feature not available.", +) +def test_literal(doc): + assert ( + doc(m.annotate_literal) + == 'annotate_literal(arg0: Literal[26, 0x1A, "hello world", b"hello world", u"hello world", True, Color.RED, None]) -> object' + ) + + @pytest.mark.skipif( not m.if_defined__cpp_nontype_template_parameter_class, reason="C++20 feature not available.", From 26281c79861ddc96ad8dbdda8fec53cc6252e1a5 Mon Sep 17 00:00:00 2001 From: Michael Carlstrom Date: Tue, 25 Jun 2024 21:10:25 -0400 Subject: [PATCH 4/8] feat(types): adds support for Never and NoReturn from python Typing (#5193) * Adds support for Never and NoReturn * lint --- include/pybind11/typing.h | 16 ++++++++++++++++ tests/test_pytypes.cpp | 3 +++ tests/test_pytypes.py | 8 ++++++++ 3 files changed, 27 insertions(+) diff --git a/include/pybind11/typing.h b/include/pybind11/typing.h index fb37f0021c..55f1f949da 100644 --- a/include/pybind11/typing.h +++ b/include/pybind11/typing.h @@ -80,6 +80,13 @@ class Optional : public object { using object::object; }; +class NoReturn : public none { + using none::none; +}; + +class Never : public none { + using none::none; +}; #if defined(__cpp_nontype_template_parameter_class) template struct StringLiteral { @@ -176,6 +183,15 @@ struct handle_type_name> { static constexpr auto name = const_name("Optional[") + make_caster::name + const_name("]"); }; +template <> +struct handle_type_name { + static constexpr auto name = const_name("NoReturn"); +}; + +template <> +struct handle_type_name { + static constexpr auto name = const_name("Never"); +}; #if defined(__cpp_nontype_template_parameter_class) template struct handle_type_name> { diff --git a/tests/test_pytypes.cpp b/tests/test_pytypes.cpp index 952b5af6eb..ce6b93326f 100644 --- a/tests/test_pytypes.cpp +++ b/tests/test_pytypes.cpp @@ -891,6 +891,9 @@ TEST_SUBMODULE(pytypes, m) { list.append(py::none()); return list; }); + + m.def("annotate_no_return", []() -> py::typing::NoReturn { throw 0; }); + m.def("annotate_never", []() -> py::typing::Never { throw 0; }); m.def("annotate_optional_to_object", [](py::typing::Optional &o) -> py::object { return o; }); diff --git a/tests/test_pytypes.py b/tests/test_pytypes.py index b265512c8e..923cebaf5a 100644 --- a/tests/test_pytypes.py +++ b/tests/test_pytypes.py @@ -991,6 +991,14 @@ def test_optional_annotations(doc): ) +def test_no_return_annotation(doc): + assert doc(m.annotate_no_return) == "annotate_no_return() -> NoReturn" + + +def test_never_annotation(doc): + assert doc(m.annotate_never) == "annotate_never() -> Never" + + def test_optional_object_annotations(doc): assert ( doc(m.annotate_optional_to_object) From b5ec7c7174342fcf78830f007ef2c1f28cbc70af Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Tue, 25 Jun 2024 21:12:58 -0400 Subject: [PATCH 5/8] ci: release with trusted publisher and attestations (#5196) * ci: release with trusted publisher and attestations Signed-off-by: Henry Schreiner * Update pip.yml --------- Signed-off-by: Henry Schreiner --- .github/workflows/pip.yml | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/.github/workflows/pip.yml b/.github/workflows/pip.yml index 9aad8df886..6d453eabe1 100644 --- a/.github/workflows/pip.yml +++ b/.github/workflows/pip.yml @@ -58,7 +58,7 @@ jobs: - name: Prepare env run: | - python -m pip install -r tests/requirements.txt build twine + python -m pip install -r tests/requirements.txt build twine!=5.1.0 - name: Python Packaging tests run: pytest tests/extra_python_package/ @@ -91,23 +91,27 @@ jobs: runs-on: ubuntu-latest if: github.event_name == 'release' && github.event.action == 'published' needs: [packaging] + environment: pypi + permissions: + id-token: write + attestations: write + contents: read steps: - - uses: actions/setup-python@v5 - with: - python-version: "3.x" - # Downloads all to directories matching the artifact names - uses: actions/download-artifact@v4 + - name: Generate artifact attestation for sdist and wheel + uses: actions/attest-build-provenance@173725a1209d09b31f9d30a3890cf2757ebbff0d # v1.1.2 + with: + subject-path: "*/pybind11*" + - name: Publish standard package uses: pypa/gh-action-pypi-publish@release/v1 with: - password: ${{ secrets.pypi_password }} packages-dir: standard/ - name: Publish global package uses: pypa/gh-action-pypi-publish@release/v1 with: - password: ${{ secrets.pypi_password_global }} packages-dir: global/ From 2be85c604167e4097edab9cd7b4215e85f1ae8d1 Mon Sep 17 00:00:00 2001 From: Michael Carlstrom Date: Tue, 25 Jun 2024 22:53:15 -0400 Subject: [PATCH 6/8] feat(types): adds support for TypeGuard and TypeIs (#5194) * Adds support for TypeGuard and TypeIs * style: pre-commit fixes --------- Co-authored-by: Henry Schreiner Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- include/pybind11/typing.h | 22 ++++++++++++++++++++++ tests/test_pytypes.cpp | 7 +++++++ tests/test_pytypes.py | 11 +++++++++++ 3 files changed, 40 insertions(+) diff --git a/include/pybind11/typing.h b/include/pybind11/typing.h index 55f1f949da..cf70b739ed 100644 --- a/include/pybind11/typing.h +++ b/include/pybind11/typing.h @@ -80,6 +80,16 @@ class Optional : public object { using object::object; }; +template +class TypeGuard : public bool_ { + using bool_::bool_; +}; + +template +class TypeIs : public bool_ { + using bool_::bool_; +}; + class NoReturn : public none { using none::none; }; @@ -87,6 +97,7 @@ class NoReturn : public none { class Never : public none { using none::none; }; + #if defined(__cpp_nontype_template_parameter_class) template struct StringLiteral { @@ -183,6 +194,16 @@ struct handle_type_name> { static constexpr auto name = const_name("Optional[") + make_caster::name + const_name("]"); }; +template +struct handle_type_name> { + static constexpr auto name = const_name("TypeGuard[") + make_caster::name + const_name("]"); +}; + +template +struct handle_type_name> { + static constexpr auto name = const_name("TypeIs[") + make_caster::name + const_name("]"); +}; + template <> struct handle_type_name { static constexpr auto name = const_name("NoReturn"); @@ -192,6 +213,7 @@ template <> struct handle_type_name { static constexpr auto name = const_name("Never"); }; + #if defined(__cpp_nontype_template_parameter_class) template struct handle_type_name> { diff --git a/tests/test_pytypes.cpp b/tests/test_pytypes.cpp index ce6b93326f..6b347894b0 100644 --- a/tests/test_pytypes.cpp +++ b/tests/test_pytypes.cpp @@ -892,8 +892,15 @@ TEST_SUBMODULE(pytypes, m) { return list; }); + m.def("annotate_type_guard", [](py::object &o) -> py::typing::TypeGuard { + return py::isinstance(o); + }); + m.def("annotate_type_is", + [](py::object &o) -> py::typing::TypeIs { return py::isinstance(o); }); + m.def("annotate_no_return", []() -> py::typing::NoReturn { throw 0; }); m.def("annotate_never", []() -> py::typing::Never { throw 0; }); + m.def("annotate_optional_to_object", [](py::typing::Optional &o) -> py::object { return o; }); diff --git a/tests/test_pytypes.py b/tests/test_pytypes.py index 923cebaf5a..92a3a36bf4 100644 --- a/tests/test_pytypes.py +++ b/tests/test_pytypes.py @@ -991,6 +991,17 @@ def test_optional_annotations(doc): ) +def test_type_guard_annotations(doc): + assert ( + doc(m.annotate_type_guard) + == "annotate_type_guard(arg0: object) -> TypeGuard[str]" + ) + + +def test_type_is_annotations(doc): + assert doc(m.annotate_type_is) == "annotate_type_is(arg0: object) -> TypeIs[str]" + + def test_no_return_annotation(doc): assert doc(m.annotate_no_return) == "annotate_no_return() -> NoReturn" From 0c69e1eb2177fa8f8580632c7b1f97fdb606ce8f Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Tue, 25 Jun 2024 23:51:27 -0400 Subject: [PATCH 7/8] chore: prepare for 2.13.0 (#5198) * chore: prepare for 2.13.0 Signed-off-by: Henry Schreiner * Update changelog.rst --------- Signed-off-by: Henry Schreiner --- .github/workflows/pip.yml | 2 +- docs/changelog.rst | 13 ++++++++++--- include/pybind11/detail/common.h | 4 ++-- noxfile.py | 2 +- pybind11/_version.py | 2 +- 5 files changed, 15 insertions(+), 8 deletions(-) diff --git a/.github/workflows/pip.yml b/.github/workflows/pip.yml index 6d453eabe1..a054ce6952 100644 --- a/.github/workflows/pip.yml +++ b/.github/workflows/pip.yml @@ -58,7 +58,7 @@ jobs: - name: Prepare env run: | - python -m pip install -r tests/requirements.txt build twine!=5.1.0 + python -m pip install -r tests/requirements.txt build twine - name: Python Packaging tests run: pytest tests/extra_python_package/ diff --git a/docs/changelog.rst b/docs/changelog.rst index 0a556973ed..7135e65311 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -33,11 +33,15 @@ New Features: .. feat(types) -* Support for ``type[T]`` was added to pybind11/typing.h. +* Support for ``Union``, ``Optional``, ``type[T]``, ``typing.TypeGuard``, + ``typing.TypeIs``, ``typing.Never``, ``typing.NoReturn`` and + ``typing.Literal`` was added to ``pybind11/typing.h``. `#5166 `_ - -* ``Union`` and ``Optional`` were added to ``pybind11/typing.h``. `#5165 `_ + `#5194 `_ + `#5193 `_ + `#5192 `_ + .. feat(cmake) @@ -93,6 +97,9 @@ CI: * Use ``macos-13`` (Intel) for CI jobs for now (will drop Python 3.7 soon). `#5109 `_ +* Releases now have artifact attestations, visible at + https://github.com/pybind/pybind11/attestations. + `#5196 `_ Other: diff --git a/include/pybind11/detail/common.h b/include/pybind11/detail/common.h index 698421d840..a83302f13e 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 13 -#define PYBIND11_VERSION_PATCH 0.dev1 +#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 0x020D00D1 +#define PYBIND11_VERSION_HEX 0x020D0000 // Define some generic pybind11 helper macros for warning management. // diff --git a/noxfile.py b/noxfile.py index be75def5d4..e9a2fa8fee 100644 --- a/noxfile.py +++ b/noxfile.py @@ -45,7 +45,7 @@ def tests_packaging(session: nox.Session) -> None: Run the packaging tests. """ - session.install("-r", "tests/requirements.txt") + session.install("-r", "tests/requirements.txt", "pip") session.run("pytest", "tests/extra_python_package", *session.posargs) diff --git a/pybind11/_version.py b/pybind11/_version.py index f71abbcdb8..5795f44067 100644 --- a/pybind11/_version.py +++ b/pybind11/_version.py @@ -8,5 +8,5 @@ def _to_int(s: str) -> int | str: return s -__version__ = "2.13.0.dev1" +__version__ = "2.13.0" version_info = tuple(_to_int(s) for s in __version__.split(".")) From 895e657220c1ff2058a4cfee6b185bd0582b0157 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Wed, 26 Jun 2024 00:42:54 -0400 Subject: [PATCH 8/8] chore: back to work Signed-off-by: Henry Schreiner --- include/pybind11/detail/common.h | 6 +++--- pybind11/_version.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/pybind11/detail/common.h b/include/pybind11/detail/common.h index a83302f13e..fc66e6f756 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 13 -#define PYBIND11_VERSION_PATCH 0 +#define PYBIND11_VERSION_MINOR 14 +#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 0x020D0000 +#define PYBIND11_VERSION_HEX 0x020E00D1 // Define some generic pybind11 helper macros for warning management. // diff --git a/pybind11/_version.py b/pybind11/_version.py index 5795f44067..c5cc1a0b09 100644 --- a/pybind11/_version.py +++ b/pybind11/_version.py @@ -8,5 +8,5 @@ def _to_int(s: str) -> int | str: return s -__version__ = "2.13.0" +__version__ = "2.14.0.dev1" version_info = tuple(_to_int(s) for s in __version__.split("."))