Commit Graph

494 Commits

Author SHA1 Message Date
David Hewitt bb6d4df497 multiple-pymethods: documentation updates 2021-03-04 23:03:26 +00:00
David Hewitt 977735db20 pymethods: make inventory optional 2021-03-04 19:52:58 +00:00
David Hewitt 1dcda8809d docs: deny warnings in ci 2021-03-04 19:41:11 +00:00
Georg Brandl e065f9b517 PyModule: rename call* to call_function*
For consistency with PyObject/PyAny, where call() means to call the
object itself.
2021-03-04 09:29:28 +01:00
konstin 7dfb4c353d Update setuptools-rust/maturin comparison
I tried to make differences clearer and make it a bit less biased towards maturin
2021-03-03 11:40:21 +01:00
David Hewitt a7528ee690
guide: correct documentation on default features 2021-02-27 14:55:40 +00:00
David Hewitt c4bd9335fc
Merge pull request #1446 from davidhewitt/no-pyproto-inventory
pyproto: don't use inventory for methods
2021-02-26 09:09:23 +00:00
David Hewitt aa2855b6a0 pyproto: don't use inventory for methods 2021-02-25 00:17:22 +00:00
David Hewitt 9e4e0dbbe0 auto-initialize: remove from default features 2021-02-22 22:34:34 +00:00
David Hewitt 1e134aa0de pyclass-impl: use impl Trait arguments
Co-authored-by: Yuji Kanagawa <yuji.kngw.80s.revive@gmail.com>
2021-02-19 07:45:14 +00:00
David Hewitt 7b99e391fa pyclass-impl: merge implementation traits 2021-02-18 08:19:07 +00:00
kangalioo fe9b4625d1 Implement conversions for Path/PathBuf 2021-02-13 20:22:16 +00:00
Andrew J Westlake db3668898a Updated guide after merging attributes branch into pyo3-asyncio 2021-02-09 18:26:14 -06:00
Andrew J Westlake 80d4c5b3ad rebased on #1401 2021-02-08 22:43:21 +00:00
Andrew J Westlake 411e97643a Changed overview paragraphs at the top, added some of my own changes to (hopefully) improve the flow 2021-02-08 22:43:21 +00:00
Andrew J Westlake e1b2bd20d0 Added sleep in the initialization example as suggested 2021-02-08 22:43:21 +00:00
Andrew J Westlake bc87c57f7c Updated guide to address some issues brought up in the PR 2021-02-08 22:43:21 +00:00
Andrew J Westlake 3b82cf475a Changed instance of Asyncio to `asyncio`
Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2021-02-08 22:43:21 +00:00
Andrew J Westlake b4f338c68d Update guide/src/async-await.md
Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2021-02-08 22:43:21 +00:00
Andrew J Westlake 8140dc99ec Fixed typo in README, flattened sections in Cargo Test portion of guide 2021-02-08 22:43:01 +00:00
Andrew J Westlake 946460caeb Added async/await example to the guide, added pyo3-asyncio to list of tools and libraries 2021-02-08 22:41:42 +00:00
David Hewitt 0a7aee14fe guide: organise more chapters into sublevels 2021-01-26 22:09:02 +00:00
David Hewitt dc7bcdaf9b gil: move finalization from prepare_freethreaded_python to
with_embedded_python_interpreter
2021-01-12 07:44:37 +00:00
David Hewitt 7c61c9b7f9 gil: tidy ups to finalization 2021-01-12 07:42:47 +00:00
Daniil Konovalenko abb5829e9c implement Serialize, Deserialize for Py<T> 2021-01-11 22:19:10 +00:00
David Hewitt a8d8003b31 guide: document PYO3_NO_PYTHON on Windows 2021-01-10 10:16:37 +00:00
Auke Willem Oosterhoff c1c4a5ffa5 readme/faq: document `rlib` crate type better 2021-01-06 06:54:44 +00:00
David Hewitt 8e37d378b5
Merge pull request #1347 from davidhewitt/embedding
auto-initialize: new feature to control initializing Python
2021-01-04 21:31:22 +00:00
David Hewitt e0c35d17dd auto-initialize: add CHANGELOG and docs 2021-01-04 21:08:08 +00:00
Daniil Konovalenko 74a8b3257d
Fix #[pyclass] arguments description 2021-01-02 19:03:29 +03:00
David Hewitt a350dd2c20 build: make include dir optional when targeting Windows 2020-12-31 22:02:29 +00:00
David Hewitt 7572962828 abi3: add support for dict and weakref from Python 3.9 2020-12-28 10:22:46 +00:00
David Hewitt 26ca1f5bca Release 0.13 2020-12-22 15:42:04 +00:00
David Hewitt 9e7fa408d4 pyproto: use buffer slots on Python 3.9 and up 2020-12-22 13:33:42 +00:00
David Hewitt 4e650d939d pyproto: remove inventory from implementation 2020-12-20 10:01:30 +00:00
David Hewitt a689ab42c6 macros: rename crates for consistency 2020-12-20 06:39:28 +00:00
David Hewitt 3d6356223e docs: fix warnings 2020-12-18 23:11:10 +00:00
Alex Gaynor 3edd961fa3 Clearly document the limitations of abi3
closes #1288
2020-12-13 10:26:37 -05:00
Yuji Kanagawa 9aa70f7c89
Merge pull request #1263 from PyO3/abi3-min-python
Add abi3-py* features
2020-12-08 12:52:00 +09:00
kngwyu 49143724d5 Rename PYO3_NO_INTERPRETER by PYO3_NO_PYTHON 2020-12-07 17:30:04 +09:00
Yuji Kanagawa 6da6bc9461
Apply suggestions from @davidhewitt
Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2020-12-06 16:06:10 +09:00
kngwyu 1b838504b7 Introduce PYO3_NO_INTERPRETER variable for build script 2020-12-01 23:40:49 +09:00
Patrick Chieppe bba1cf19b3 Add section about Python::check_signals to the FAQ 2020-11-30 11:38:40 +11:00
David Hewitt fc34e41163 pyany: add is_instance 2020-11-22 19:24:59 +00:00
kngwyu 93282e9a70 Note abi3-py* features in the guide and Add CHANGELOG 2020-11-16 00:47:24 +09:00
David Hewitt 9617edfca9 msrv: bump to 1.45 2020-11-12 11:33:08 +00:00
Yuji Kanagawa 3b3ba4e3ab
Merge pull request #1152 from PyO3/abi3
Complete abi3 support
2020-10-27 23:30:36 +09:00
kngwyu eb0e6f6b55 Note the minimum required version of maturin supporting abi3 2020-10-27 13:19:01 +09:00
kngwyu 6627658127 Renew proc-macros for new `#[pyproto]` backend 2020-10-21 01:29:28 +09:00
Alex Gaynor ba6f0ecdfa Merge branch 'master' into abi3-merge-master 2020-10-18 10:47:06 -04:00
David Hewitt 84b893b261 guide: improve "calling Python from Rust" section 2020-10-18 10:08:11 +01:00
David Hewitt 27f2d0ee3b
Merge pull request #1212 from Askaholic/issue/#1055-add-arg-name-to-conversion-error
Enhance error messages of conversion errors
2020-10-18 09:15:42 +01:00
David Hewitt 4a916eb3ed
guide: fix broken link 2020-10-16 09:00:46 +01:00
Askaholic 6724783395
Change wording of PyDowncastError display implementation
Displays type(obj) instead of repr(obj) and uses `cannot` instead of
`can't`
to be more consistent with existing python error messages.

