Commit Graph

690 Commits

Author SHA1 Message Date
Ralf W. Grosse-Kunstleve
9cd8e7449b Merge branch 'master' into smart_holder 2021-07-10 16:39:02 -07:00
Jan Iwaszkiewicz
cf006af2f0
Fix typos and docs style (#3088)
* py::pickle typo

* correct dots and parentheses
2021-07-10 11:16:07 -07:00
Ralf W. Grosse-Kunstleve
704daac879 Merge branch 'master' into smart_holder 2021-07-06 14:12:08 -07:00
luzpaz
8bee61b645
docs: fix various typos (#3075)
Found via `codespell -q 3 -L nd,ot,thist`
2021-07-04 19:58:35 -04:00
Ralf W. Grosse-Kunstleve
84cbec0bc1 Merge branch 'master' into smart_holder 2021-07-02 07:07:49 -07:00
Antony Lee
5bcaaa0423
Add a std::filesystem::path <-> os.PathLike caster. (#2730) 2021-07-02 07:00:50 -07:00
Ralf W. Grosse-Kunstleve
c48f887cd8 Merge branch 'master' into smart_holder 2021-06-17 14:01:07 -07:00
Aaron Gokaslan
b4b67f026b
Fix typos (#3044) 2021-06-17 13:39:59 -07:00
Aaron Gokaslan
cd4b49a2c8
Update py::kwargs examples to pass by reference (#3038) 2021-06-17 13:20:17 -07:00
Ralf W. Grosse-Kunstleve
2cfc017e2d Merge branch 'master' into smart_holder 2021-05-27 11:30:03 -07:00
Yichen
3ac690b88b
Explicitly export exception types. (#2999)
* Set visibility of exceptions to default.

Co-authored-by: XZiar <czktc2007@gmail.com>

* add test

* update docs

* Skip failed test.
2021-05-27 08:00:18 -07:00
Ralf W. Grosse-Kunstleve
29e46381e4 Merge branch 'master' into smart_holder 2021-05-06 09:48:55 -07:00
Eric Cousineau
b6ec0e950c
functions: Add doc on incorrect argument index (#2979)
test_call_policies: Explicitly check free-functions and static methods
2021-05-06 10:13:30 -04:00
Ralf W. Grosse-Kunstleve
0032083113 Merge branch 'master' into smart_holder 2021-04-16 07:27:12 -07:00
Henry Schreiner
114be7f4ad
docs: remove recommonmark (#2955) 2021-04-15 18:27:16 -04:00
Ralf W. Grosse-Kunstleve
0b63dd0eb2
Adding initial README_smart_holder.rst. (#2936)
* Adding initial README_smart_holder.rst.

* Adding README_smart_holder.rst to MANIFEST.in and test_files.py.
2021-04-05 13:47:48 -07:00
JYX
3df0ee6fe3
docs: typo in classes.rst (#2926) 2021-04-02 11:46:43 -04:00
Tom de Geus
9c0aa69937
Pointing out namespace in docs (#2874) 2021-02-25 07:25:50 -08:00
jakobjw
98f9a33c62
Correct typo in FAQ (#2868) 2021-02-20 23:28:27 +01:00
Ralf W. Grosse-Kunstleve
0432ae7c52
Changing pybind11::str to exclusively hold PyUnicodeObject (#2409)
* Changing pybind11::str to exclusively hold PyUnicodeObject
2021-01-29 09:41:42 -08:00
Yannick Jadoul
587d5f840a
Update breathe to 4.26.1, add make_tuple, make_iterator, and make_key_iterator (#2828) 2021-01-28 12:28:16 +01:00
Henry Fredrick Schreiner
4a5b81b1b7 chore: get back to work 2021-01-26 22:28:09 -05:00
Henry Schreiner
8de7772cc7
chore: prepare for the 2.6.2 release (#2821) 2021-01-26 21:26:45 -05:00
Henry Schreiner
8e5d3d234e
docs: prepare for 2.6.2 (#2820)
* docs: prepare for 2.6.2

* chore: pre-commit autoupdate
2021-01-25 16:09:36 -05:00
Henry Schreiner
08bca374fd
docs: update changelog, nicer output for script (#2811) 2021-01-21 11:34:39 -05:00
Henry Schreiner
0df11d857c
docs: update build description slightly (#2794)
* docs: update build description slightly

* docs: missing ticks
2021-01-16 20:12:19 -05:00
Yannick Jadoul
1faf4a8ae4
docs: the order of alternatives for variant types matters, and follows the same rules as overload resolution (#2784) 2021-01-13 23:17:27 -05:00
Andy Maloney
14b375123c
docs: fix example code in Exceptions section (match vs. matches) (#2781) 2021-01-13 23:14:45 -05:00
Henry Schreiner
b7dfe5cc84
chore: changelog update (#2750) 2020-12-28 20:14:54 -05:00
Steve Siano
6f66e7603c
docs: add a note about compiling the example (#2737)
* docs: mention PYTHONPATH in installing.rst

When pybind11 is included as a submodule, the user needs to update their
Python module search path.  Otherwise, the first c++ compilation command
in docs/basics.rst will fail.

* docs: add a note about compiling the example

This note shows how to modify the compilation command for the example
when the pybind11 source has been included as a Git submodule.

* docs: add a note about compiling the example

Added an internal link to the docs

* docs: updated a note about compiling the example

Also updated the command substitution syntax for consistency
2020-12-24 09:51:36 -05:00
Henry Schreiner
79b0e2c052
docs: fix pdf build, simpler start page (#2736) 2020-12-22 08:50:45 -05:00
Henry Schreiner
5bd766bf6c
docs: update changelog and add script to help generate it (#2733) 2020-12-21 21:04:33 -05:00
Antony Lee
d068ab286a
docs: pybind11/numpy.h does not require numpy at build time. (#2720)
This is nice enough to be mentioned explicitly in the docs.
2020-12-08 18:07:36 -05:00
Yannick Jadoul
028812ae7e
docs: add warning about FindPython's Development component when libraries don't exist (e.g. on manylinux) (#2689)
* Add waring about FindPython's Development component when libraries don't exist (e.g. on manylinux)

* Minor wording update (thanks, @henryiii!)
2020-11-24 13:37:51 -05:00
James Foster
d57c1fab7f
docs: update installing.rst (#2691)
`git submodule add` needs the branch before the repository or else it is ignored. The previous code checked out the `master` branch, not the `stable` branch.
2020-11-24 12:08:33 -05:00
Jean-Baptiste Lespiau
af8849f47e
docs: list all pybind11 exceptions (#2671)
* List all the pyind11 exceptions.

For curious readers, see `translate_exception` and
`PYBIND11_RUNTIME_EXCEPTION.
2020-11-19 10:11:55 -05:00
Henry Schreiner
17c22b9e0f
docs: mention branch update in checklist (#2670) 2020-11-16 16:18:43 +01:00
Bjorn
32d11c9653
fix typo in pickle example (#2669) 2020-11-16 15:57:06 +01:00
Henry Schreiner
02746cb69f docs: add a little more information for releases 2020-11-12 13:06:00 -05:00
Henry Schreiner
b7c741b540 docs: back to work after 2.6.1 2020-11-11 19:27:41 -05:00
Henry Schreiner
f1abf5d915
docs: changelog update (#2652) 2020-11-11 16:33:21 -05:00
Henry Schreiner
ebd5c5b48c
feat: way to only recompile changed files (#2643)
* feat: lazy compile

* refactor: lazy -> only_changed

* refactor: leave the changed function up to the user

* refactor: pass a function, based on @YannickJadoul and @HDembinski's suggestions

* refactor: old -> _old, as it's not intended for users

* docs: slight improvmenent from @rwgk

* docs: Ccache spelling, extra warning about pip caching

Ccache spelling noted by @YannickJadoul
2020-11-11 11:45:28 -05:00
Wink Saville
7c26c71835
Fix mispelling in basics.rst (#2614)
Replaced adviced with advised.
2020-10-21 20:11:34 +02:00
Wenzel Jakob
86d3e9eb43 begin working towards a future v2.6.1 patch release 2020-10-21 18:31:10 +02:00
Wenzel Jakob
59a2ac2745 v2.6.0 release 2020-10-21 18:07:48 +02:00
Mana Borwornpadungkitti
6edd0e6d90
fix: Reject keyword argument None with .none(false) (#2611)
* demo kwarg with none(false)

* Reorder and extend tests for arg::none(false) in test_methods_and_attributes.py::test_accepts_none

* Fix arg::none() for keyword arguments

* Add changelog note

* Fix names of no_none_kw test functions

Co-authored-by: Yannick Jadoul <yannick.jadoul@belgacom.net>
2020-10-20 23:57:22 +02:00
Henry Schreiner
0b9acc4009
fix: chapters in PDF again (#2606)
* fix: chapters in PDF again

* fix: sections in README
2020-10-18 14:31:28 -04:00
Henry Schreiner
09056717da
fix: much better pdf (#2604)
* docs: fix PDF build by adding unicode mappings

* fix: better PDF

* fix: html build issue
2020-10-18 00:21:16 -04:00
Henry Schreiner
c16da99309 chore: bump to 2.6.0rc3 2020-10-16 17:34:53 -04:00
Henry Schreiner
c50f90eca6
style: use Black everywhere (#2594)
* style: use Black everywhere

* style: minor touchup from review
2020-10-16 16:38:13 -04:00
Henry Schreiner
2e31e466dc docs: update for PyPy win 32 issue 2020-10-15 17:38:49 -04:00
Henry Schreiner
f200832534 style: ssize_t -> py::ssize_t 2020-10-15 17:38:49 -04:00
Henry Schreiner
645d83813b
feat: typing support for helpers (#2588)
* feat: basic typing support

* docs: mention syncing as suggested by @rwgk

* docs: update changelog

* docs: copy of warning in limitations
2020-10-14 14:08:41 -04:00
Henry Schreiner
a8c2e3eec5
fix: ipo should be off for debug or relwithdebinfo (#2590)
* fix: ipo should be off for debug or relwithdebinfo

Closes #2587

* docs: slightly more detailed about IPO

* Update pybind11Common.cmake
2020-10-14 13:43:31 -04:00
Henry Schreiner
2a263e087c
docs: some final 2.6.0 updates (#2582)
* docs: some final 2.6.0 updates

* docs: better warning text
2020-10-13 18:19:05 -04:00
Henry Schreiner
993495c96c
fix: Intel 18+ required (#2577)
* fix: Intel 18+ fully supported

* fix: Intel compiler workaround no longer needed

Followup on #94 now that Intel 18+ is required.
2020-10-12 16:31:44 -04:00
Henry Schreiner
e4e5c49a26
docs: known issues (#2565)
* docs: FAQ CMake updates

* docs: limitations

* ci: don't over label

* docs: update CHANGELOG, add a bit more structure

* ci: label PRs with more labels, and sooner

* docs: updates from @rwgk

* docs: address @YannickJadoul's points
2020-10-09 11:19:13 -04:00
Yannick Jadoul
0c5cc031ee
feat: deprecate public constructors of module_ class (#2552)
* Deprecated public constructors of module

* Turn documentation comment of module_::add_object into valid doxygen documentation

* Move definition of PYBIND11_DETAIL_MODULE_STATIC_DEF and PYBIND11_DETAIL_MODULE_CREATE macros up

* Move detail::create_top_level_module to module_::create_extension_module, and unify Python 2 and 3 signature again

* Throw error_already_set if module creation fails in module_::create_extension_module

* Mention module_::create_extension_module in deprecation warning message of module_::module_
2020-10-09 10:46:11 -04:00
jbarlow83
49cdb70a4d
docs: use sorted(glob()) in example setup.py (#2561) 2020-10-08 09:04:27 -04:00
Henry Schreiner
49c389b760
ci: test on Windows 3.8 and 3.9 (mostly) (#2560)
* ci: skip cpptest on Win Py 3.8+

* docs: minor typo caught by @rwgk
2020-10-08 09:04:02 -04:00
Henry Schreiner
b6f37f67ac
docs: minor cleanup (#2555)
* docs: minor cleanup

* ci: fix add-path command

* docs: add example of use in-place

* Update .github/workflows/ci.yml
2020-10-07 20:41:03 -04:00
Henry Schreiner
00edc3001b
fix: PYBIND11_OBJECT required pybind11 namespace (regression) (#2553)
* fix: PYBIND11_OBJECT could only be used inside the pybind11 namespace (regression)

* docs: add changelog for conversion protection change

* ci: update to Python 3.9
2020-10-06 10:04:13 -04:00
Henry Schreiner
9a0c96dd4c
feat: py::prepend tag (#1131)
* feat: add a priority overload with py::prepend

* doc: fix wording as suggested by rwgk

* feat: add get_pointer

* refactor: is_prepended -> prepend (internal)

* docs: suggestion from @wjakob

* tests: add test covering get_pointer/set_pointer
2020-10-05 22:36:33 -04:00
Henry Schreiner
2a2f52201d
fix: find_import didn't work properly for classic tools (#2550)
* fix: find_import didn't work properly for classic tools

* ci: fix all files not being checked in style run
2020-10-05 15:31:00 -04:00
Yannick Jadoul
1411207711
chore: drop support for PyPy < 7.3.1 and clean up old PyPy workarounds (#2456)
* Remove code inside 'PYPY_VERSION_NUM < 0x06000000' preprocessor if branch

* fix: more cleanup

* Remove more references to PyPy 5.7 and 5.9 in the docs

* Update comment on PyUnicode_UTF* in PyPy

Co-authored-by: Henry Schreiner <henryschreineriii@gmail.com>
2020-10-05 10:43:27 -04:00
Yannick Jadoul
b70894df52
docs: add std::valarray to docs/advanced/cast/stl.rst (#2547) 2020-10-04 09:52:55 -04:00
Henry Schreiner
6bcd220c8d
refactor: module -> module_ with typedef (#2544)
* WIP: module -> module_ without typedef

* refactor: allow py::module to work again
2020-10-03 13:38:03 -04:00
Henry Schreiner
560ed3e34f
docs: fix odd spacing 2020-10-02 22:38:29 -04:00
Henry Schreiner
3488494a81
refactor: import check as a common function (#2526)
* feat: import check as a common function

* docs: add cmake to docs
2020-10-02 22:34:22 -04:00
Yannick Jadoul
9796fe98fc
feat: vectorize functions with void return type (#1969)
* Allow function/functor passed to py::vectorize to return void

* Stealing @sizmailov's test and fixing unused argument warning

* Add missing std::move()

RVO doesn't work here because function return type is different from
actual returned type

* remove extra EOL

* docs: add a few details

* chore: pre-commit autoupdate

* Remove array_iterator, array_begin, and array_end (in detail namespace)

Co-authored-by: Sergei Izmailov <sergei.a.izmailov@gmail.com>
Co-authored-by: Henry Schreiner <henryschreineriii@gmail.com>
2020-10-02 15:30:34 -04:00
Henry Schreiner
b9d00273ee
feat: parallel compiler (#2521) 2020-10-02 10:03:35 -04:00
Boris Staletic
5ebc78164d
Allow raw unions without base classes in is_accessible_base_of (#2320)
Co-authored-by: Henry Schreiner <HenrySchreinerIII@gmail.com>
2020-10-02 09:39:22 -04:00
Henry Schreiner
82dbc5b78f
ci: releases (#2530)
* ci: releases

* docs: minor update form @wjakob

* fix: enforce reasonable version of setuptools
2020-09-30 15:48:08 -04:00
Henry Schreiner
54831a9a1a fix: use svg to pdf converter instead of original solution 2020-09-17 16:07:47 -04:00
Henry Schreiner
81555ce61f
docs: Use README.rst in docs as home page (#2500) 2020-09-17 15:40:09 -04:00
Henry Schreiner
99ef2b8467
docs: read version from pybind11 file (#2496)
* docs: read version from pybind11 file

* docs: show full PEP 440 version everywhere
2020-09-17 09:08:08 -04:00
Henry Schreiner
dec33c29f2
docs: installing section (#2494)
* docs: installing section

* docs: feedback from @wjakob
2020-09-16 20:00:19 -04:00
Boris Staletic
d3c999c774
fix: rename pybind11::module to pybind11::module_ (#2489)
Support C++20. For backwards compatibility, we provide an alias for the old name.
This change is necessary to easily avoid errors when a compiler thinks
`module` is used as a keyword.
2020-09-16 17:15:42 -04:00
Henry Schreiner
e37921d761
refactor: drop mkdoc and update changelog (#2491)
* refactor: drop mkdoc

* docs: update changelog
2020-09-16 17:14:06 -04:00
Henry Schreiner
fd61f5038e
feat: setup.py redesign and helpers (#2433)
* feat: setup.py redesign and helpers

* refactor: simpler design with two outputs

* refactor: helper file update and Windows support

* fix: review points from @YannickJadoul

* refactor: fixes to naming and more docs

* feat: more customization points

* feat: add entry point pybind11-config

* refactor: Try Extension-focused method

* refactor: rename alt/inplace to global

* fix: allow usage with git modules, better docs

* feat: global as an extra (@YannickJadoul's suggestion)

* feat: single version location

* fix: remove the requirement that setuptools must be imported first

* fix: some review points from @wjacob

* fix: use .in, add procedure to docs

* refactor: avoid monkeypatch copy

* docs: minor typos corrected

* fix: minor points from @YannickJadoul

* fix: typo on Windows C++ mode

* fix: MSVC 15 update 3+ have c++14 flag

See <https://docs.microsoft.com/en-us/cpp/build/reference/std-specify-language-standard-version?view=vs-2019>

* docs: discuss making SDists by hand

* ci: use pep517.build instead of manual setup.py

* refactor: more comments from @YannickJadoul

* docs: updates from @ktbarrett

* fix: change to newly recommended tool instead of pep517.build

This was intended as a proof of concept; build seems to be the correct replacement.

See https://github.com/pypa/pep517/pull/83

* docs: updates from @wjakob

* refactor: dual version locations

* docs: typo spotted by @wjakob
2020-09-16 17:13:41 -04:00
Henry Schreiner
41aa92601e
refactor: replace .get_type with type::handle_of (#2492)
* refactor: replace .get_type with type::handle_of

* refactor: use impl for handle_of

* fix: deprecate h.get_type()
2020-09-16 11:32:17 -04:00
Griffin Downs
a4cee36b6f
Add vcpkg installation instructions (#1936)
* Add vcpkg installation instructions

* Casing

* Move instructions

Co-authored-by: Henry Fredrick Schreiner <henry.fredrick.schreiner@cern.ch>
2020-09-16 08:07:06 -04:00
Henry Schreiner
dabbbf315d
fix: use OVERRIDE instead of OVERLOAD (#2490)
* fix: use OVERRIDE instead of OVERLOAD

* docs: more accurate statement
2020-09-15 12:10:31 -04:00
Yannick Jadoul
16f199f8d9
Change base parameter type in register_exception and exception constructor from PyObject* to handle (#2467)
* Change base parameter type in register_exception and excepion constructor from PyObject* to handle

* Fix compilation error passing `handle` to `PyObject*`
2020-09-15 10:24:39 -04:00
Yannick Jadoul
d65e34d61d
Resolve empty statement warning when using PYBIND11_OVERLOAD_PURE_NAME and PYBIND11_OVERLOAD_PURE (#2325)
* Wrap PYBIND11_OVERLOAD_NAME and PYBIND11_OVERLOAD_PURE_NAME in do { ... } while (false), and resolve trailing semicolon

* Deprecate PYBIND11_OVERLOAD_* and get_overload in favor of PYBIND11_OVERRIDE_* and get_override

* Correct erroneous usage of 'overload' instead of 'override' in the implementation and internals

* Fix tests to use non-deprecated PYBIND11_OVERRIDE_* macros

* Update docs to use override instead of overload where appropriate, and add warning about deprecated aliases

* Add semicolons to deprecated PYBIND11_OVERLOAD macros to match original behavior

* Remove deprecation of PYBIND11_OVERLOAD_* macros and get_overload

* Add note to changelog and upgrade guide
2020-09-15 14:56:20 +02:00
Henry Schreiner
f12ec00d70
feat: py::type::of<T>() and py::type::of(h) (#2364)
* feat: type<T>()

* refactor: using py::type as class

* refactor: py::object as base

* wip: tigher api

* refactor: fix conversion and limit API further

* docs: some added notes from @EricCousineau-TRI

* refactor: use py::type::of
2020-09-14 18:06:26 -04:00
Boris Staletic
32bb9071aa
Avoid C-style casts for pointers in docs (#2487)
Why only for pointers? Because C casts are hard to grep for.
2020-09-14 20:07:29 +02:00
andriish
38370a87f4
fix: support NVIDIA-PGI HPC SDK (#2475)
* Added guards to the includes

Added new CI config

Added new trigger

Changed CI workflow name

Debug CI

Debug CI

Debug CI

Debug CI

Added flags fro PGI

Disable Eigen

Removed tests that fail

Uncomment lines

* fix: missing include

fix: minor style cleanup

tests: support skipping

ci: remove and tighten a bit

fix: try msvc workaround for pgic

* tests: split up prealoc tests

* fix: PGI compiler fix

* fix: PGI void_t only

* fix: try to appease nvcc

* ci: better ordering for slow tests

* ci: minor improvements to testing

* ci: Add NumPy to testing

* ci: Eigen generates CUDA warnings / PGI errors

* Added CentOS7 back for a moment

* Fix YAML

* ci: runs-on missing

* centos7 is missing pytest

* ci: use C++11 on CentOS 7

* ci: test something else

* Try just adding flags on CentOS 7

* fix: CentOS 7

* refactor: move include to shared location

* Added verbose flag

* Try to use system cmake3 on CI

* Try to use system cmake3 on CI, attempt2

* Try to use system cmake3 on CI, attempt3

* tests: not finding pytest should be a warning, not a fatal error

* tests: cleanup

* Weird issue?

* fix: final polish

Co-authored-by: Andrii Verbytskyi <andrii.verbytskyi@mpp.mpg.de>
Co-authored-by: Henry Schreiner <henryschreineriii@gmail.com>
Co-authored-by: Andrii Verbytskyi <averbyts@cern.ch>
2020-09-11 22:06:52 -04:00
Holger Kohr
fbc7563623
Add py::object casting example to embedding docs (#2466)
* Add py::object casting example to embedding docs

* Move implicit cast example to object.rst

* Move to bottom and improve implicit casting text

* Fix xref

* Improve wording as per @bstaletic's suggestion
2020-09-09 10:39:20 -04:00
Henry Schreiner
37f845a1dc
ci: disallow some common capitalization mistakes (#2472)
* ci: only annotate linux for now

* style: block some common mistakes
2020-09-08 15:26:50 +02:00
Wenzel Jakob
36c666f027 pybind11_add_module(): OPT_SIZE target 2020-09-06 16:46:38 +02:00
michalsustr
3bd0d7a8d5
Add note about specifying custom base class for Exceptions. (#2465)
* Add note about specifying custom base.

* Update exception docs based on PR feedback.

* Fix trailing whitespace.

Co-authored-by: Michal Sustr <michal.sustr@aic.fel.cvut.cz>
2020-09-06 13:35:53 +02:00
Henry Schreiner
0dbda6e80b
feat: py::pos_only (#2459)
* feat: py::pos_only

* fix: review points from @YannickJadoul

* fix: review points from @bstaletic

* refactor: kwonly -> kw_only
2020-09-04 20:02:05 -04:00
Eric Cousineau
44fa79ca80
pytypes: Add Gotchas section about default-constructed wrapper types and py::none() (#2362) 2020-09-04 19:26:57 -04:00
Sergei Izmailov
4c36fb7b12
[DOC] avoid C++ types in docstrings (#2441)
* doc: avoid C++ types in docstrings

* A bit of rewording

* Another bit of rewording

* Third rewording
2020-09-01 14:56:43 +02:00
Yannick Jadoul
43f390ad85
Add note that VS2017 requires /permissive- to build in C++17 mode (#2431)
* Add note that VS2017 requires /permissive- to build in C++17 mode

* ci: test C++17 on MSVC 2017

* ci: args1/2, use args to override max cxx

Co-authored-by: Henry Schreiner <henryschreineriii@gmail.com>
2020-08-24 14:31:20 -04:00
Yannick Jadoul
b3d8fec066
Adapt code example in advanced/classes.rst to new handling of forgetting to call the superclass __init__ (#2429) 2020-08-24 00:00:12 +02:00
Yannick Jadoul
4493751a5f
Fix new-style __init__ usage in numpy docs (#2426) 2020-08-23 18:35:51 +02:00
jbarlow83
b8863698d6
Improve documentation of Python and C++ exceptions (#2408)
The main change is to treat error_already_set as a separate category
of exception that arises in different circumstances and needs to be
handled differently. The asymmetry between Python and C++ exceptions
is further emphasized.
2020-08-23 00:11:09 +02:00
Henry Schreiner
2fa18431ce docs: pin versions for readthedocs 2020-08-20 14:42:00 -04:00
Henry Schreiner
a6887b604a docs: update changelog and versionadded 2020-08-20 14:42:00 -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
Mosalam Ebrahimi
7dd2bdb0b3
docs: fix typo (#2405) 2020-08-18 06:46:23 -04:00
James R. Barlow
3618bea2aa Add and document py::error_already_set::discard_as_unraisable()
To deal with exceptions that hit destructors or other noexcept functions.

Includes fixes to support Python 2.7 and extends documentation on
error handling.

@virtuald and @YannickJadoul both contributed to this PR.
2020-08-16 10:05:03 -07:00
Dustin Spicuzza
6f3470f757
Add robotpy-build to list of tools (#2359) 2020-08-10 16:10:45 -04:00
Yannick Jadoul
3e448c0b5e
Enable py::ellipsis on Python 2 (#2360)
* Enable py::ellipsis on Python 2

* Enable py::ellipsis tests on Python 2 and mention `Ellipsis` in the docs
2020-08-04 14:45:55 +02:00
Henry Schreiner
1651c32492 update: address review points 2020-07-30 20:27:55 -04:00
Henry Schreiner
1b92cd1703 fix: address review points from @YannickJadoul 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
Boris Staletic
441e777040
Use new style __init__ in numpy docs (#2316) 2020-07-23 16:03:55 +02:00
Henry Schreiner
d8c7ee00a6
ci: GHA basic format & pre-commit (#2309) 2020-07-20 13:35:21 -04:00
Kota Yamaguchi
e248869893
Fix undefined memoryview format (#2223)
* Fix undefined memoryview format

* Add missing <algorithm> header

* Add workaround for py27 array compatibility

* Workaround py27 memoryview behavior

* Fix memoryview constructor from buffer_info

* Workaround PyMemoryView_FromMemory availability in py27

* Fix up memoryview tests

* Update memoryview test from buffer to check signedness

* Use static factory method to create memoryview

* Remove ndim arg from memoryview::frombuffer and add tests

* Allow ndim=0 memoryview and documentation fixup

* Use void* to align to frombuffer method signature

* Add const variants of frombuffer and frommemory

* Add memory view section in doc

* Fix docs

* Add test for null buffer

* Workaround py27 nullptr behavior in test

* Rename frombuffer to from_buffer
2020-07-15 08:50:43 -07:00
Yannick Jadoul
964ab956e0
Fix DeprecationWarning about 'invalid escape sequence' in tools/docs Python scripts (#2281) 2020-07-10 16:30:44 +02:00
Dustin Spicuzza
1b0bf352fa
Throw TypeError when subclasses forget to call __init__ (#2152)
- Fixes #2103
2020-07-07 12:04:06 +02:00
Wenzel Jakob
fc3a4490b8 Minor clarification (@AntoinePrv, #2083) 2020-07-01 00:29:55 +02:00
Guilherme Dantas
8908552dfc typo 2020-07-01 00:12:33 +02:00
Lin Hsu
d031efe788 Typo 2020-07-01 00:08:05 +02:00
Matthijs van der Burgh
b524008967
Deepcopy documentation (#2242)
* (docs) convert note to real note

* (docs) Add information about (deep)copy
2020-06-10 13:30:41 +02:00
Wenzel Jakob
a54eab92d2 Revert "Change __init__(self) to __new__(cls)"
This reverts commit 9ed8b44033.
2020-04-26 22:53:50 +02:00
Dustin Spicuzza
2c4cd8419d Add AutoWIG to list of binding generators (#1990)
* Add AutoWIG to list of binding generators
2020-04-26 18:40:54 +02:00
Sebastian Koslowski
a86ac538f5 rename args_kw_only to kwonly 2020-04-26 18:07:51 +02:00
Jason Rhinelander
be0d804523 Support keyword-only arguments
This adds support for a `py::args_kw_only()` annotation that can be
specified between `py::arg` annotations to indicate that any following
arguments are keyword-only.  This allows you to write:

    m.def("f", [](int a, int b) { /* ... */ },
          py::arg("a"), py::args_kw_only(), py::arg("b"));

and have it work like Python 3's:

    def f(a, *, b):
        # ...

with respect to how `a` and `b` arguments are accepted (that is, `a` can
be positional or by keyword; `b` can only be specified by keyword).
2020-04-26 18:07:51 +02:00
Dustin Spicuzza
0dfffcf257 Add is_final to disallow inheritance from Python
- Not currently supported on PyPy
2020-04-26 09:46:44 +02:00
Orell Garten
9ed8b44033 Change __init__(self) to __new__(cls)
__init__(self) cannot return values. According to https://stackoverflow.com/questions/2491819/how-to-return-a-value-from-init-in-python __new__(cls) should be used, which works.
2020-04-26 09:21:42 +02:00
Axel Huebl
6ebfc4b2b0 Document CMAKE_CXX_STANDARD
This variable is a CMake community standard to set the C++
standard of a build. Document it in favor of the previous variable,
which stays as a legacy flag for existing projects.

https://cmake.org/cmake/help/v3.17/variable/CMAKE_CXX_STANDARD.html
2020-04-26 09:17:10 +02:00
Wenzel Jakob
0234871649 begin working on next version 2020-03-31 13:09:41 +02:00
Wenzel Jakob
3b1dbebabc v2.5.0 release 2020-03-31 13:00:39 +02:00
Eric Cousineau
baf69345f6 Minor modifications to interrupt handling FAQ (#2007) 2019-11-25 22:14:06 +08:00
Charles Brossollet
0f1d3bfee2 Add FAQ entry for dealing with long functions interruption (#2000)
* Add FAQ entry, with code example, for dealing with long functions interruption
2019-11-25 17:59:53 +08:00
Francesco Biscani
deb3cb238a Add exception translation for std::overflow_error. (#1977) 2019-11-14 08:56:58 +01:00
Erick Matsen
b32b762c60 Fixing minor typo in basics.rst (#1984) 2019-11-14 08:54:46 +01:00
Wenzel Jakob
dfde1554ea begin working on next version 2019-10-15 01:58:43 +02:00
Wenzel Jakob
80d452484c v2.4.3 release 2019-10-15 01:57:24 +02:00
Wenzel Jakob
34c2281e31 begin working on next version 2019-09-21 20:23:01 +02:00
Wenzel Jakob
2abd7e1eb4 updated release.rst to remove parts that are now automated 2019-09-21 20:22:33 +02:00
Wenzel Jakob
7ec2ddfc95 v2.4.2 release 2019-09-21 20:20:26 +02:00
Wenzel Jakob
82cf793588 begin working on next version 2019-09-20 11:12:22 +02:00
Wenzel Jakob
e44fcc3c15 v2.4.1 release 2019-09-20 11:10:49 +02:00
Wenzel Jakob
5fd187ebe9 minor changelog cleanup
[ci skip]
2019-09-20 10:49:54 +02:00
Wenzel Jakob
e825205ac6 begin working on v2.4.1 2019-09-19 23:18:04 +02:00
Wenzel Jakob
00a0aa9929 v2.4.0 release 2019-09-19 23:06:22 +02:00
Andre Schmeißer
19189b4c2c Make overload_cast_impl available in C++11 mode. (#1581)
* Make `overload_cast_impl` available in C++11 mode.

Narrow the scope of the `#if defined(PYBIND11_CPP14)` block around overload_cast to only
cover the parts where C++14 is stricly required. Thus, the implementation in
`pybind11::details::overload_cast_impl` is still available in C++11 mode.

* PR #1581: Modify test to use overload_cast_impl, update docs and change log
2019-08-19 12:54:33 +02:00
phil-zxx
c6b699d9c2 Added ability to convert from datetime.date to system_clock::time_point (#1848)
* Added ability to convert from Python datetime.date and datetime.time to C++ system_clock::time_point
2019-07-19 11:28:48 +02:00
Ian Bell
502ffe50a9 Add docs and tests for unary op on class (#1814) 2019-06-22 12:07:41 +02:00
Wenzel Jakob
64f2a5f8e6 begin work on v2.3.1 2019-06-12 21:03:40 +02:00
Wenzel Jakob
cf36e3d9ba updated changelog 2019-06-11 23:28:58 +02:00
Wenzel Jakob
51ca6b0832 Update docs on std::out_of_range exception mapping (#1254) 2019-06-11 23:28:58 +02:00
Chris Rusby
22859bb8fc Support more natural syntax for vector extend 2019-06-11 23:28:58 +02:00
Roland Dreier
7a24bcf1f6 Fix malformed reST (#1802)
Commit 2b045757b5 ("Improve documentation related to inheritance. (#1676)") left off
a ':' from a hyperlink, which breaks the Travis CI build.
2019-06-11 10:57:49 +02:00
Ivor Wanders
2b045757b5 Improve documentation related to inheritance. (#1676)
* Adds section to the reference.
* Adds section to advanced classes page describing how to use `get_overload`.
2019-06-10 22:12:28 +02:00
Manuel Schneider
492da592c2 another typo (#1675) 2019-06-10 22:05:12 +02:00
Darius Arnold
09330b94ea Fix typos in documentation (#1635)
* Always capitalize Eigen

* Fix spelling
2019-06-10 21:57:00 +02:00
Omar Awile
ac6cb91a34 Fixed small typo (#1633)
I think this particular method binding should not be done with `PYBIND11_OVERLOAD_PURE` but instead `PYBIND11_OVERLOAD`.
2019-06-10 21:56:17 +02:00
Sergei Izmailov
979d75de23 doc: Add note about casting from None to T* (#1760)
* doc: Add note about casting from `None` to `T*`

* doc: reword 'none-to-pointer' note message

* doc: mention opaque types in 'none-to-pointer' note message
2019-06-10 21:03:17 +02:00
nstelzen
c251434011 Added note in documentation regarding make install (#1801)
* Added note regarding make install
2019-06-10 16:35:36 +02:00
Wenzel Jakob
64205140bd added std::deque to overview.rst
[ci skip]
2018-11-16 06:46:48 +01:00
voxmea
17983e7425 Adds type_caster support for std::deque. (#1609)
* Adds std::deque to the types supported by list_caster in stl.h.
* Adds a new test_deque test in test_stl.{py,cpp}.
* Updates the documentation to include std::deque as a default
  supported type.
2018-11-16 06:45:19 +01:00
Ahuva Kroizer
8f5b7fce84 FAQ addition (#1606)
* Add possible solution to ImportError issue
2018-11-13 13:25:57 +01:00
Allan Leal
e76dff7751 Fix for Issue #1258 (#1298)
* Fix for Issue #1258

list_caster::load method will now check for a Python string and prevent its automatic conversion to a list.
This should fix the issue "pybind11/stl.h converts string to vector<string> #1258" (https://github.com/pybind/pybind11/issues/1258)

* Added tests for fix of issue #1258

* Changelog: stl string auto-conversion
2018-10-11 10:28:12 +02:00
Semen Yesylevskyy
ef13fb2e1c Info about inconsistent detection of Python version between pybind11 … (#1093)
* Info about inconsistent detection of Python version between pybind11 and CMake in FAQ
2018-09-12 00:20:56 +02:00
Wenzel Jakob
f4245181ae enum_: move most functionality to a non-template implementation
This commit addresses an inefficiency in how enums are created in
pybind11. Most of the enum_<> implementation is completely generic --
however, being a template class, it ended up instantiating vast amounts
of essentially identical code in larger projects with many enums.

This commit introduces a generic non-templated helper class that is
compatible with any kind of enumeration. enum_ then becomes a thin
wrapper around this new class.

The new enum_<> API is designed to be 100% compatible with the old one.
2018-09-11 22:08:26 +02:00
Wenzel Jakob
35c82c7250 changelog for version 2.2.4 & features targeted for 2.3.0 2018-09-11 10:41:30 +02:00
Jeff VanOss
01839dce8d remove duplicate feature from list (#1476) 2018-09-11 10:39:17 +02:00
Axel Huebl
435dbdd114 add_module: allow include as SYSTEM (#1416)
pybind11 headers passed via the `pybind11_add_module` CMake
function can now be included as `SYSTEM` includes (`-isystem`).

This allows to set stricter (or experimental) warnings in
calling projects that might throw otherwise in headers
a user of pybind11 can not influence.
2018-08-29 13:20:11 +02:00
Wenzel Jakob
d4b37a284a added py::ellipsis() method for slicing of multidimensional NumPy arrays
This PR adds a new py::ellipsis() method which can be used in
conjunction with NumPy's generalized slicing support. For instance,
the following is now valid (where "a" is a NumPy array):

py::array b = a[py::make_tuple(0, py::ellipsis(), 0)];
2018-08-28 23:22:55 +02:00
Boris Dalstein
b30734ee9f Fix typo in doc: build-in -> built-in 2018-07-17 11:28:15 -03:00
Thomas Hrabe
534b756cb3 Minor documentation clarification in numpy.rst (#1356) 2018-06-24 15:41:27 +02:00
Antony Lee
55dc131944 Clarify docs for functions taking bytes and not str. 2018-05-24 11:09:41 -03:00
François Becker
ce9d6e2c0d Fixed typo in classes.rst (#1388)
Fixed typos (erroneous `;`) in `classes.rst`.
2018-05-07 10:18:08 -03:00
luzpaz
4b874616b2 Misc. typos (#1384)
Found via `codespell`
2018-05-06 10:54:10 -03:00
Tom de Geus
a7ff616dfb Simplified example allowing more robust usage, fixed minor spelling issues 2018-05-06 10:48:54 -03:00
Wenzel Jakob
f5f6618962 updated changelog for v2.2.3 2018-04-29 15:47:13 +02:00
Lori A. Burns
bdbe8d0bde Enforces intel icpc >= 2017, fixes #1121 (#1363) 2018-04-29 13:48:25 +02:00
David Caron
307ea6b7fd Typo 2018-04-24 17:44:57 -03:00
oremanj
fd9bc8f54d Add basic support for tag-based static polymorphism (#1326)
* Add basic support for tag-based static polymorphism

Sometimes it is possible to look at a C++ object and know what its dynamic type is,
even if it doesn't use C++ polymorphism, because instances of the object and its
subclasses conform to some other mechanism for being self-describing; for example,
perhaps there's an enumerated "tag" or "kind" member in the base class that's always
set to an indication of the correct type. This might be done for performance reasons,
or to permit most-derived types to be trivially copyable. One of the most widely-known
examples is in LLVM: https://llvm.org/docs/HowToSetUpLLVMStyleRTTI.html

This PR permits pybind11 to be informed of such conventions via a new specializable
detail::polymorphic_type_hook<> template, which generalizes the previous logic for
determining the runtime type of an object based on C++ RTTI. Implementors provide
a way to map from a base class object to a const std::type_info* for the dynamic
type; pybind11 then uses this to ensure that casting a Base* to Python creates a
Python object that knows it's wrapping the appropriate sort of Derived.

There are a number of restrictions with this tag-based static polymorphism support
compared to pybind11's existing support for built-in C++ polymorphism:

- there is no support for this-pointer adjustment, so only single inheritance is permitted
- there is no way to make C++ code call new Python-provided subclasses
- when binding C++ classes that redefine a method in a subclass, the .def() must be
  repeated in the binding for Python to know about the update

But these are not much of an issue in practice in many cases, the impact on the
complexity of pybind11's innards is minimal and localized, and the support for
automatic downcasting improves usability a great deal.
2018-04-14 02:13:10 +02:00
Antony Lee
8fbb5594fd Clarify error_already_set documentation. 2018-04-09 16:25:04 -03:00
Boris Staletic
289e5d9cc2 Implement an enum_ property "name"
The property returns the enum_ value as a string.
For example:

>>> import module
>>> module.enum.VALUE
enum.VALUE
>>> str(module.enum.VALUE)
'enum.VALUE'
>>> module.enum.VALUE.name
'VALUE'

This is actually the equivalent of Boost.Python "name" property.
2018-04-07 19:11:35 -03:00
Patrik Huber
41a4fd8ae9 Fix missing word typo
I think that there's the word "for" missing for that sentence to be correct.
Please double-check that the sentence means what it's supposed to mean. :-)
2018-04-02 21:10:38 -03:00
Jason Rhinelander
e88656ab45 Improve macro type handling for types with commas
- PYBIND11_MAKE_OPAQUE now takes ... rather than a single argument and
  expands it with __VA_ARGS__; this lets templated, comma-containing
  types get through correctly.
- Adds a new macro PYBIND11_TYPE() that lets you pass the type into a
  macro as a single argument, such as:

      PYBIND11_OVERLOAD(PYBIND11_TYPE(R<1,2>), PYBIND11_TYPE(C<3,4>), func)

  Unfortunately this only works for one macro call: to forward the
  argument on to the next macro call (without the processor breaking it
  up again) requires also adding the PYBIND11_TYPE(...) to type macro
  arguments in the PYBIND11_OVERLOAD_... macro chain.
- updated the documentation with these two changes, and use them at a couple
  places in the test suite to test that they work.
2018-03-10 14:24:23 -04:00
Marc Schlaich
ab003dbdd9 Correct VS version in FAQ 2018-03-10 14:19:31 -04:00
Tomas Babej
01fada7674 Minor typo 2018-02-27 22:46:29 -04:00
Wenzel Jakob
2d0507db43 added v2.2.2 changelog 2018-02-07 11:05:41 +01:00
luz.paz
28cb6764fc misc. typos
Found via `codespell`
2018-01-11 16:39:50 -04:00
Bruce Merry
3b265787f2 Document using atexit for module destructors on PyPy (#1169)
None of the three currently recommended approaches works on PyPy, due to
it not garbage collecting things when you want it to. Added a note with
example showing how to get interpreter shutdown callbacks using the Python
atexit module.
2017-11-24 10:19:45 -04:00
Wenzel Jakob
e7d304fbc6
added citation reference (fixes #767) (#1189) 2017-11-17 18:44:20 +01:00
Wenzel Jakob
6d19036cb2
support docstrings in enum::value() (#1160) 2017-11-16 22:24:36 +01:00
Ted Drain
0a0758ce3a Added write only property functions for issue #1142 (#1144)
py::class_<T>'s `def_property` and `def_property_static` can now take a
`nullptr` as the getter to allow a write-only property to be established
(mirroring Python's `property()` built-in when `None` is given for the
getter).

This also updates properties to use the new nullptr constructor internally.
2017-11-07 12:35:27 -04:00
Unknown
0b3f44ebdf Trivial typos
Non-user facing. 
Found using `codespell -q 3`
2017-11-01 22:48:36 -03:00
Ansgar Burchardt
a22dd2d1df correct stride in matrix example and test
This also matches the Eigen example for the row-major case.

This also enhances one of the tests to trigger a failure (and fixes it in the PR).  (This isn't really a flaw in pybind itself, but rather fixes wrong code in the test code and docs).
2017-09-21 18:07:48 -03:00
Dean Moldovan
56613945ae Use semi-constexpr signatures on MSVC
MSCV does not allow `&typeid(T)` in constexpr contexts, but the string
part of the type signature can still be constexpr. In order to avoid
`typeid` as long as possible, `descr` is modified to collect type
information as template parameters instead of constexpr `typeid`.
The actual `std::type_info` pointers are only collected in the end,
as a `constexpr` (gcc/clang) or regular (MSVC) function call.

Not only does it significantly reduce binary size on MSVC, gcc/clang
benefit a little bit as well, since they can skip some intermediate
`std::type_info*` arrays.
2017-09-16 12:02:49 +02:00
Wenzel Jakob
f94d759881 updated changelog for v2.2.1 release 2017-09-14 08:51:30 +02:00
Dean Moldovan
27680302dd Update changelog for v2.2.1 release 2017-09-13 19:04:25 +02:00
jbarlow83
9f82370e48 docs: Describe importing Python modules and Python methods (#1079)
* Expand documentation to include explicit example of py::module::import 
  where one would expect it.

* Describe how to use unbound and bound methods to class Python classes.

[skip ci]
2017-09-13 16:18:08 +02:00
Dean Moldovan
2b4477eb65 Make TypeErrors more informative when an optional header is missing
E.g. trying to convert a `list` to a `std::vector<int>` without
including <pybind11/stl.h> will now raise an error with a note that
suggests checking the headers.

The note is only appended if `std::` is found in the function
signature. This should only be the case when a header is missing.
E.g. when stl.h is included, the signature would contain `List[int]`
instead of `std::vector<int>` while using stl_bind.h would produce
something like `MyVector`. Similarly for `std::map`/`Dict`, `complex`,
`std::function`/`Callable`, etc.

There's a possibility for false positives, but it's pretty low.
2017-09-12 08:06:46 +02:00
Gunnar Läthén
c64e6b1670 Added function for reloading module (#1040) 2017-09-12 08:05:05 +02:00
Dean Moldovan
953d2422b3 Fix a reference leak in the number converter (#1078)
Fixes #1075.

`PyNumber_Float()` and `PyNumber_Long()` return new references.
2017-09-10 16:53:02 +02:00
Dean Moldovan
7b1de1e551 Fix nullptr dereference when loading an external-only module_local type 2017-09-10 12:28:03 +02:00
Dean Moldovan
3c4933cb50 Fix STL casters for containers with proxies (regression)
To avoid an ODR violation in the test suite while testing
both `stl.h` and `std_bind.h` with `std::vector<bool>`,
the `py::bind_vector<std::vector<bool>>` test is moved to
the secondary module (which does not include `stl.h`).
2017-09-10 12:25:10 +02:00
Dean Moldovan
b0a0e4a23c Fix compilation with Clang on host GCC < 5 (old libstdc++) 2017-09-08 12:48:14 +02:00
Dean Moldovan
0991d7fba1 Remove deprecated placement-new constructor from docs
[skip ci]
2017-09-07 15:02:16 +02:00