Commit Graph

3271 Commits

Author SHA1 Message Date
biergaizi da91926295
fix: remove -stdlib=libc++ from setup helpers, not needed on modern Pythons (#4639)
* Inject -stdlib=libc++ on macOS only when it's supported, close #4637.

On macOS, by default, pybind11 currently unconditionally set the compiler
flag "-stdlib=libc++" in Pybind11Extension.__init__(), regardless of which
compiler is used. This flag is required for clang, but is invalid for GCC.
If GCC is used, it causes compilation failures in all Python projects that
use pybind11, with the error message:

    arm64-apple-darwin22-gcc: error: unrecognized command-line option -stdlib=libc++.

This commit uses has_flag() to detect whether "-stdlib=libc++" on macOS,
and injects this flag from build_ext.build_extensions(), rather than
setting it unconditionally.

Signed-off-by: Yifeng Li <tomli@tomli.me>

* revert: just remove flags

---------

Signed-off-by: Yifeng Li <tomli@tomli.me>
Co-authored-by: Henry Schreiner <HenrySchreinerIII@gmail.com>
2023-05-01 10:14:52 -04:00
Ralf W. Grosse-Kunstleve 9cbf45d4ea appease ruff v0.0.263 2023-04-30 21:23:57 -07:00
Ralf W. Grosse-Kunstleve 7d92147666 ruff v0.0.263 auto fix with new manual line breaks 2023-04-30 21:23:57 -07:00
Ralf W. Grosse-Kunstleve ed4317e790 clang-format 16 auto fix 2023-04-30 21:23:57 -07:00
Ralf W. Grosse-Kunstleve 4d597f8aa0 Merge branch 'master' into sh_merge_master 2023-04-30 21:23:26 -07:00
Henry Schreiner 956390a87f
fix(cmake): only define lto if CMAKE's IPO setting is unset (#4643)
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
2023-04-29 10:15:45 -04:00
pre-commit-ci[bot] 5e946c2fa5
chore(deps): update pre-commit hooks (#4605)
* chore(deps): update pre-commit hooks

updates:
- [github.com/psf/black: 23.1.0 → 23.3.0](https://github.com/psf/black/compare/23.1.0...23.3.0)
- [github.com/Lucas-C/pre-commit-hooks: v1.4.2 → v1.5.1](https://github.com/Lucas-C/pre-commit-hooks/compare/v1.4.2...v1.5.1)
- [github.com/charliermarsh/ruff-pre-commit: v0.0.254 → v0.0.260](https://github.com/charliermarsh/ruff-pre-commit/compare/v0.0.254...v0.0.260)
- [github.com/PyCQA/pylint: v2.16.4 → v3.0.0a6](https://github.com/PyCQA/pylint/compare/v2.16.4...v3.0.0a6)
- [github.com/pre-commit/mirrors-mypy: v1.0.1 → v1.1.1](https://github.com/pre-commit/mirrors-mypy/compare/v1.0.1...v1.1.1)
- [github.com/codespell-project/codespell: v2.2.2 → v2.2.4](https://github.com/codespell-project/codespell/compare/v2.2.2...v2.2.4)
- [github.com/pre-commit/mirrors-clang-format: v15.0.7 → v16.0.0](https://github.com/pre-commit/mirrors-clang-format/compare/v15.0.7...v16.0.0)

* style: pre-commit fixes

* style: fix issues

* Update tests/test_call_policies.py

* Update tests/test_call_policies.py

* fix: ignore code in file

* style: pre-commit fixes

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Henry Schreiner <HenrySchreinerIII@gmail.com>
2023-04-28 14:32:32 -04:00
Ralf W. Grosse-Kunstleve 3f366ff888
Remove stray comment. (Oversight in PR #4631. Noticed by chance.) (#4641) 2023-04-27 07:24:48 -07:00
Ralf W. Grosse-Kunstleve 3ed60604e5 Tracking ci.yml changes from master. 2023-04-26 23:44:24 -07:00
Ralf W. Grosse-Kunstleve d85bcd8976 Merge branch 'master' into sh_merge_master 2023-04-26 23:39:56 -07:00
Ralf W. Grosse-Kunstleve 6de6191a0c
Use `std::hash<std::type_index>`, `std::equal_to<std::type_index>` everywhere **except when libc++ is in use** (#4319)
* Try using `std::hash<std::type_index>`, `std::equal_to<std::type_index>` everywhere.

From PR #4316 we know that types in the unnamed namespace in different translation units do not compare equal, as desired.

But do types in named namespaces compare equal, as desired?

* Revert "Try using `std::hash<std::type_index>`, `std::equal_to<std::type_index>` everywhere."

This reverts commit a06949a926.

* Use "our own name-based hash and equality functions" for `std::type_index` only under macOS, based on results shown under https://github.com/pybind/pybind11/pull/4316#issuecomment-1305097879

* Patch in PR #4313: Minimal reproducer for clash when binding types defined in the unnamed namespace.

* test_unnamed_namespace_b xfail for clang

* `PYBIND11_INTERNALS_VERSION 5`

* Add a note to docs/classes.rst

* For compatibility with Google-internal testing, test_unnamed_namespace_a & test_unnamed_namespace_b need to work when imported in any order.

* Trying "__GLIBCXX__ or Windows", based on observations from Google-internal testing.

* Try _LIBCPP_VERSION

* Account for libc++ behavior in tests and documentation.

* Adjust expectations for Windows Clang (and make code less redundant).

* Add WindowsClang to ci.yml

Added block transferred from PR #4321

* Add clang-latest to name that appears in the GitHub Actions web view.

* Tweak the note in classes.rst again.

* Add `pip install --upgrade pip`, Show env, cosmetic changes

Already tested under PR #4321

* Add macos_brew_install_llvm to ci.yml

Added block transferred from PR #4324

* `test_cross_module_exception_translator` xfail 'Homebrew Clang'

* Revert back to base version of .github/workflows/ci.yml (the ci.yml changes were merged under #4323 and #4326)

* Fixes for ruff

* Make updated condition in internals.h dependent on ABI version.

* Remove PYBIND11_TEST_OVERRIDE when testing with PYBIND11_INTERNALS_VERSION=10000000

* Selectively exercise cmake `-DPYBIND11_TEST_OVERRIDE`: ubuntu, macos, windows

Extra work added to quick jobs, based on timings below, to not increase the GHA start-to-last-job-finished time.

```
Duration
^              Number of pytest runs
^              ^ Job identifier
^              ^ ^
0:03:48.024227 1 1___3___Clang_3.6___C++11___x64.txt
0:03:58.992814 1 2___3___Clang_3.7___C++11___x64.txt
0:04:25.758942 1 1___3.7___Debian___x86____Install.txt
0:04:50.148276 1 4___3___Clang_7___C++11___x64.txt
0:04:55.784558 1 13___3___Clang_15___C++20___x64.txt
0:04:57.048754 1 6___3___Clang_dev___C++11___x64.txt
0:05:00.485181 1 7___3___Clang_5___C++14___x64.txt
0:05:03.744964 1 2___3___almalinux8___x64.txt
0:05:06.222752 1 5___3___Clang_9___C++11___x64.txt
0:05:11.767022 1 2___3___GCC_7___C++17__x64.txt
0:05:18.634930 1 2___3.11__deadsnakes____x64.txt
0:05:22.810995 1 1___3___GCC_7___C++11__x64.txt
0:05:25.275317 1 12___3___Clang_14___C++20___x64.txt
0:05:32.058174 1 5___3___GCC_10___C++17__x64.txt
0:05:39.381351 1 7___3___GCC_12___C++20__x64.txt
0:05:40.502252 1 8___3___Clang_10___C++17___x64.txt
0:05:59.344905 1 3___3___Clang_3.9___C++11___x64.txt
0:06:10.825147 1 6___3___GCC_11___C++20__x64.txt
0:06:20.655443 1 3___3___almalinux9___x64.txt
0:06:22.472061 1 3___3___GCC_8___C++14__x64.txt
0:06:42.647406 1 11___3___Clang_13___C++20___x64.txt
0:06:53.352720 1 1___3.10___CUDA_11.7___Ubuntu_22.04.txt
0:07:07.357801 1 2___3.7___MSVC_2019___x86_-DCMAKE_CXX_STANDARD=14.txt
0:07:09.057603 1 1___3___centos7___x64.txt
0:07:15.546282 1 1___3.8___MSVC_2019__Debug____x86_-DCMAKE_CXX_STANDARD=17.txt
0:07:22.566022 1 4___3___GCC_8___C++17__x64.txt
0:08:13.592674 1 2___3.9___MSVC_2019__Debug____x86_-DCMAKE_CXX_STANDARD=20.txt
0:08:16.422768 1 9___3___Clang_11___C++20___x64.txt
0:08:21.168457 1 3___3.8___MSVC_2019___x86_-DCMAKE_CXX_STANDARD=17.txt
0:08:27.129468 1 10___3___Clang_12___C++20___x64.txt
0:09:35.045470 1 1___3.10___windows-latest___clang-latest.txt
0:09:57.361843 1 1___3.9___MSVC_2022_C++20___x64.txt
0:10:35.187767 1 1___3.6___MSVC_2019___x86.txt
0:11:14.691200 4 2___3.9___ubuntu-20.04___x64.txt
0:11:37.701167 1 1_macos-latest___brew_install_llvm.txt
0:11:38.688299 4 4___3.11___ubuntu-20.04___x64.txt
0:11:52.720216 1 4___3.9___MSVC_2019___x86_-DCMAKE_CXX_STANDARD=20.txt
0:13:23.456591 4 6___pypy-3.8___ubuntu-20.04___x64_-DPYBIND11_FINDPYTHON=ON.txt
0:13:25.863592 2 1___3___ICC_latest___x64.txt
0:13:32.411758 3 9___3.9___windows-2022___x64.txt
0:13:45.473377 4 3___3.10___ubuntu-20.04___x64.txt
0:13:55.366447 4 5___pypy-3.7___ubuntu-20.04___x64.txt
0:13:57.969502 3 10___3.10___windows-2022___x64.txt
0:14:19.837475 3 11___3.11___windows-2022___x64.txt
0:14:33.316770 4 1___3.6___ubuntu-20.04___x64_-DPYBIND11_FINDPYTHON=ON_-DCMA.txt
0:15:34.449278 4 22___3.6___windows-2019___x64_-DPYBIND11_FINDPYTHON=ON.txt
0:16:25.189055 2 1___3.9-dbg__deadsnakes____Valgrind___x64.txt
0:17:20.956667 4 15___3.6___macos-latest___x64.txt
0:17:27.513891 4 23___3.9___windows-2019___x64.txt
0:17:58.783286 3 8___3.6___windows-2022___x64.txt
0:18:25.917828 4 7___pypy-3.9___ubuntu-20.04___x64.txt
0:19:17.399820 3 13___pypy-3.8___windows-2022___x64.txt
0:19:45.002122 3 12___pypy-3.7___windows-2022___x64.txt
0:20:03.201926 4 16___3.9___macos-latest___x64.txt
0:20:15.415178 4 17___3.10___macos-latest___x64.txt
0:20:20.263216 4 20___pypy-3.8___macos-latest___x64.txt
0:20:31.998226 3 1___3___windows-latest___mingw64.txt
0:20:40.812286 4 18___3.11___macos-latest___x64.txt
0:22:47.714749 4 19___pypy-3.7___macos-latest___x64.txt
0:23:04.435859 3 2___3___windows-latest___mingw32.txt
0:25:48.719597 3 14___pypy-3.9___windows-2022___x64.txt
0:26:01.211688 4 21___pypy-3.9___macos-latest___x64.txt
0:28:19.971015 1 1___3___CentOS7__PGI_22.9___x64.txt
```

* Update skipif for Python 3.12a7 (the WIP needs to be handled in a separate PR).
2023-04-25 14:03:24 -07:00
Ralf W. Grosse-Kunstleve ff7f5dfca3
1. Fully test unstable ABI (#4635)
2. Selectively exercise cmake `-DPYBIND11_TEST_OVERRIDE`: ubuntu, macos, windows

Extra work added to quick jobs, based on timings below, to not increase the GHA start-to-last-job-finished time.

```
Duration
^              Number of pytest runs
^              ^ Job identifier
^              ^ ^
0:03:48.024227 1 1___3___Clang_3.6___C++11___x64.txt
0:03:58.992814 1 2___3___Clang_3.7___C++11___x64.txt
0:04:25.758942 1 1___3.7___Debian___x86____Install.txt
0:04:50.148276 1 4___3___Clang_7___C++11___x64.txt
0:04:55.784558 1 13___3___Clang_15___C++20___x64.txt
0:04:57.048754 1 6___3___Clang_dev___C++11___x64.txt
0:05:00.485181 1 7___3___Clang_5___C++14___x64.txt
0:05:03.744964 1 2___3___almalinux8___x64.txt
0:05:06.222752 1 5___3___Clang_9___C++11___x64.txt
0:05:11.767022 1 2___3___GCC_7___C++17__x64.txt
0:05:18.634930 1 2___3.11__deadsnakes____x64.txt
0:05:22.810995 1 1___3___GCC_7___C++11__x64.txt
0:05:25.275317 1 12___3___Clang_14___C++20___x64.txt
0:05:32.058174 1 5___3___GCC_10___C++17__x64.txt
0:05:39.381351 1 7___3___GCC_12___C++20__x64.txt
0:05:40.502252 1 8___3___Clang_10___C++17___x64.txt
0:05:59.344905 1 3___3___Clang_3.9___C++11___x64.txt
0:06:10.825147 1 6___3___GCC_11___C++20__x64.txt
0:06:20.655443 1 3___3___almalinux9___x64.txt
0:06:22.472061 1 3___3___GCC_8___C++14__x64.txt
0:06:42.647406 1 11___3___Clang_13___C++20___x64.txt
0:06:53.352720 1 1___3.10___CUDA_11.7___Ubuntu_22.04.txt
0:07:07.357801 1 2___3.7___MSVC_2019___x86_-DCMAKE_CXX_STANDARD=14.txt
0:07:09.057603 1 1___3___centos7___x64.txt
0:07:15.546282 1 1___3.8___MSVC_2019__Debug____x86_-DCMAKE_CXX_STANDARD=17.txt
0:07:22.566022 1 4___3___GCC_8___C++17__x64.txt
0:08:13.592674 1 2___3.9___MSVC_2019__Debug____x86_-DCMAKE_CXX_STANDARD=20.txt
0:08:16.422768 1 9___3___Clang_11___C++20___x64.txt
0:08:21.168457 1 3___3.8___MSVC_2019___x86_-DCMAKE_CXX_STANDARD=17.txt
0:08:27.129468 1 10___3___Clang_12___C++20___x64.txt
0:09:35.045470 1 1___3.10___windows-latest___clang-latest.txt
0:09:57.361843 1 1___3.9___MSVC_2022_C++20___x64.txt
0:10:35.187767 1 1___3.6___MSVC_2019___x86.txt
0:11:14.691200 4 2___3.9___ubuntu-20.04___x64.txt
0:11:37.701167 1 1_macos-latest___brew_install_llvm.txt
0:11:38.688299 4 4___3.11___ubuntu-20.04___x64.txt
0:11:52.720216 1 4___3.9___MSVC_2019___x86_-DCMAKE_CXX_STANDARD=20.txt
0:13:23.456591 4 6___pypy-3.8___ubuntu-20.04___x64_-DPYBIND11_FINDPYTHON=ON.txt
0:13:25.863592 2 1___3___ICC_latest___x64.txt
0:13:32.411758 3 9___3.9___windows-2022___x64.txt
0:13:45.473377 4 3___3.10___ubuntu-20.04___x64.txt
0:13:55.366447 4 5___pypy-3.7___ubuntu-20.04___x64.txt
0:13:57.969502 3 10___3.10___windows-2022___x64.txt
0:14:19.837475 3 11___3.11___windows-2022___x64.txt
0:14:33.316770 4 1___3.6___ubuntu-20.04___x64_-DPYBIND11_FINDPYTHON=ON_-DCMA.txt
0:15:34.449278 4 22___3.6___windows-2019___x64_-DPYBIND11_FINDPYTHON=ON.txt
0:16:25.189055 2 1___3.9-dbg__deadsnakes____Valgrind___x64.txt
0:17:20.956667 4 15___3.6___macos-latest___x64.txt
0:17:27.513891 4 23___3.9___windows-2019___x64.txt
0:17:58.783286 3 8___3.6___windows-2022___x64.txt
0:18:25.917828 4 7___pypy-3.9___ubuntu-20.04___x64.txt
0:19:17.399820 3 13___pypy-3.8___windows-2022___x64.txt
0:19:45.002122 3 12___pypy-3.7___windows-2022___x64.txt
0:20:03.201926 4 16___3.9___macos-latest___x64.txt
0:20:15.415178 4 17___3.10___macos-latest___x64.txt
0:20:20.263216 4 20___pypy-3.8___macos-latest___x64.txt
0:20:31.998226 3 1___3___windows-latest___mingw64.txt
0:20:40.812286 4 18___3.11___macos-latest___x64.txt
0:22:47.714749 4 19___pypy-3.7___macos-latest___x64.txt
0:23:04.435859 3 2___3___windows-latest___mingw32.txt
0:25:48.719597 3 14___pypy-3.9___windows-2022___x64.txt
0:26:01.211688 4 21___pypy-3.9___macos-latest___x64.txt
0:28:19.971015 1 1___3___CentOS7__PGI_22.9___x64.txt
```
2023-04-25 10:25:57 -07:00
Ralf W. Grosse-Kunstleve 07725c28c0
Introduce `pybind11::detail::is_move_constructible` (#4631)
To support the use case captured in the new test_vector_unique_ptr_member.cpp
2023-04-24 00:19:21 -07:00
dependabot[bot] 071f35ab85
chore(deps): bump jwlawson/actions-setup-cmake from 1.13 to 1.14 (#4632)
Bumps [jwlawson/actions-setup-cmake](https://github.com/jwlawson/actions-setup-cmake) from 1.13 to 1.14.
- [Release notes](https://github.com/jwlawson/actions-setup-cmake/releases)
- [Commits](https://github.com/jwlawson/actions-setup-cmake/compare/v1.13...v1.14)

---
updated-dependencies:
- dependency-name: jwlawson/actions-setup-cmake
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-04-23 12:32:35 -04:00
Ralf W. Grosse-Kunstleve 6e81be2183
Introduce `pybind11::detail::is_move_constructible` (#4630)
To support the use case captured in the new test_vector_unique_ptr_member.cpp
2023-04-21 11:30:35 -07:00
Ralf W. Grosse-Kunstleve d930de0bca
Alternative approach to #3807 (#4612)
* Alternative approach to #3807 that supports an important PyCLIF use case: `Base` not specified in `classh<Derived>` statement, but passing Derived as Base works anyway.

* NOtest_multiple_inheritance_getattr in test_class_sh_void_ptr_capsule.py (quick experiment)

* Revert "NOtest_multiple_inheritance_getattr in test_class_sh_void_ptr_capsule.py (quick experiment)"

This reverts commit e8f0749b89.

* Special handling of pybind11 objects to side-step try_as_void_ptr_capsule_get_pointer __getattr__ issues.

* Inspect `internals.registered_types_py` in `type_is_pybind11_class_()`

* Remove debug code in tests subdir.

* Clean up the modified `try_as_void_ptr_capsule_get_pointer()` implementation and new helper functions.
2023-04-10 11:13:28 -07:00
Ralf W. Grosse-Kunstleve c6a4191d15 Merge branch 'master' into smart_holder 2023-04-08 11:59:35 -07:00
dependabot[bot] ed466da571
chore(deps): bump pypa/gh-action-pypi-publish from 1.8.4 to 1.8.5 (#4604)
Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) from 1.8.4 to 1.8.5.
- [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases)
- [Commits](https://github.com/pypa/gh-action-pypi-publish/compare/v1.8.4...v1.8.5)

---
updated-dependencies:
- dependency-name: pypa/gh-action-pypi-publish
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-04-07 15:52:41 -04:00
Ralf W. Grosse-Kunstleve fb78376ecd Merge branch 'master' into sh_merge_master 2023-04-06 13:19:17 -07:00
Xiaofei Wang 99cf27a4f5
[smart_holder] Keep parent alive when returning raw pointers (#4609)
* Avoid dangling pointers.

* Add test for const ptr

* Fix test failures.

* Fix ClangTidy

* fix emplace_back
2023-04-06 13:18:05 -07:00
dependabot[bot] 7ab88d2e4f
chore(deps): bump pypa/gh-action-pypi-publish from 1.8.3 to 1.8.4 (#4602)
Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) from 1.8.3 to 1.8.4.
- [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases)
- [Commits](https://github.com/pypa/gh-action-pypi-publish/compare/v1.8.3...v1.8.4)

---
updated-dependencies:
- dependency-name: pypa/gh-action-pypi-publish
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-04-03 10:18:53 -04:00
Henry Schreiner 4ce05175d5
ci: Python 3.12 optional test job (#4575)
* ci: Python 3.12 optional testing

Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>

* Skip test_flaky_exception_failure_point_init() for Python 3.12.0a6 (similar to af5c6536ab (diff-f46006e3f43ffb1dd5d6862005427f6620f4dcfb1fa2f883d8482550069eeecc)).

* Disable tests/test_embed/test_interpreter.cpp (broken with Python 3.12.0alpha6)

```
free(): invalid pointer

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
test_embed is a Catch v2.13.9 host application.
Run with -? for options

-------------------------------------------------------------------------------
Custom PyConfig
-------------------------------------------------------------------------------
/home/runner/work/pybind11/pybind11/tests/test_embed/test_interpreter.cpp:175
...............................................................................

/home/runner/work/pybind11/pybind11/tests/test_embed/test_interpreter.cpp:179: FAILED:
  {Unknown expression after the reported line}
due to a fatal error condition:
  SIGABRT - Abort (abnormal termination) signal

===============================================================================
test cases:    6 |    5 passed | 1 failed
assertions: 1518 | 1517 passed | 1 failed
```

---------

Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
Co-authored-by: Ralf W. Grosse-Kunstleve <rwgk@google.com>
2023-03-30 10:29:25 -04:00
Ralf W. Grosse-Kunstleve b37a1cd01d Merge branch 'master' into sh_merge_master 2023-03-27 18:00:01 -07:00
Ralf W. Grosse-Kunstleve 654fe92652
Introduce `get_python_state_dict()` for Python 3.12 compatibility. (#4570)
* Introduce `get_python_state_dict()`

* Conditional version bump for Python 3.12+

* Shuffle subexpressions to make the condition easier to understand (no change to logic).

* Make pybind11 ABI version 5 the minimum for Python 3.12+ (as suggested by @Lalaland)

* Add back condition for PYPY_VERSION, but keep it open for future PyPy versions.

* Fall back to simple `|| defined(PYPY_VERSION)`. `PY_VERSION_HEX` does not appear to be meaningful with PyPy.
2023-03-27 17:52:57 -07:00
Aaron Gokaslan 1e8b52a9ac
bugfix: allow noexcept lambdas in C++17. Fix #4565 (#4593)
* bugfix: allow noexcept lambdas in CPP17. Fix #4565

* Remove unused code from test case

* Fix clang-tidy error

* Address reviewer comment
2023-03-27 20:21:06 -04:00
Aaron Gokaslan 66f12df03b
chore: make #4587 use proper cpp17 feature macro (#4592) 2023-03-27 10:59:56 -04:00
Ralf W. Grosse-Kunstleve 4f3a1a8231
Add `test_class_sh_property_non_owning` to CMakeLists.txt (#4590)
* use C++17 syntax to get rid of recursive template instantiations for concatenating type signatures (#4587)

* Apply descr.h `src_loc` change (smart_holder PR #4022) to code added with master PR #4587

* Add test_class_sh_property_non_owning to CMakeLists.txt (fixes oversight in PR #4586)

* Resolve clang-tidy errors.

* clang-tidy auto fix

---------

Co-authored-by: Konstantin Bespalov <kos5tya@yandex.ru>
2023-03-24 00:07:39 -07:00
Ralf W. Grosse-Kunstleve 13936bb258 Apply descr.h `src_loc` change (smart_holder PR #4022) to code added with master PR #4587 2023-03-23 22:12:13 -07:00
Ralf W. Grosse-Kunstleve 6b8264fb24 Merge branch 'master' into sh_merge_master 2023-03-23 22:05:18 -07:00
Konstantin Bespalov 5bbcba548a
use C++17 syntax to get rid of recursive template instantiations for concatenating type signatures (#4587) 2023-03-23 22:01:09 -07:00
Ralf W. Grosse-Kunstleve 083a03d122 Merge branch 'master' into sh_merge_master 2023-03-23 17:25:43 -07:00
Ralf W. Grosse-Kunstleve 37d0bf4289
[smart_holder] Enable properties for non-owning holders (#4586)
* Add test_class_sh_property_non_owning.cpp,py

Failing:

```
__________________________________________________________ test_persistent_holder __________________________________________________________

    def test_persistent_holder():
        h = m.DataFieldsHolder(2)
>       c = h.vec_at(0).core_fld
E       RuntimeError: Non-owning holder (loaded_as_shared_ptr).

h          = <pybind11_tests.class_sh_property_non_owning.DataFieldsHolder object at 0x7fabab516470>

test_class_sh_property_non_owning.py:6: RuntimeError
__________________________________________________________ test_temporary_holder ___________________________________________________________

    def test_temporary_holder():
        d = m.DataFieldsHolder(2).vec_at(1)
>       c = d.core_fld
E       RuntimeError: Non-owning holder (loaded_as_shared_ptr).

d          = <pybind11_tests.class_sh_property_non_owning.DataField object at 0x7fabab548770>

test_class_sh_property_non_owning.py:13: RuntimeError
```

* Introduce `shared_ptr_from_python(responsible_parent)` and use in all `property_cpp_function`s with `const shared_ptr<T> &` arguments.

Tests are incomplete.

* Complete tests.

* Add comment for `smart_holder_type_caster_load<T>::shared_ptr_from_python`
2023-03-23 17:21:41 -07:00
dependabot[bot] 286873ecf7
chore(deps): bump pypa/gh-action-pypi-publish from 1.8.1 to 1.8.3 (#4584)
Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) from 1.8.1 to 1.8.3.
- [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases)
- [Commits](https://github.com/pypa/gh-action-pypi-publish/compare/v1.8.1...v1.8.3)

---
updated-dependencies:
- dependency-name: pypa/gh-action-pypi-publish
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-03-23 10:23:52 -04:00
Ralf W. Grosse-Kunstleve 945be5bbd9 Merge branch 'master' into sh_merge_master 2023-03-16 21:36:21 -07:00
Ralf W. Grosse-Kunstleve cf7d2e6f15
Change `always_forkserver_on_unix()` to `use_multiprocessing_forkserver_on_linux()` (#4577) 2023-03-16 14:33:34 -07:00
Henry Schreiner c4c15d4b10
docs: changelog for 2.10.4 (#4532)
* docs: changelog for 2.10.4

Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>

* Apply suggestions from code review

* Update docs/changelog.rst

---------

Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
2023-03-16 16:01:28 -04:00
dependabot[bot] 04ef4e4229
chore(deps): bump pypa/gh-action-pypi-publish from 1.6.4 to 1.8.1 (#4576) 2023-03-16 18:18:44 +00:00
Ralf W. Grosse-Kunstleve 442261da58
Remove test code that does not exercise anything in pybind11, but breaks between Python 3.12alpha3 (still working) and 3.12alpha6 (broken): (#4559)
```
str(OrderedDict([(1, "a"), (2, "b")]))
```

Old:
```
OrderedDict([(1, 'a'), (2, 'b')])
```

New:
```
OrderedDict({1: 'a', 2: 'b'})
```

See also: https://github.com/python/cpython/issues/101446
2023-03-09 13:02:34 -08:00
pre-commit-ci[bot] cbb876cc7b
chore(deps): update pre-commit hooks (#4552)
updates:
- [github.com/charliermarsh/ruff-pre-commit: v0.0.251 → v0.0.254](https://github.com/charliermarsh/ruff-pre-commit/compare/v0.0.251...v0.0.254)
- [github.com/PyCQA/pylint: v2.16.1 → v2.16.4](https://github.com/PyCQA/pylint/compare/v2.16.1...v2.16.4)
- [github.com/pre-commit/mirrors-mypy: v0.991 → v1.0.1](https://github.com/pre-commit/mirrors-mypy/compare/v0.991...v1.0.1)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2023-03-07 00:34:41 -05:00
Xiaofei Wang 114c0f2a3e
[smart_holder] Implement `try_as_void_ptr_capsule` as a free function (#4539)
* Move try_as_void_ptr_capsule out from modified_type_caster_generic_load_impl.

* Try fixing clangtidy
2023-02-28 17:35:21 -08:00
Eli Schwartz 3cc7e4258c
add --version option to pybind11-config (#4526)
Without this, it's impossible to get feature parity between detection
mechanisms. Both the pkg-config file and the cmake config set their
versions, but the python probe script didn't provide an option for this.

So you could print the compiler flags for using it, but you could not
check what you got.
2023-02-22 21:59:14 -08:00
Ralf W. Grosse-Kunstleve 480eb36b3a ubench ruff noqa (in files) 2023-02-22 14:05:23 -08:00
Ralf W. Grosse-Kunstleve 1c10b097a7 test_class_sh_void_ptr_capsule.py manual fixes for ruff 2023-02-22 13:01:46 -08:00
Ralf W. Grosse-Kunstleve 9b78303d7b trivial manual fixes for ruff 2023-02-22 13:00:31 -08:00
Ralf W. Grosse-Kunstleve cee7cec5f4 ruff auto-fixes (to be reviewed) 2023-02-22 12:46:12 -08:00
Ralf W. Grosse-Kunstleve e0029bd3b0 ruff: exclude: ubench for now 2023-02-22 12:42:23 -08:00
Ralf W. Grosse-Kunstleve 9005b55bdf Merge branch 'master' into sh_merge_master 2023-02-22 12:32:31 -08:00
Ralf W. Grosse-Kunstleve 9a90783b1e Merge branch 'master' into sh_merge_master 2023-02-22 11:24:43 -08:00
Ralf W. Grosse-Kunstleve 7087a74add Revert "Appease new flake8 B028 error:"
This reverts commit 44c2d89c47.
2023-02-22 11:24:34 -08:00
Henry Schreiner 438034c5b8
chore: move to Ruff and add rules (#4483) 2023-02-22 06:18:55 -08:00