Commit Graph

3078 Commits

Author SHA1 Message Date
Henry Schreiner 3fd1520de2
docs: changelog for next version (#4413)
* docs: changelog for next version

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

* docs: address feedback

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

Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
2022-12-20 14:47:41 -05:00
Ethan Steinberg ee4b9f5d7b
Fix ODR violations in our Eigen Tensor tests (#4412)
* First

* Fix centos 7 again :(

* Fix minor nits
2022-12-20 05:34:00 -08:00
Henry Schreiner a97c4d220e
fix(cmake): support Windows ARM cross-compilation (#4406)
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>

Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
2022-12-19 14:36:39 -05:00
Martin Blanchard 09db6445d8
IPO/LTO support for ICX (IntelLLVM) compiler (#4402)
* IPO/LTO support for ICX (IntelLLVM) compiler

https://github.com/pybind/pybind11/issues/4080

* style: pre-commit fixes

* Add WARNING/HELP WANTED comment.

Co-authored-by: Martin Blanchard <martin.blanchard@siemens.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Ralf W. Grosse-Kunstleve <rwgk@google.com>
2022-12-15 21:10:46 -08:00
Ralf W. Grosse-Kunstleve ece1206b8a
ci: set `env: VERBOSE: 1` (#4405)
* Revert "Systematically add `-DCMAKE_VERBOSE_MAKEFILE=ON` to obtain full command lines related to `-Wodr` (#4398)"

This reverts commit ff42f5254a.

* Set `env: VERBOSE: 1` as suggested by @henryiii

* Set `env: VERBOSE: 1` also in all other .yml files using cmake
2022-12-15 16:19:13 -05:00
Martin Blanchard 89c3561d9a
Fix multi-context new Python linking mode (#4401)
Allow CMake find_package() from multiple directories.

https://github.com/pybind/pybind11/issues/4400

Co-authored-by: Martin Blanchard <martin.blanchard@siemens.com>
2022-12-14 14:03:37 -05:00
Ralf W. Grosse-Kunstleve 2120dde73e Tracking ci.yml changes from master. 2022-12-13 11:08:40 -08:00
Ralf W. Grosse-Kunstleve 27eeb275e9 Merge branch 'master' into sh_merge_master 2022-12-13 11:06:14 -08:00
Ralf W. Grosse-Kunstleve ff42f5254a
Systematically add `-DCMAKE_VERBOSE_MAKEFILE=ON` to obtain full command lines related to `-Wodr` (#4398) 2022-12-13 11:04:05 -08:00
Ralf W. Grosse-Kunstleve ee10afa1da Merge branch 'master' into smart_holder 2022-12-12 19:57:13 -08:00
Ralf W. Grosse-Kunstleve 4766065e5c
[smart_holder] test_class_sh_mi_thunks (started from PR #4374) (#4380)
* Content of PR #4374 applied on top of smart_holder branch.

* More tests, with USE_SH switch. [ci skip]

* Use `std::dynamic_pointer_cast<Base0>` [ci skip]

* All tests pass when using `m.make_derived_as_base0_raw_ptr()`, with `USE_SH` defined or not defined. [ci skip]

* WIP

* Debug LOOOK & one-line bug fix:

```diff
-        auto smhldr = pybindit::memory::smart_holder::from_shared_ptr(src);
+        auto smhldr = pybindit::memory::smart_holder::from_shared_ptr(std::shared_ptr<void>(src, const_cast<void *>(st.first)));
```

* Remove all print LOOOK and clang-format the fix.

* Resolve clang-tidy errors.

* Systematic test matrix.

* Bug fix in `smart_holder_type_caster<std::unique_ptr<T, D>>::cast()`

* Rename: test_mi_debug -> test_class_sh_mi_thunks

* Add `test_ptrdiff_derived_base0()`

* Miscellaneous polishing (naming, comments). No functional changes.

* Improve test_class_sh_mi_thunks.py implementation. No change in test coverage.

* Resolve clang-tidy error.
2022-12-12 19:55:16 -08:00
Henry Schreiner 9727dcdae5
chore: future safe bugbear opinionated warnings (#4393)
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>

Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
2022-12-09 23:18:36 -05:00
Ralf W. Grosse-Kunstleve 53b80b4312 Merge branch 'master' into smart_holder 2022-12-09 10:55:26 -08:00
Ralf W. Grosse-Kunstleve 663b86c26c
Add flake8 `B905` to `extend-ignore` in setup.cfg (#4391)
* Add flake8 `--ignore=B905,N818,W503`

* Add B905 to `extend-ignore` in setup.cfg (thanks @Skylion007), leave .pre-commit-config.yaml as-is on master.
2022-12-09 10:53:03 -08:00
Ralf W. Grosse-Kunstleve 1ebac536f3 clang-format automatic changes (due to clang-format update on master) 2022-12-08 23:25:36 -08:00
Ralf W. Grosse-Kunstleve 0be972a9c1 Merge branch 'master' into sh_merge_master 2022-12-08 23:19:31 -08:00
aimir 9db988013c
Correct class names for KeysView, ValuesView and ItemsView in bind_map (#4353)
* Create templated abstract classes KeysView, ValuesView and ItemsView, and implement them on-the-fly when wrapping any specific map type

* We don't want to wrap different ValuesView objects for double values and const double, for example, as both wrappers will be named ValuesView[float]

* Fallback to C++ names if key or values types are not wrapped

* Added a test for .keys(), .values() and .items() returning the same types for similarly-typed maps

* Fixed wrong use of auto in a declarator list: the two descriptions might have different types

* Fixes for clang-tidy issues: explicit single-argument constructor, using the 'override' keyword when overriding functions

* Bugfix for old versions of clang++, which seem to have trouble with the struct being defined inside a module, which was also needlessly ugly anyway

* Bugfix for clang++, which doesn't have some of the names in runtime uness they are specified to be static

* A fix for clang-tidy performance-inefficient-string-concatenation issues - I personally think this looks uglier, but it's probably worth it for clang-tidy to be happy

* Possible fix for clang++ linking issues - make the descriptions static constexpr to make sure they are known before linking

* Correct names for previously-wrapped types as keys/values of maps

* Bugfix - typo in type info names which caused things to segfault

* Apply suggestions from code review

Co-authored-by: Aaron Gokaslan <skylion.aaron@gmail.com>

* Use detail::remove_cvref_t instead of doing remove_cv and remove_reference separately

* Avoid names with double underscore, as they are reserved

* Improved testing for KeysView, ValuesView and ItemsView: check type names + stricter asserts

* Moved description logic to helper function in type_caster_base.h

* style: pre-commit fixes

* Fix a clang-tidy issue: do not use 'else' after 'return'

* Apply suggestion by @Skylion007, with additional trivial simplification.

Co-authored-by: Amir <aimir@local>
Co-authored-by: aimir <aimir@localhost>
Co-authored-by: Aaron Gokaslan <skylion.aaron@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Ralf W. Grosse-Kunstleve <rwgk@google.com>
2022-12-08 23:15:11 -08:00
Frank 00126859a5
Add option for enable/disable enum members in docstring. (#2768)
* Add option for enable/disable enum members in docstring

* Add tests for disable enum members docstring option

* Add docstring options to documentation

* style: pre-commit fixes

* Fix typos in documentation

* Improve documentation wording

* Apply suggestions by @Skylion007

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Ralf W. Grosse-Kunstleve <rwgk@google.com>
2022-12-08 23:10:10 -08:00
Ralf W. Grosse-Kunstleve 65374c8e62
`pybind11::handle` `inc_ref()` & `dec_ref()` `PyGILState_Check()` **excluding** `nullptr` (#4246)
* pybind11/pytypes.h `inc_ref()`, `dec_ref()` `PyGILState_Check()` **excluding** `nullptr`

Guarded by `PYBIND11_ASSERT_GIL_HELD_INCREF_DECREF`

* Disable `PYBIND11_ASSERT_GIL_HELD_INCREF_DECREF` for PyPy under Windows.

* Add reference to PR #4268 (PyPy Windows)
2022-12-08 22:06:51 -08:00
dependabot[bot] 65cc9d2a29
chore(deps): bump pypa/gh-action-pypi-publish from 1.6.1 to 1.6.4 (#4389)
Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) from 1.6.1 to 1.6.4.
- [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases)
- [Commits](https://github.com/pypa/gh-action-pypi-publish/compare/v1.6.1...v1.6.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>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-12-06 23:36:11 -05:00
pre-commit-ci[bot] 4768a6f8f5
chore(deps): update pre-commit hooks (#4386)
* chore(deps): update pre-commit hooks

updates:
- [github.com/pre-commit/pre-commit-hooks: v4.3.0 → v4.4.0](https://github.com/pre-commit/pre-commit-hooks/compare/v4.3.0...v4.4.0)
- [github.com/asottile/pyupgrade: v3.2.0 → v3.3.0](https://github.com/asottile/pyupgrade/compare/v3.2.0...v3.3.0)
- [github.com/hadialqattan/pycln: v2.1.1 → v2.1.2](https://github.com/hadialqattan/pycln/compare/v2.1.1...v2.1.2)
- [github.com/PyCQA/flake8: 5.0.4 → 6.0.0](https://github.com/PyCQA/flake8/compare/5.0.4...6.0.0)
- [github.com/PyCQA/pylint: v2.15.5 → v2.15.8](https://github.com/PyCQA/pylint/compare/v2.15.5...v2.15.8)
- [github.com/pre-commit/mirrors-mypy: v0.982 → v0.991](https://github.com/pre-commit/mirrors-mypy/compare/v0.982...v0.991)
- [github.com/mgedmin/check-manifest: 0.48 → 0.49](https://github.com/mgedmin/check-manifest/compare/0.48...0.49)
- [github.com/pre-commit/mirrors-clang-format: v14.0.6 → v15.0.4](https://github.com/pre-commit/mirrors-clang-format/compare/v14.0.6...v15.0.4)

* style: pre-commit fixes

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2022-12-06 10:10:48 -08:00
luzpaz a672de7cc8
Fix source comment typo (#4388) 2022-12-06 12:54:15 -05:00
Ralf W. Grosse-Kunstleve 302bd31727 Tracking ci.yml changes from master. 2022-12-05 14:36:30 -08:00
Ralf W. Grosse-Kunstleve 3036510bb7 Merge branch 'master' into sh_merge_master 2022-12-05 14:35:42 -08:00
Xiaofei Wang c1f14f0511
[smart_holder] Auto select return value policy for clif_automatic (#4381)
* Auto select return value policy for clif_automatic

* Try fixing test failures

* Add more tests.

* remove comments

* Fix test failures

* Fix test failures

* Fix test failure for windows platform

* Fix clangtidy
2022-12-05 14:32:54 -08:00
dependabot[bot] a6e75e4d8a
chore(deps): bump pypa/gh-action-pypi-publish from 1.5.2 to 1.6.1 (#4384)
Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) from 1.5.2 to 1.6.1.
- [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases)
- [Commits](https://github.com/pypa/gh-action-pypi-publish/compare/v1.5.2...v1.6.1)

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

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-12-05 01:03:05 -08:00
dependabot[bot] 6a1023e3e9
chore(deps): bump deadsnakes/action from 2.1.1 to 3.0.0 (#4383)
Bumps [deadsnakes/action](https://github.com/deadsnakes/action) from 2.1.1 to 3.0.0.
- [Release notes](https://github.com/deadsnakes/action/releases)
- [Commits](https://github.com/deadsnakes/action/compare/v2.1.1...v3.0.0)

---
updated-dependencies:
- dependency-name: deadsnakes/action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-12-05 01:01:45 -08:00
Ralf W. Grosse-Kunstleve 5b55f8fe82
Replace `ubuntu-latest` with `ubuntu-22.04` (#4382)
* Replace 🐍 3.6 • ubuntu-latest • x64 -DPYBIND11_FINDPYTHON=ON -DCMAKE_CXX_FLAGS="-D_=1" with 3.9

* Revert "Replace 🐍 3.6 • ubuntu-latest • x64 -DPYBIND11_FINDPYTHON=ON -DCMAKE_CXX_FLAGS="-D_=1" with 3.9"

This reverts commit 3ec984e1ed.

* Systematically change all active ubuntu-latest to ubuntu-20.04, except in upstream.yml

* Revert "Systematically change all active ubuntu-latest to ubuntu-20.04, except in upstream.yml"

This reverts commit cdfd99526a.

* Change only some ubuntu-latest to ubuntu-20.04
2022-12-04 19:39:25 -08:00
Ralf W. Grosse-Kunstleve 33fb7a6bd8 Show ODR VIOLATION DETECTED message only if `PYBIND11_DETAIL_TYPE_CASTER_ODR_GUARD_IMPL_DEBUG` is defined, to not clutter the test_gil_scoped.py output with many of these messages when `multiprocessing.set_start_method("forkserver")` is used. 2022-12-02 05:41:49 -08:00
Ralf W. Grosse-Kunstleve 13eb5eafd5 Changes related to PR #4285 (new style of warning suppression based on push/pop) 2022-12-02 05:30:03 -08:00
Ralf W. Grosse-Kunstleve 8f54f4f48c Tracking ci.yml changes from master. 2022-12-02 05:30:03 -08:00
Ralf W. Grosse-Kunstleve 10d4aa7476 Merge branch 'master' into sh_merge_master_3 2022-12-02 05:28:58 -08:00
Aaron Gokaslan e133c33d5c
chore: Convert direct multiprocessing.set_start_method("forkserver") call to a pytest fixture. (#4377)
* chore: convert multiprocessing set_spawn to fixture in pytest

* Switch to early return
2022-12-01 15:15:47 -05:00
Ralf W. Grosse-Kunstleve 358ba459d2
Fix test added with PR #4330 (#4372) 2022-12-01 09:25:30 -08:00
dependabot[bot] b14d58b615
chore(deps): bump pypa/gh-action-pypi-publish from 1.5.1 to 1.5.2 (#4370)
Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) from 1.5.1 to 1.5.2.
- [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases)
- [Commits](https://github.com/pypa/gh-action-pypi-publish/compare/v1.5.1...v1.5.2)

---
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>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-11-30 23:30:36 -08:00
Arman 8869984926
scoped_interpreter. overloaded constructor: PyConfig param (#4330)
* scoped_interpreter overloaded ctor: PyConfig param

* style: pre-commit fixes

* refact: some logics extracted into funcs (precheck_interpreter, _initialize_interpreter); config_guard

* style: pre-commit fixes

* refact: scoped_config, some funcs hidden in detail ns

* refact: macro PYBIND11_PYCONFIG_SUPPORT_PY_VERSION + undef

* feat: PYBIND11_PYCONFIG_SUPPORT_PY_VERSION set to 3.8

* tests: Custom PyConfig

* ci: python 3.6 -> 3.8

* ci: reverted py 38 back  to 36; refact: initialize_interpreter overloads

* style: pre-commit fixes

* fix: readability-implicit-bool-conversion

* refact: each initialize_interpreter overloads in pybind11 ns

* Move `initialize_interpreter_pre_pyconfig()` into the `detail` namespace.

Move the `PYBIND11_PYCONFIG_SUPPORT_PY_VERSION_HEX` define down to where it is used for the first time, and check if it is defined already, so that it is possible to customize from the compilation command line, just in case there is some unforeseen issue for Python 3.8, 3.9, 3.10.

* tests: Add program dir to path, Custom PyConfig with argv

* refact: clang-formatted

* tests: Add-program-dir-to-path covers both scoped_interpreter overloads

* tests: Add-program-dir-to-path fixed

* tests: Add-program-dir-to-path py_version dependant validation

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Ralf W. Grosse-Kunstleve <rwgk@google.com>
2022-11-30 21:17:59 -08:00
Ralf W. Grosse-Kunstleve 8720cf94d6
cast.h return_value_policy_override _clif_automatic (#4364) 2022-11-28 11:10:37 -08:00
Ralf W. Grosse-Kunstleve 341bc8ac99
Add `PYBIND11_HAS_RETURN_VALUE_POLICY_...` defines. (#4352) 2022-11-28 11:10:03 -08:00
Ethan Steinberg 06003e82b3
Introduce a new style of warning suppression based on push/pop (#4285)
* Introduce a new warning suppression system

* Switch to better name

* Nits
2022-11-28 07:39:38 -08:00
Xuehai Pan 9907bedce5
fix(.github): fix bug-report issue template (#4363) 2022-11-25 15:15:54 -08:00
Ralf W. Grosse-Kunstleve 9c18a74e37
Use `multiprocessing` `start_method` `"forkserver"` (#4306)
* Use `multiprocessing` `start_method` `"forkserver"`

Alternative to PR #4305

* Add link to comment under PR #4105

* Unconditionally `pytest.skip("DEADLOCK")` for PyPy Windows

* Remove `SKIP_IF_DEADLOCK` entirely, for simplicity. Hopefully this PR will resolve the deadlocks for good.

* Add "In a nutshell" comment, in response to request by @EricCousineau-TRI
2022-11-22 17:17:02 -08:00
Ralf W. Grosse-Kunstleve 48949222c6
Use `PyEval_InitThreads()` as intended (#4350)
* Use `PyEval_InitThreads()` as intended (actually matters only for Python 3.6).

* Add `if defined(WITH_THREAD)` condition.

https://docs.python.org/3.6/c-api/init.html#c.PyEval_InitThreads

> This function is not available when thread support is disabled at compile time.

* Fix oversight pointed out by @EricCousineau-TRI: Remove condition that is always false.
2022-11-22 15:14:49 -08:00
Ralf W. Grosse-Kunstleve d095a9bcff Tracking ci.yml changes from master. 2022-11-18 10:08:11 -08:00
Ralf W. Grosse-Kunstleve 645bcd47d0 Add macos_brew_install_llvm to ci.yml (#4326)
* Add macos_brew_install_llvm to ci.yml

Added block transferred from PR #4324

* `test_cross_module_exception_translator` xfail 'Homebrew Clang'

* Add `pip install numpy scipy` (tested already under PR #4324).
2022-11-18 10:08:11 -08:00
gitartpiano 4625adcbe5 fix pybind11Tools.cmake typo causing Unknown arguments (#4327)
* fix pybind11Tools.cmake typo causing Unknown arguments

CMake Error at pybind11/tools/pybind11Tools.cmake:217 (if):
  if given arguments:
    "NOT" "MSVC" "AND" "NOT" "TEST" "MATCHES" "DEBUG|RELWITHDEBINFO"
  Unknown arguments specified
https://github.com/pybind/pybind11/issues/4325

* Apply the same fix in tools/pybind11NewTools.cmake

Co-authored-by: Ralf W. Grosse-Kunstleve <rwgk@google.com>
2022-11-18 10:08:11 -08:00
Ralf W. Grosse-Kunstleve e76293d699 Add windows_clang to ci.yml (#4323)
* Add windows_clang to ci.yml (previously tested under PRs #4321, #4319)

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

Already tested under PR #4321
2022-11-18 10:08:11 -08:00
Ethan Steinberg 3cb7c254e6 Fix functional.h bug + introduce test to verify that it is fixed (#4254)
* Illustrate bug in functional.h

* style: pre-commit fixes

* Make functional casting more robust / add workaround

* Make function_record* casting even more robust

* See if this fixes PyPy issue

* It still fails on PyPy sadly

* Do not make new CTOR just yet

* Fix test

* Add name to ensure correctness

* style: pre-commit fixes

* Clean up tests + remove ifdef guards

* Add comments

* Improve comments, error handling, and safety

* Fix compile error

* Fix magic logic

* Extract helper function

* Fix func signature

* move to local internals

* style: pre-commit fixes

* Switch to simpler design

* style: pre-commit fixes

* Move to function_record

* style: pre-commit fixes

* Switch to internals, update tests and docs

* Fix lint

* Oops, forgot to resolve last comment

* Fix typo

* Update in response to comments

* Implement suggestion to improve test

* Update comment

* Simple fixes

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Aaron Gokaslan <aaronGokaslan@gmail.com>
2022-11-18 10:08:11 -08:00
Aaron Gokaslan 5b092eddde chore: sync blacken-docs hook with black (#4304) 2022-11-18 10:08:11 -08:00
pre-commit-ci[bot] 9bd8f656d3 chore(deps): update pre-commit hooks (#4302)
updates:
- [github.com/asottile/pyupgrade: v2.38.2 → v3.2.0](https://github.com/asottile/pyupgrade/compare/v2.38.2...v3.2.0)
- [github.com/psf/black: 22.8.0 → 22.10.0](https://github.com/psf/black/compare/22.8.0...22.10.0)
- [github.com/PyCQA/pylint: v2.15.3 → v2.15.5](https://github.com/PyCQA/pylint/compare/v2.15.3...v2.15.5)
- [github.com/pre-commit/mirrors-mypy: v0.981 → v0.982](https://github.com/pre-commit/mirrors-mypy/compare/v0.981...v0.982)
- [github.com/codespell-project/codespell: v2.2.1 → v2.2.2](https://github.com/codespell-project/codespell/compare/v2.2.1...v2.2.2)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2022-11-18 10:08:11 -08:00
Henry Schreiner 717aa08784 docs: prepare for 2.10.1 release (#4279)
* docs: prepare for 2.10.1 release

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

* Update changelog.rst

* docs: update changelog with final list of PRs

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

* Update docs/changelog.rst

* chore: one more changelog bump

Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
2022-11-18 10:08:11 -08:00