Commit Graph

19 Commits

Author SHA1 Message Date
Henry Schreiner
7c3a031766
chore: bump clang-tidy to 13 (#3997)
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
2022-07-13 09:06:32 -05:00
Michał Górny
96b943be1d
tests: update catch to 2.13.5 to fix glibc 2.34 failures (#3679)
* Download catch for MinGw

* Fix rest of MinGW

* fix: update catch to 2.13.5 to fix glibc 2.34 failures

Update the downloaded Catch version to 2.13.5, in order to fix build
failure on glibc 2.34:

```
In file included from /usr/include/signal.h:328,
                 from /tmp/pybind11/.nox/tests-3-9/tmp/tests/catch/catch.hpp:8030,
                 from /tmp/pybind11/tests/test_embed/catch.cpp:13:
/tmp/pybind11/.nox/tests-3-9/tmp/tests/catch/catch.hpp:10818:58: error: call to non-‘constexpr’ function ‘long int sysconf(int)’
10818 |     static constexpr std::size_t sigStackSize = 32768 >= MINSIGSTKSZ ? 32768 : MINSIGSTKSZ;
      |                                                          ^~~~~~~~~~~
In file included from /usr/include/python3.9/Python.h:36,
                 from /tmp/pybind11/include/pybind11/detail/common.h:215,
                 from /tmp/pybind11/include/pybind11/pytypes.h:12,
                 from /tmp/pybind11/include/pybind11/cast.h:13,
                 from /tmp/pybind11/include/pybind11/attr.h:13,
                 from /tmp/pybind11/include/pybind11/pybind11.h:13,
                 from /tmp/pybind11/include/pybind11/embed.h:12,
                 from /tmp/pybind11/tests/test_embed/catch.cpp:4:
/usr/include/unistd.h:640:17: note: ‘long int sysconf(int)’ declared here
  640 | extern long int sysconf (int __name) __THROW;
      |                 ^~~~~~~
In file included from /tmp/pybind11/tests/test_embed/catch.cpp:13:
/tmp/pybind11/.nox/tests-3-9/tmp/tests/catch/catch.hpp:10877:45: error: size of array ‘altStackMem’ is not an integral constant-expression
10877 |     char FatalConditionHandler::altStackMem[sigStackSize] = {};
      |                                             ^~~~~~~~~~~~
```

The newest Catch version cannot be used yet because of regression:
https://github.com/catchorg/Catch2/pull/2364

* fix: add option for _ check, only define on pybind11

* Revert "fix: add option for _ check, only define on pybind11"

This reverts commit 86817db488.

* fix: only undef _ for catch cpp creation.

Co-authored-by: Aaron Gokaslan <skylion.aaron@gmail.com>
Co-authored-by: Henry Schreiner <henryschreineriii@gmail.com>
2022-02-05 23:53:02 -05:00
Trigve
afdc09deda
[master] Wrong caching of overrides (#3465)
* override: Fix wrong caching of the overrides

There was a problem when the python type, which was stored in override
cache for C++ functions, was destroyed and  the record wasn't removed from the
override cache. Therefor, dangling pointer was stored there. Then when the
memory was reused and new type was allocated at the given address and the
method with the same name (as previously stored in the cache) was actually
overridden in python, it would wrongly find it in the override cache for C++
functions and therefor override from python wouldn't be called.
The fix is to erase the type from the override cache when the type is destroyed.

* test: Pass by const ref instead of by value (clang-tidy)

* test: Rename classes and move to different files

Rename the classes and files so they're no too generic. Also, better place to
test the stuff is in test_virtual_functions.cpp/.py as we're basically testing
the virtual functions/trampolines.

* Add TODO for erasure code

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2021-11-15 13:36:41 -05:00
Henry Schreiner
c14b193308
chore: increase CMake upper limit (#3124) 2021-07-28 18:04:14 -07:00
Henry Schreiner
eb83feefff
style: avoid using unintialized variables (#2806)
* style: avoid using unintialized variables

Tested with cmake --warn-unintialized -S . -B build

* refactor: use function for possibly uninit vars
2021-01-19 18:48:22 -05:00
Robert Haschke
b72cebeb22
style: clang-tidy: modernize-use-using (#2645)
* style: clang-tidy: modernize-use-using

* style: more clang-tidy checking

Co-authored-by: Henry Schreiner <henryschreineriii@gmail.com>
2020-11-09 10:10:19 -08:00
Henry Schreiner
04fdc44f50
tests: avoid putting build products into source directory (#2353)
* tests: keep source dir clean

* ci: make first build inplace

* ci: drop dev setting (wasn't doing anything)

* tests: warn if source directory is dirty
2020-08-19 13:11:57 -04:00
Henry Schreiner
1729aae96f
feat: new FindPython support (#2370)
* feat: FindPython support

* refactor: rename to PYBIND11_FINDPYTHON

* docs: Caps fixes

* feat: NOPYTHON mode

* test: check simple call

* docs: add changelog/upgrade guide

* feat: Support Python3 and Python2

* refactor: Use targets in tests

* fix: support CMake 3.4+

* feat: classic search also finds virtual environments

* docs: some updates from @wjakob's review

* fix: wrong name for QUIET mode variable, reported by @skoslowski

* refactor: cleaner output messaging

* fix: support debug Python's in FindPython mode too

* fixup! refactor: cleaner output messaging

* fix: missing pybind11_FOUND and pybind11_INCLUDE_DIR restored to subdir mode

* fix: nicer reporting of Python / PyPy

* fix: out-of-order variable fix

* docs: minor last-minute cleanup
2020-08-19 12:26:26 -04:00
Henry Schreiner
f7abac6689
fix: boost's include dir was listed first (#2384) 2020-08-12 09:33:08 -04:00
Henry Schreiner
94db5c5ed1 format: apply cmake-format 2020-07-30 20:27:55 -04:00
Henry Schreiner
6ec1775fff feat: drop CMake 3.6 and below, modernize CMake
fix: include PYTHON_IS_DEBUG
2020-07-30 20:27:55 -04:00
Henry Schreiner
1b880dfd5a ci: download EIGEN 2020-07-27 22:12:19 -04:00
Henry Schreiner
5927c5819f chore: update Catch 2020-07-26 09:25:27 -04:00
Henry Schreiner
1f53c373e4 fix: C++17 mode on Clang may error 2020-07-26 09:25:27 -04:00
Henry Schreiner
a59c6de821 test: allow MSVC/Xcode to run the embed test 2020-07-23 17:42:53 -04:00
Jason Rhinelander
326deef2ae
Fix segfault when reloading interpreter with external modules (#1092)
* Fix segfault when reloading interpreter with external modules

When embedding the interpreter and loading external modules in that
embedded interpreter, the external module correctly shares its
internals_ptr with the one in the embedded interpreter.  When the
interpreter is shut down, however, only the `internals_ptr` local to
the embedded code is actually reset to nullptr: the external module
remains set.

The result is that loading an external pybind11 module, letting the
interpreter go through a finalize/initialize, then attempting to use
something in the external module fails because this external module is
still trying to use the old (destroyed) internals.  This causes
undefined behaviour (typically a segfault).

This commit fixes it by adding a level of indirection in the internals
path, converting the local internals variable to `internals **` instead
of `internals *`.  With this change, we can detect a stale internals
pointer and reload the internals pointer (either from a capsule or by
creating a new internals instance).

(No issue number: this was reported on gitter by @henryiii and @aoloe).
2018-01-11 19:46:10 -04:00
Jason Rhinelander
835fa9bcc6 Miscellaneous travis-ci updates/fixes
- For the debian/buster docker build (GCC 7/C++17) install and use the
  system `catch` package; this also renames "COMPILER_PACKAGES" to
  "EXTRA_PACKAGES" since it now contains a non-compiler package.

- Add a status message indicating the catch version being used for
  compiling the embedded tests

- Simplify some bash code by using VAR+=" foo" to append (rather than
  VAR="${VAR} foo"

- Fix CMAKE_INCLUDE_PATH appending: it was prepending the ':' but not
  the existing $CMAKE_INCLUDE_PATH value and so would end up with
  ":/eigen-path" if CMAKE_INCLUDE_PATH was already set.  (This wasn't
  bug that was actually noticed since currently nothing else sets it).
2017-10-22 13:33:58 -03:00
Dean Moldovan
2d6116b53f Fix GIL release and acquire when embedding the interpreter
Fixes a race condition when multiple threads try to acquire the GIL
before `detail::internals` have been initialized. `gil_scoped_release`
is now tasked with initializing `internals` (guaranteed single-threaded)
to ensure the safety of subsequent `acquire` calls from multiple threads.
2017-06-24 14:03:42 +02:00
Dean Moldovan
9693a5c78f Add Catch framework for testing embedding support and C++-side features
At this point, there is only a single test for interpreter basics.

Apart from embedding itself, having a C++ test framework will also
benefit the C++-side features by allowing them to be tested directly.
2017-05-28 02:12:24 +02:00