See discussion at #1212.
2020-10-14 17:32:00 -08:00
Alex Gaynor 9e34835b76 Merge branch 'master' into abi3-merge-master 2020-10-12 18:03:14 -04:00
Alex Gaynor aabad7cf7f Assorted updates to the abi3 branch from review 2020-10-11 19:51:27 -04:00
Alex Gaynor 877667a1c6 Improved documentation 2020-10-11 15:18:05 -04:00
Alex Gaynor 140790b15f Merge branch 'master' into abi3-merge-master 2020-10-10 10:11:49 -04:00
David Hewitt 23d9d259a7 migration guide: tiny typo fix 2020-10-10 06:24:57 +01:00
kngwyu 41c2f5a748 Use &'static CStr for representing method names and docs 2020-10-08 17:26:55 +09:00
Alex Gaynor e615ce8c05 Start documenting abi3 support 2020-09-23 18:42:49 -04:00
kngwyu 1985578bb7 Don't compile extends=PyDict test in class.md with abi3 2020-09-20 16:20:08 +09:00
Sebastian Pütz 0a346dfa7c Add documentation for raw_pycfuntion 2020-09-17 09:47:53 +02:00
Alex Gaynor ba1056006a Get all the tests building, everythign except doctests passes! 2020-09-16 08:42:22 -04:00
Alex Gaynor 5bfb4674b1 Merge branch 'master' into abi3-merge-master 2020-09-10 17:01:13 -04:00
David Hewitt 151af7a0b7
Merge pull request #1115 from davidhewitt/std-py-err
Implement std::error::Error for PyErr
2020-09-10 21:17:11 +01:00
David Hewitt 73507dbf5e
Merge pull request #1163 from sebpuetz/pyfunction
Add native Function types.
2020-09-10 19:05:57 +01:00
David Hewitt b9e95dc7c9 Implement std::error::Error for PyErr 2020-09-10 19:04:24 +01:00
kngwyu 7a4c5e2960 Merge branch 'master' into abi3 2020-09-10 00:48:20 +09:00
Sebastian Pütz 22881a3c2f Change add_function, ensure static docstrings.
Change add_function to take `&PyCFunction` instead of a wrapper
fn and ensure that dostrings of functions are `&'static str`.
2020-09-09 12:37:37 +02:00
Alex Gaynor 117f60bed0 Make PyType::name abi3 compatible
The implementation is more complex, because there's no equivalent to tp_name in the limited API
2020-09-08 12:22:59 -04:00
David Hewitt 16fe583b82
Merge pull request #1143 from sebpuetz/pyfunction-modules
PyModule in #[pyfunction]
2020-09-06 20:55:29 +01:00
David Hewitt a1d6c7a838
Merge pull request #1157 from davidhewitt/conversion-detail
docs: add detail to wrapper type conversions
2020-09-06 20:52:34 +01:00
David Hewitt 192c2c2b2c docs: add detail to wrapper type conversions 2020-09-06 10:21:08 +01:00
Sebastian Pütz 64b06ea9ec Change `add_submodule()` to take `&PyModule`.
The C-exported wrapper generated through `#[pymodule]` is only
required for the top-level module.
2020-09-05 15:54:57 +02:00
David Hewitt 2b0b853912 Add CHANGELOG to the guide 2020-09-05 14:44:39 +01:00
Sebastian Pütz 06cd7c7d5a Fix some more docs. 2020-09-05 11:24:12 +02:00
Sebastian Pütz e65b849ab6 Doc fixes, changelog and rename. 2020-09-05 10:20:22 +02:00
Sebastian Pütz 9137855e81 Add documentation for accessing PyModule in #[pyfunction]s. 2020-09-04 10:02:40 +02:00
Sebastian Pütz 4aae523e54 Rename add_module to add_submodule, documentation fixes. 2020-09-04 09:02:49 +02:00
Sebastian Pütz 3214249010 Make python function wrapper creation fallible.
Wrapping a function can fail if we can't get the module name.

