| chore(deps): bump the actions group with 3 updates (#6098) * chore(deps): bump the actions group with 3 updates Bumps the actions group with 3 updates: [actions/checkout](https://github.com/actions/checkout), [astral-sh/setup-uv](https://github.com/astral-sh/setup-uv) and [pypa/cibuildwheel](https://github.com/pypa/cibuildwheel). Updates `actions/checkout` from 6 to 7 - [Release notes](https://github.com/actions/checkout/releases) - [Commits](https://github.com/actions/checkout/compare/v6...v7) Updates `astral-sh/setup-uv` from 8.1.0 to 8.2.0 - [Release notes](https://github.com/astral-sh/setup-uv/releases) - [Commits](https://github.com/astral-sh/setup-uv/compare/v8.1.0...v8.2.0) Updates `pypa/cibuildwheel` from 3.4 to 4.1 - [Release notes](https://github.com/pypa/cibuildwheel/releases) - [Changelog](https://github.com/pypa/cibuildwheel/blob/main/docs/changelog.md) - [Commits](https://github.com/pypa/cibuildwheel/compare/v3.4...v4.1) --- updated-dependencies: - dependency-name: actions/checkout dependency-version: '7' dependency-type: direct:production update-type: version-update:semver-major dependency-group: actions - dependency-name: astral-sh/setup-uv dependency-version: 8.2.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: actions - dependency-name: pypa/cibuildwheel dependency-version: '4.1' dependency-type: direct:production update-type: version-update:semver-major dependency-group: actions ... Signed-off-by: dependabot[bot] <support@github.com> * ci: restore checkout v1 for i386 job --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Ralf W. Grosse-Kunstleve <rgrossekunst@nvidia.com> | 5 天前 |
| feat(subinterpreter): reusable PyThreadState via subinterpreter_thread_state (#6073) * feat(subinterpreter): add opt-in TLS-cached thread state mode subinterpreter_scoped_activate previously created and destroyed a fresh PyThreadState on every activation when the calling OS thread was not already running the target interpreter. Workloads that repeatedly re-enter the same sub-interpreter from the same thread therefore churn thread states and lose per-thread interpreter state between activations (see pybind/pybind11#6040). Add an opt-in subinterpreter_thread_state::cached policy: on first use a PyThreadState is created and stored in OS-thread-local storage keyed by the target interpreter; subsequent activations on that thread only swap it in/out and never destroy it. The default stays transient, so existing behavior is unchanged. Since pybind11 does not control thread lifetime, cleanup is explicit: subinterpreter::release_cached_thread_state() releases the calling thread's cached state for one interpreter, and the static release_all_cached_thread_states() releases all of the calling thread's cached states as an end-of-thread hook. The TLS map's destructor only frees its own nodes and never touches the Python C API, so an unreleased state leaks rather than crashing at thread exit. Includes test coverage and embedding docs. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> * style: pre-commit fixes * refactor(subinterpreter): replace cached enum/TLS with subinterpreter_thread_state RAII Address review feedback on the original "cached" mode by switching to an explicit two-RAII design suggested by @b-pass: "Create a class ... to RAII-manage the PyThreadState but start its lifetime in an already released state. You could create another class (or modify scoped_activate) to scoped/RAII activate the inactive threadstate." Removed - enum subinterpreter_thread_state { transient, cached } and the defaulted ctor parameter on subinterpreter_scoped_activate. - detail::subinterpreter_thread_state_cache thread_local map. - subinterpreter::release_cached_thread_state() and subinterpreter::release_all_cached_thread_states(). This eliminates: the hidden per-thread map, the "release_all" footgun across pybind11 modules (the cache was module-local), and the implicit "must not be active when called" contract on the release functions. Added - Public class subinterpreter_thread_state that owns one PyThreadState for a given subinterpreter on its constructing OS thread, created in a released state (not current, no GIL). Non-copyable, non-movable (PyThreadState is bound to its creating OS thread). - subinterpreter_scoped_activate(subinterpreter_thread_state &) overload: swaps the owned PyThreadState in on entry, swaps it out on exit, does not touch its lifetime. Behavior - The existing subinterpreter_scoped_activate(subinterpreter const &) overload is unchanged (still transient: New on entry, Delete on exit). All previously-working code keeps working. - With subinterpreter_thread_state, one OS thread can alternate between multiple subinterpreters and each PyThreadState is preserved across activations -- the use case that gil_scoped_release/acquire + a long-lived scoped_activate cannot solve alone (the per-thread internals.tstate slot holds only one inactive tstate). - The dtor of subinterpreter_thread_state guards against the "destroyed-while-active" contract violation: if Swap reveals the cached tstate was current, do not Swap back to a now-deleted pointer (the safe-when-active fix b-pass requested for the old release_* functions, applied at the natural location instead). Lifetime contract is enforced by ordinary C++ scope: typical placement is `thread_local`. No new release/cleanup APIs are required. Tests cover (a) tstate identity preserved across activations on a thread, (b) transient and reusing modes do not share state, (c) different OS threads get distinct PyThreadStates, and (d) the multi-subinterpreter alternation case. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> * fix(subinterpreter): address review on #6073 (same-thread checks, test scoping) Per @b-pass's review: - ~subinterpreter_thread_state(): add a PYBIND11_DETAILED_ERROR_MESSAGES- guarded check that destruction happens on the OS thread that created the PyThreadState (same PyThread_get_thread_native_id pattern as ~subinterpreter), failing with pybind11_fail otherwise. - subinterpreter_scoped_activate(subinterpreter_thread_state &): add the matching DETAILED_ERROR_MESSAGES check that activation happens on the creating OS thread, enforcing the newly documented rule. - docs: document that activating a subinterpreter_thread_state on another OS thread is illegal. - tests: keep each subinterpreter (and its subinterpreter_thread_state) in an enclosing scope so destruction order is thread-state -> subinterpreter -> unsafe_reset_internals_for_single_interpreter(). The previous top-level declarations ran the reset while the subinterpreters were still alive, which is the likely cause of the CI crashes. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> * docs: fix codespell (re-used -> reused) in embedding.rst Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> | 1 个月前 |
| revert: "add life support to handles cast to string_view (#6092)" (#6097) This reverts commit 59d7cb28c1f5a014bb17ad4a8e80da2fb51a6159 (#6092). #6092 introduced regressions that are being addressed in #6096; reverting Assisted-by: ClaudeCode:claude-opus-4.8 | 10 天前 |
| chore(setup_helpers): remove dead cpp_flag_cache and fix parameter typo (#6085) Remove the module-level `cpp_flag_cache = None` variable and its stale comment "Every call will cache the result". The actual caching is handled by the `@lru_cache` decorator on `auto_cpp_level` directly below. Also rename the typo'd parameter `obg` to `obj` in `no_recompile`. Nothing passes this argument by keyword, so there is no API break. Part of #6084 Assisted-by: ClaudeCode:claude-sonnet-4-6 | 22 天前 |
| revert: "add life support to handles cast to string_view (#6092)" (#6097) This reverts commit 59d7cb28c1f5a014bb17ad4a8e80da2fb51a6159 (#6092). #6092 introduced regressions that are being addressed in #6096; reverting Assisted-by: ClaudeCode:claude-opus-4.8 | 10 天前 |
| Apply -undefined dynamic_lookup to all Apple platforms (#6075) * Apply -undefined dynamic_lookup to all Apple platforms * style: pre-commit fixes --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> | 1 个月前 |
| feat: remove Python 3.6 support (#5177) * Change Python version guard: PYTHON < 3.7 IS UNSUPPORTED. * Replace or remove Python 3.6 jobs. * Move appveyor to Python 3.8 * Change `[tool.pylint]` `master.py-version` from `3.6` to `3.8` * Change `[tool.pylint]` `master.py-version` to `3.7` * Remove `centos:7` job; Change almalinux:8 job to use Python 3.8 * Try 🐍 3.8 • ubuntu-20.04 • x64 without `-DCMAKE_CXX_FLAGS="-D_=1"` * Update setup.cfg as suggested by @henryiii * Try running `cmake --build . --target cpptest` on all platforms (`standard` job). * Disable deadsnakes jobs entirely. * Apply PR #5179: Add Python 3.10, 3.11, 3.12 to win32 job matrix. * Add back `-DCMAKE_CXX_FLAGS="-D_=1"` but do not install boost in that case. * PY_VERSION_HEX < 3.7 cleanup pass: include/pybind11 * WITH_THREAD cleanup pass: include/pybind11 * Undo incorrect change. * Revert "Disable deadsnakes jobs entirely." This reverts commit bbcd0087b2d52e0130f96792dd5dd03704280a57. * WITH_THREAD cleanup pass: tests/ * Change Python version guard in pybind11/__init__.py: pybind11 does not support Python < 3.7. * Misc cleanup pass * chore: use future imports Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> * Update tests/test_numpy_array.py * Update test_numpy_array.py --------- Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> Co-authored-by: Henry Schreiner <henryschreineriii@gmail.com> | 2 年前 |
| Final manual curation in preparation for global `clang-format`ing (#3712) * Manual line breaks to pre-empt undesired `clang-format`ing. Informed by work under https://github.com/pybind/pybind11/pull/3683: https://github.com/pybind/pybind11/commit/60b7eb410fefe2b23aeb6906f2a9184e91b11a15 https://github.com/pybind/pybind11/commit/59572e65598b4b9f2c9ae0b8a0e5fcb6d65c7f92 * Manual curation of clang-format diffs involving source code comments. Very labor-intensive and dull. * Pulling .clang-format change from @henryiii's https://github.com/pybind/pybind11/pull/3683/commits/9057962d40ca520b9d26abbe0ff125796e2323dd * Adding commonly used .clang-format `CommentPragmas:` * Ensure short lambdas are allowed Co-authored-by: Aaron Gokaslan <skylion.aaron@gmail.com> | 4 年前 |
| Add more readability tidy rules (#5924) * Apply clang-tidy readibility fixes Signed-off-by: Yuanyuan Chen <cyyever@outlook.com> * Add checks Signed-off-by: Yuanyuan Chen <cyyever@outlook.com> * More fixes Signed-off-by: cyy <cyyever@outlook.com> --------- Signed-off-by: Yuanyuan Chen <cyyever@outlook.com> Signed-off-by: cyy <cyyever@outlook.com> | 6 个月前 |
| format: apply cmake-format | 5 年前 |
| type_caster_generic: add set_foreign_holder method for subclasses to implement (#5862) * type_caster_generic: add set_foreign_holder method for subclasses to implement * style: pre-commit fixes * Rename try_shared_from_this -> set_via_shared_from_this to avoid confusion against try_get_shared_from_this * Add comment explaining the limits of the test * CI * style: pre-commit fixes * Fixes from code review * style: pre-commit fixes --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> | 8 个月前 |
| style: pylint (#3720) * fix: add pylint and fix issue * chore: add pylint to pre-commit * fix: local variable warning surfaced mistake in intree | 4 年前 |
| chore: add agent files (#6082) * chore: add agent files Assisted-by: ClaudeCode:claude-opus-4.8 Signed-off-by: Henry Schreiner <henryfs@princeton.edu> * fix: better AGENTS.md Signed-off-by: Henry Schreiner <henryfs@princeton.edu> * Apply suggestions from code review Co-authored-by: Ralf W. Grosse-Kunstleve <rwgkio@gmail.com> Co-authored-by: Henry Schreiner <HenrySchreinerIII@gmail.com> --------- Signed-off-by: Henry Schreiner <henryfs@princeton.edu> Co-authored-by: Ralf W. Grosse-Kunstleve <rwgkio@gmail.com> | 15 天前 |
| chore(deps): update pre-commit hooks (#6099) updates: - [github.com/astral-sh/ruff-pre-commit: v0.15.15 → v0.15.20](https://github.com/astral-sh/ruff-pre-commit/compare/v0.15.15...v0.15.20) - [github.com/adhtruong/mirrors-typos: v1.47.0 → v1.48.0](https://github.com/adhtruong/mirrors-typos/compare/v1.47.0...v1.48.0) - [github.com/PyCQA/pylint: v4.0.5 → v4.0.6](https://github.com/PyCQA/pylint/compare/v4.0.5...v4.0.6) - [github.com/python-jsonschema/check-jsonschema: 0.37.2 → 0.37.4](https://github.com/python-jsonschema/check-jsonschema/compare/0.37.2...0.37.4) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> | 23 小时前 |
| [ci skip] Adopt nanobind config. (#4792) | 2 年前 |
| chore: add agent files (#6082) * chore: add agent files Assisted-by: ClaudeCode:claude-opus-4.8 Signed-off-by: Henry Schreiner <henryfs@princeton.edu> * fix: better AGENTS.md Signed-off-by: Henry Schreiner <henryfs@princeton.edu> * Apply suggestions from code review Co-authored-by: Ralf W. Grosse-Kunstleve <rwgkio@gmail.com> Co-authored-by: Henry Schreiner <HenrySchreinerIII@gmail.com> --------- Signed-off-by: Henry Schreiner <henryfs@princeton.edu> Co-authored-by: Ralf W. Grosse-Kunstleve <rwgkio@gmail.com> | 15 天前 |
| Improve performance of enum_ operators by going back to specific implementation (#5887) * Improve performance of enum_ operators by going back to specific implementation test_enum needs a patch because ops are now overloaded and this affects their docstrings. * outline call_impl to save on code size This does cause more move constructions, as shown by the needed update to test_copy_move. Up to reviewers whether they want more code size or more moves. * add function_ref.h to PYBIND11_HEADERS. * Update test_copy_move tests with C++17 passing values just so we can see mostly-not-red tests * Remove stray TODO * fix clang-tidy * fix clang-tidy again. add function_ref.h to test_files.py * Add static assertion for function_ref lifetime safety in call_impl Add a static_assert to document and enforce that function_ref is trivially copyable, ensuring safe pass-by-value usage. This also documents the lifetime safety guarantees: function_ref is created from cap->f which lives in the capture object, and is only used synchronously within call_impl without being stored beyond its scope. * Add #undef cleanup for enum operator macros Undefine all enum operator macros after their last use to prevent macro pollution and follow the existing code pattern. This matches the cleanup pattern used for the previous enum operator macros. * Rename PYBIND11_THROW to PYBIND11_ENUM_OP_THROW_TYPE_ERROR Rename the macro to be more specific and avoid potential clashes with public macros. The new name clearly indicates it's scoped to enum operations and describes its purpose (throwing a type error). * Clarify comments in function_ref.h Replace vague comments about 'extensions to <functional>' and 'functions' with a clearer description that this is a header-only class template similar to std::function but with non-owning semantics. This makes it clear that it's template-only and requires no additional library linking. --------- Co-authored-by: Ralf W. Grosse-Kunstleve <rgrossekunst@nvidia.com> | 4 个月前 |
| fix: expose required symbol using clang (#5700) * test: Added test case for visibility of common symbols across shared libraries * style: pre-commit fixes * tests: cmake target name fix * tests: Added visibility test to ci * tests: set the default visibility to hidden * prototype/proof-of-concept fix: PYBIND11_EXPORT_GUARDED_DELETE * Fix silly oversight: actually use PYBIND11_EXPORT_GUARDED_DELETE * Update struct_smart_holder.h * style: pre-commit fixes * Update include/pybind11/detail/struct_smart_holder.h * Update struct_smart_holder.h * ci: fix addition to reusable-standard.yml * Update CMakeLists.txt * refactor: rename tests to test_cross_module_rtti Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> --------- Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Henry Schreiner <HenrySchreinerIII@gmail.com> Co-authored-by: Ralf W. Grosse-Kunstleve <rgrossekunst@nvidia.com> | 1 年前 |
| docs: contrib/issue templates (#2377) * docs: move helpers to .github where allowed * docs: more guidelines in CONTRIBUTING * chore: update issue templates * fix: review from @bstaletic * refactor: a few points from @rwgk * docs: more touchup, review changes | 5 年前 |
| Point main README.rst to CI for supported platforms and compilers (#5910) * [skip ci] Point main README.rst to CI for supported platforms and compilers - **Replace** the hard-coded “Supported compilers” and “Supported platforms” lists in `README.rst`. - **Point** readers to the current GitHub Actions matrix as the source of truth for tested platforms, compilers, and Python/C++ versions. - **Clarify** that the matrix evolves over time and that configurations users care about can be kept working via contributions. - **Avoid stale documentation**: Enumerating specific compiler and platform versions in the README is both burdensome and error-prone, and tends to drift out of sync with reality. - **Align “supported” with “tested”**: In practice, the CI configuration is the only place where we can say with confidence which combinations are exercised. Nearby versions (e.g., adjacent compiler minor releases) will often work, but we cannot test every variant. - **Reflect actual maintenance capacity**: pybind11 is maintained by a small, volunteer-based community, so support is necessarily best-effort. Pointing to CI and inviting contributions better matches how support is provided in practice. - **No behavior change**: This PR updates documentation only. - **Living source of truth**: As CI jobs are added or removed, the linked Actions view will automatically reflect the set of configurations we actively test. Keeping a configuration in CI is the best way to keep it “supported”. * [skip ci] Slight rewording: point out GitHub's limits on concurrent jobs under the free tier (rather than free minutes). | 7 个月前 |
| Create s Security Policy (#4671) * Create SECURITY.md * Update test_files.py to include SECURITY.md file * Update MANIFEST.in to include SECURITY.md file | 3 年前 |
| chore: use scikit-build-core for the build (#5598) * chore: use scikit-build-core for the build Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> * fix: support tests job Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> * refactor: use tomlkit instead of manual parsing Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> * tests: add tests for output Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> * chore: remove more unused files Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> * fix: restore global pin Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> * fix: test and fix pinning Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> --------- Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> | 1 年前 |
| chore(deps): update pre-commit hooks (#6029) * chore(deps): update pre-commit hooks updates: - [github.com/pre-commit/mirrors-clang-format: v22.1.0 → v22.1.2](https://github.com/pre-commit/mirrors-clang-format/compare/v22.1.0...v22.1.2) - [github.com/astral-sh/ruff-pre-commit: v0.15.4 → v0.15.9](https://github.com/astral-sh/ruff-pre-commit/compare/v0.15.4...v0.15.9) - [github.com/pre-commit/mirrors-mypy: v1.19.1 → v1.20.0](https://github.com/pre-commit/mirrors-mypy/compare/v1.19.1...v1.20.0) - [github.com/codespell-project/codespell: v2.4.1 → v2.4.2](https://github.com/codespell-project/codespell/compare/v2.4.1...v2.4.2) - [github.com/adhtruong/mirrors-typos: v1.44.0 → v1.45.0](https://github.com/adhtruong/mirrors-typos/compare/v1.44.0...v1.45.0) - [github.com/python-jsonschema/check-jsonschema: 0.37.0 → 0.37.1](https://github.com/python-jsonschema/check-jsonschema/compare/0.37.0...0.37.1) * fix: allow NumPy writeable spelling in typos NumPy uses `writeable` in public flags and API names, so typos should treat that spelling as intentional instead of blocking pre-commit runs. Made-with: Cursor --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Ralf W. Grosse-Kunstleve <rgrossekunst@nvidia.com> | 2 个月前 |