1. 19 Aug, 2020 2 commits
    • Henry Schreiner's avatar
      tests: avoid putting build products into source directory (#2353) · 04fdc44f
      Henry Schreiner authored
      * 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
      04fdc44f
    • Henry Schreiner's avatar
      feat: new FindPython support (#2370) · 1729aae9
      Henry Schreiner authored
      * 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
      1729aae9
  2. 18 Aug, 2020 1 commit
  3. 06 Aug, 2020 1 commit
  4. 01 Aug, 2020 1 commit
  5. 31 Jul, 2020 6 commits
  6. 24 Jun, 2018 1 commit
    • Axel Huebl's avatar
      CMake: Remember Python Version (#1434) · 97b20e53
      Axel Huebl authored
      It is useful not only to remember the python libs and includes but
      also the interpreter version in cache.
      
      If users call pybind11 throught `add_subdirectories` they will
      otherwise have no access to the selected interpreter version.
      The interpreter version is useful for downstream projects, e.g.
      to select default `lib/pythonX.Y/site-packages/` install paths.
      97b20e53
  7. 06 Sep, 2017 1 commit
  8. 30 Aug, 2017 1 commit
  9. 23 Aug, 2017 1 commit
  10. 17 Aug, 2017 3 commits
    • Jason Rhinelander's avatar
      Allow binding factory functions as constructors · 464d9896
      Jason Rhinelander authored
      This allows you to use:
      
          cls.def(py::init(&factory_function));
      
      where `factory_function` returns a pointer, holder, or value of the
      class type (or a derived type).  Various compile-time checks
      (static_asserts) are performed to ensure the function is valid, and
      various run-time type checks where necessary.
      
      Some other details of this feature:
      - The `py::init` name doesn't conflict with the templated no-argument
        `py::init<...>()`, but keeps the naming consistent: the existing
        templated, no-argument one wraps constructors, the no-template,
        function-argument one wraps factory functions.
      - If returning a CppClass (whether by value or pointer) when an CppAlias
        is required (i.e. python-side inheritance and a declared alias), a
        dynamic_cast to the alias is attempted (for the pointer version); if
        it fails, or if returned by value, an Alias(Class &&) constructor
        is invoked.  If this constructor doesn't exist, a runtime error occurs.
      - for holder returns when an alias is required, we try a dynamic_cast of
        the wrapped pointer to the alias to see if it is already an alias
        instance; if it isn't, we raise an error.
      - `py::init(class_factory, alias_factory)` is also available that takes
        two factories: the first is called when an alias is not needed, the
        second when it is.
      - Reimplement factory instance clearing.  The previous implementation
        failed under python-side multiple inheritance: *each* inherited
        type's factory init would clear the instance instead of only setting
        its own type value.  The new implementation here clears just the
        relevant value pointer.
      - dealloc is updated to explicitly set the leftover value pointer to
        nullptr and the `holder_constructed` flag to false so that it can be
        used to clear preallocated value without needing to rebuild the
        instance internals data.
      - Added various tests to test out new allocation/deallocation code.
      - With preallocation now done lazily, init factory holders can
        completely avoid the extra overhead of needing an extra
        allocation/deallocation.
      - Updated documentation to make factory constructors the default
        advanced constructor style.
      - If an `__init__` is called a second time, we have two choices: we can
        throw away the first instance, replacing it with the second; or we can
        ignore the second call.  The latter is slightly easier, so do that.
      464d9896
    • Jason Rhinelander's avatar
      Don't force hidden visibility on the embed target, just the module target · 0d703f6e
      Jason Rhinelander authored
      Embedding may well be used in places where hidden visibility isn't
      desired.  It should be relatively safe to allow it there; any potential
      conflict would come in if modules are loaded into that embedded
      interpreter, but as long as the modules are compiled with hidden
      visibility they shouldn't conflict.
      
      There could still be warnings if the embedded code attempts to export
      classes with internal (hidden) pybind members, but that seems a
      legitimate warning (and already has a FAQ entry).
      0d703f6e
    • Dean Moldovan's avatar
      f5806498
  11. 14 Aug, 2017 1 commit
    • Jason Rhinelander's avatar
      Compile with hidden visibility always; set via cmake property rather than compiler flag · 97aa54fe
      Jason Rhinelander authored
      This updates the compilation to always apply hidden visibility to
      resolve the issues with default visibility causing problems under debug
      compilations.  Moreover using the cmake property makes it easier for a
      caller to override if absolutely needed for some reason.
      
      For `pybind11_add_module` we use cmake to set the property; for the
      targets, we append to compilation option to non-MSVC compilers.
      97aa54fe
  12. 07 Aug, 2017 2 commits
    • Dean Moldovan's avatar
      Add test for custom CMake export group · 3dde6ddc
      Dean Moldovan authored
      3dde6ddc
    • Ben Boeckel's avatar
      CMake: support a custom export group (#970) · 017a747d
      Ben Boeckel authored
      When Pybind11 is used via `add_subdirectory`, when targets are installed
      from the parent project, CMake wants all of the dependencies built by
      the project in the same export set. Projects may now set
      `PYBIND11_EXPORT_NAME` to have Pybind11 put it targets into the
      project's export set. If so, do not install Pybind11's export file.
      017a747d
  13. 28 May, 2017 2 commits
  14. 07 May, 2017 1 commit
  15. 13 Apr, 2017 1 commit
    • Jason Rhinelander's avatar
      Move buffer_info to its own header · dbb4c5b5
      Jason Rhinelander authored
      Upcoming changes to buffer_info make it need some things declared in
      common.h; it also feels a bit misplaced in common.h (which is arguably
      too large already), so move it out.  (Separating this and the subsequent
      changes into separate commits to make the changes easier to distinguish
      from the move.)
      dbb4c5b5
  16. 24 Mar, 2017 1 commit
    • Ghislain Antony Vaillant's avatar
      Arch-indep CMake packaging (#764) · 5b503764
      Ghislain Antony Vaillant authored
      * Arch-indep CMake packaging
      
      Since pybind11 is a header-only library, the CMake packaging does not have to carry any architecture specific checks. Without this patch, the detection of pybind11 will fail on 32-bit architectures if the project was built on a 64-bit machine and vice-versa. This fix is similar to what is applied to `Eigen` and other header-only C++ libraries.
      5b503764
  17. 24 Feb, 2017 1 commit
    • Jason Rhinelander's avatar
      Independent tests (#665) · 60d0e0db
      Jason Rhinelander authored
      * Make tests buildable independently
      
      This makes "tests" buildable as a separate project that uses
      find_package(pybind11 CONFIG) when invoked independently.
      
      This also moves the WERROR option into tests/CMakeLists.txt, as that's
      the only place it is used.
      
      * Use Eigen 3.3.1's cmake target, if available
      
      This changes the eigen finding code to attempt to use Eigen's
      system-installed Eigen3Config first.  In Eigen 3.3.1, it exports a cmake
      Eigen3::Eigen target to get dependencies from (rather than setting the
      include path directly).
      
      If it fails, we fall back to the trying to load allowing modules (i.e.
      allowing our tools/FindEigen3.cmake).  If we either fallback, or the
      eigen version is older than 3.3.1 (or , we still set the include
      directory manually; otherwise, for CONFIG + new Eigen, we get it via
      the target.
      
      This is also needed to allow 'tests' to be built independently, when
      the find_package(Eigen3) is going to find via the system-installed
      Eigen3Config.cmake.
      
      * Add a install-then-build test, using clang on linux
      
      This tests that `make install` to the actual system, followed by a build
      of the tests (without the main pybind11 repository available) works as
      expected.
      
      To also expand the testing variety a bit, it also builds using
      clang-3.9 instead of gcc.
      
      * Don't try loading Eigen3Config in cmake < 3.0
      
      It could FATAL_ERROR as the newer cmake includes a cmake 3.0 required
      line.
      
      If doing an independent, out-of-tree "tests" build, the regular
      find_package(Eigen3) is likely to fail with the same error, but I think
      we can just let that be: if you want a recent Eigen with proper cmake
      loading support *and* want to do an independent tests build, you'll
      need at least cmake 3.0.
      60d0e0db
  18. 23 Feb, 2017 1 commit
    • Dean Moldovan's avatar
      Reimplement static properties by extending PyProperty_Type · c91f8bd6
      Dean Moldovan authored
      Instead of creating a new unique metaclass for each type, the builtin
      `property` type is subclassed to support static properties. The new
      setter/getters always pass types instead of instances in their `self`
      argument. A metaclass is still required to support this behavior, but
      it doesn't store any data anymore, so a new one doesn't need to be
      created for each class. There is now only one common metaclass which
      is shared by all pybind11 types.
      c91f8bd6
  19. 14 Feb, 2017 1 commit
  20. 08 Feb, 2017 1 commit
    • Matthew Woehlke's avatar
      Avoid C-style const casts (#659) · e15fa9f9
      Matthew Woehlke authored
      * Avoid C-style const casts
      
      Replace C-style casts that discard `const` with `const_cast` (and, where
      necessary, `reinterpret_cast` as well).
      
      * Warn about C-style const-discarding casts
      
      Change pybind11_enable_warnings to also enable `-Wcast-qual` (warn if a
      C-style cast discards `const`) by default. The previous commit should
      have gotten rid of all of these (at least, all the ones that tripped in
      my build, which included the tests), and this should discourage more
      from newly appearing.
      e15fa9f9
  21. 26 Dec, 2016 1 commit
    • Jason Rhinelander's avatar
      Avoid CMP0048 warning (#570) · a3fec901
      Jason Rhinelander authored
      Fixes #567.
      
      If pybind's CMakeLists gets loaded via an include_directory from another
      CMakeLists with a higher minimum version (e.g. 3.0), the project()
      command without a version produces a CMP0048 warning.
      
      This commit explicitly requests the new behaviour if the policy exists,
      as it won't cause problems (we set VERSION later).
      a3fec901
  22. 19 Dec, 2016 2 commits
    • Dean Moldovan's avatar
      Rename target from pybind11::pybind11 to pybind11::module · 71e8a796
      Dean Moldovan authored
      Makes room for an eventual pybind11::embedded target.
      71e8a796
    • Dean Moldovan's avatar
      Make sure add_subdirectory and find_package behave identically · b0f3885c
      Dean Moldovan authored
      Add a BUILD_INTERFACE and a pybind11::pybind11 alias for the interface
      library to match the installed target.
      
      Add new cmake tests for add_subdirectory and consolidates the
      .cpp and .py files needed for the cmake build tests:
      
      Before:
      tests
      |-- test_installed_module
      |   |-- CMakeLists.txt
      |   |-- main.cpp
      |   \-- test.py
      \-- test_installed_target
          |-- CMakeLists.txt
          |-- main.cpp
          \-- test.py
      
      After:
      tests
      \-- test_cmake_build
          |-- installed_module/CMakeLists.txt
          |-- installed_target/CMakeLists.txt
          |-- subdirectory_module/CMakeLists.txt
          |-- subdirectory_target/CMakeLists.txt
          |-- main.cpp
          \-- test.py
      b0f3885c
  23. 13 Dec, 2016 3 commits
  24. 15 Nov, 2016 1 commit
  25. 09 Oct, 2016 2 commits
  26. 29 Sep, 2016 1 commit