Based on suggestion by @kngwyu
2020-09-03 15:48:32 +02:00
Sebastian Pütz 5bbca1a052 Set the module of `#[pyfunction]`s.
Previously neither the module nor the name of the module of
pyfunctions were registered. This commit passes the module and
its name when creating a new pyfunction.

PyModule::add_function and PyModule::add_module have been added and are
set to replace `add_wrapped` in a future release. `add_wrapped` is kept
for compatibility reasons during the transition.

Depending on whether a `PyModule` or `Python` is the argument for the
Python function-wrapper, the module will be registered with the function.
2020-09-03 14:49:28 +02:00
Alex Gaynor 400462063d Proof of concept of using PEP384s PyType_Spec 2020-09-02 16:54:39 -04:00
David Hewitt 81afdaf6cd Start splitting long guide pages into subchapters 2020-09-01 22:44:27 +01:00
David Hewitt f0650ebd94 Add doc for extracting Union via FromPyObject 2020-09-01 22:04:57 +01:00
Yuji Kanagawa 729f2f42e7
Merge pull request #1065 from sebpuetz/union
FromPyObject derivation for structs and enums
2020-08-31 21:28:49 +09:00
Sebastian Pütz 0f32f886b8 More FromPyObject derive suggestions by @davidhewitt 2020-08-30 19:16:59 +02:00
David Hewitt 21cdb8ab7e Add introduction to guide 2020-08-30 13:03:28 +01:00
Sebastian Pütz 53a858c5c1 Add documentation for FromPyObject derivation. 2020-08-30 13:35:06 +02:00
Mario 608aea726c
Allow other Result types in `#[pyfunction]` (#1118)
* Added a couple basic tests

* Implemented suggested change

* Fixed type inference

* cargo fmt

* Finished tests and removed warnings

* Include in CHANGELOG.md

* Moved test into separate file

* &'static str and function rename

* Mention in the book
2020-08-29 08:25:20 +01:00
David Hewitt 16ef96904a
Merge pull request #1114 from mtreinish/hashbrown
Add optional support for conversion from Hashbrown types
2020-08-26 12:48:21 +01:00
Matthew Treinish 659d24e1a9
Add CHANGELOG entry and update conversions guide 2020-08-26 06:37:02 -04:00
David Hewitt 37d23da7d5 Add link to Bazel rules 2020-08-25 23:02:20 +01:00
Rene Leveille 441d7f52b1 apply symlink use case, change variable name 2020-08-19 12:11:14 -04:00
Rene Leveille 7beb272075 find within general lib dir, with new optional env variable 2020-08-18 22:05:29 -04:00
Rene Leveille 5dc907bc5d apply suggestions from review 2020-08-17 18:14:05 -04:00
Rene Leveille 0cd1e5bf19 change documentation 2020-08-17 15:17:34 -04:00
Rene Leveille aef159d4ee appy suggestions from PR 2020-08-17 11:26:30 -04:00
David Hewitt 565e36d989
Merge pull request #1098 from davidhewitt/py-as-into-ref
Py::as_ref and Py::into_ref (remove AsPyRef)
2020-08-11 20:44:53 +01:00
Yuji Kanagawa b17d4fffe2
Merge pull request #1093 from kngwyu/iterator-example
Improve lifetime insertions for #[pyproto]
2020-08-11 18:16:53 +09:00
David Hewitt 6b3c6fdeee Improve docs for Py::as_ref() and Py::into_ref()
Co-authored-by: Georg Brandl <georg@python.org>
2020-08-11 08:36:31 +01:00
Georg Brandl 4467cf51db guide: show exporting create_exception! exceptions in a module 2020-08-10 17:08:52 +02:00
Yuji Kanagawa c4d9ab227e
Merge branch 'master' into iterator-example 2020-08-10 17:11:00 +09:00
kngwyu 093dda375f Improve lifetime insertions for #[pyproto] 2020-08-10 15:18:16 +09:00
David Hewitt 7d0b3b386a Add Py::into_ref 2020-08-09 23:00:34 +01:00
David Hewitt 77ed6d6d69 Remove AsPyRef for just Py::as_ref 2020-08-09 22:47:54 +01:00
David Hewitt 20959ecc92 Rewrite documentation for FromPy and PyObject changes 2020-08-09 12:29:25 +01:00
David Hewitt c44697cd31 Prefer docs.rs doc links 2020-08-08 23:54:11 +01:00
David Hewitt 1f37dbc1a7 Various fixes to edge cases with GILGuard 2020-08-06 14:32:59 +01:00
David Hewitt dc5c2a9b8f Rename PYTHON_SYS_EXECUTABLE to PYO3_PYTHON 2020-08-06 13:27:20 +01:00
Manuel Vázquez Acosta f2ba3e6da7
#1064: Comparisons with __eq__ should not raise TypeError (#1072)
* Add (failing) tests for issue #1064

* Return NotImplemented when richcmp doesn't match the expected type.

* Fix tests that expect TypeError when richcmp returns NotImplemented.

- The python code 'class Other: pass; c2 {} Other()' was raising a NameError:
  c2 not found

- eq and ne never raise a TypeError, so I split the those cases.

* Return NotImplemented for number-like binary operations.

* Add dummy impl PyNumberProtocol for the test struct.

* Rework tests of NotImplemented.

* Make py_ternary_num_func return NotImplemented when type mismatches.

* Return NotImplement for type mismatches in binary inplace operators.

* Reduce boilerplate with `extract_or_return_not_implemented!`

* Extract common definition 'Other' into a function.

* Test explicitly for NotImplemented in the __ipow__ test.

* Add entry in CHANGELOG for PR #1072.

* Add the section 'Emulating numeric types' to the guide.

* Ensure we're returning NotImplemented in tests.

* Simplify the tests: only test we return NotImplemented.

Our previous test were rather indirect: were relying that Python
behaves correctly when we return NotImplemented.

Now we only test that calling a pyclass dunder method returns NotImplemented
when the argument doesn't match the type signature.  This is the expected
behavior.

* Remove reverse operators in tests of NotImplemented

The won't be used because of #844.

* Apply suggestions from code review

Co-authored-by: Yuji Kanagawa <yuji.kngw.80s.revive@gmail.com>

* Add a note about #844 below the list of reflected operations.

Co-authored-by: Yuji Kanagawa <yuji.kngw.80s.revive@gmail.com>
2020-08-05 22:53:16 +09:00
Michal 'vorner' Vaner e6dd2d980f
docs: Link to pyo3-log in README and the guide
Show how one can log from Rust through the Python's logging facilities.

Related to #1016.
2020-07-19 22:01:22 +02:00
David Hewitt 4ed9748b45 Rename exceptions to PyException etc; reintroduce deprecated ones 2020-07-18 06:02:57 +01:00
David Hewitt a7e0c6bfa7 Make exceptions proper native types. 2020-07-18 01:57:39 +01:00
David Hewitt 4020e4d0c8 Add `Python::with_gil` 2020-07-13 22:37:40 +01:00
David Hewitt 85f1d009ec Add introduction to class.md 2020-07-01 07:44:37 +01:00
konstin 9251748280 Update maturin/setuptools-rust section 2020-06-30 14:20:50 +02:00
kngwyu 6cbe9ff30d Bump version to 0.11.1 2020-06-30 14:53:55 +09:00
kngwyu d76fe7835a Introduce #[pyclass(unsendable)] 2020-06-30 12:30:17 +09:00
David Hewitt f89e9e0eb1 Write migration guide for 0.11 2020-06-27 23:59:44 +09:00
kngwyu fd94a0d55c Bump version to 0.11.0 2020-06-27 23:59:44 +09:00
Yuji Kanagawa e35622b941
Merge pull request #997 from davidhewitt/pyproto-next-return
Add __next__ return
2020-06-24 23:16:35 +09:00
scalexm f5e1dff7eb Update docs now that recursive `#[classattr]` are allowed again 2020-06-23 22:41:23 +02:00
David Hewitt 9f9137c6e4 Add ability to return from `__next__` / `__anext__` 2020-06-23 15:26:28 +01:00
David Hewitt a9c7e12be0 Allow skipping the return type completely for `#[pyproto]` methods returning `()`. 2020-06-23 11:51:02 +01:00
David Hewitt 0c59b05e1f
Merge pull request #996 from davidhewitt/pyproto-simplifications
Refactor `#[pyproto]` Result types
2020-06-23 11:49:39 +01:00
David Hewitt c7a4b4770f Refactor `#[pyproto]` Result types 2020-06-23 11:08:36 +01:00
scalexm 863c0001e1 `LazyStaticType::get_or_init` returns an `*mut` instead of a `&` ref 2020-06-22 22:37:11 +02:00
David Hewitt 646dd19a49 Move cargo test guidelines to faq 2020-06-21 09:18:27 +01:00
Yuji Kanagawa 7075827a03
Merge pull request #969 from PyO3/poc-stable-rust
Stable Rust
2020-06-21 16:54:59 +09:00
kngwyu 404f3981e5 Improve docs and Remove all-stable feature 2020-06-21 16:10:19 +09:00
kngwyu a63e426f6f Some doc and test cleanups mainly around specialization 2020-06-20 12:59:56 +09:00
kngwyu e27c4d75c9 Add a document about nightly feature 2020-06-19 14:50:48 +09:00
David Hewitt a1dbfa8c8c Add pyo3::once_cell::GILOnceCell 2020-06-18 18:53:32 +01:00
konstin 3180e5cc06 POC stable rust (2 tests failing) 2020-06-18 17:21:09 +09:00
Yuji Kanagawa a044f3c322
Merge branch 'master' into slot-provider 2020-06-18 15:49:56 +09:00
Nateckert 4f8c2e767b
Doc trait exposition (#964)
Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2020-06-15 09:58:37 +01:00
David Hewitt f58398d6e3
Rewrite sentence one last time 2020-06-13 08:15:30 +01:00
David Hewitt e73d696f8c
Clarify wording in guide 2020-06-13 08:12:21 +01:00
kngwyu ac2c51c774 Fix typo and revert unintended changes 2020-06-13 15:25:04 +09:00
kngwyu d678093509 Remove specialization from async/sequence methods 2020-06-13 15:25:04 +09:00
David 33617bfffc Require Send for #[pyclass] 2020-06-08 02:06:15 +01:00
Alexander Niederbühl 75d44ca296 Remove getting started chapter from user guide
Since it's exactly the same content as in the README.
2020-06-07 00:26:17 +02:00
Alexander Niederbühl bbf1c39cea Address review comments 2020-06-05 21:24:03 +02:00
Alexander Niederbühl eca93c3ff8 Ignore doctests 2020-06-05 21:02:52 +02:00
Alexander Niederbühl e38a077c29 Fix typos 2020-06-05 20:54:38 +02:00
Alexander Niederbühl cbe3e574b7 Rewrite parallelism chapter in guide 2020-06-05 20:25:07 +02:00
Alexander Niederbühl eadd7b1081 Remove word-count from examples 2020-06-05 16:40:29 +02:00
David Hewitt 29c93c87c7 Remove GetPropertyValue 2020-05-21 18:06:24 +01:00
Yuji Kanagawa 7fd35b2fb6
Merge pull request #937 from davidhewitt/doc-conversion-table
Add conversion table to guide
2020-05-21 16:18:46 +09:00