Commit Graph

899 Commits

Author SHA1 Message Date
David Hewitt e1d4173827 Fix bug in default implementation of `__ne__` 2023-10-11 09:48:06 +01:00
David Hewitt f335f42197
Merge pull request #3446 from davidhewitt/relax-import-check
relax multiple-import check to only prevent subinterpreters
2023-09-29 16:35:31 +00:00
SigureMo 25b2acb0eb
fix some dead links 2023-09-29 13:24:00 +08:00
David Hewitt f17e703167 return existing module on Python 3.9 and up 2023-09-23 11:13:39 +01:00
Jeff Schwab 535a255bae Fix a typo in a documentation page title 2023-09-21 21:11:27 +01:00
David Hewitt bcb01049cc
Merge pull request #3404 from davidhewitt/fix-dealloc
call PyObject_GC_Untrack before deallocating
2023-09-11 05:18:34 +00:00
David Hewitt e28403e772 call PyObject_GC_Untrack before deallocating 2023-09-09 22:29:58 +01:00
David Hewitt c7f834ad87 add migration guide entry for `PyDict::get_item` 2023-09-09 13:05:51 +01:00
Julian Hofer 6e24fb6643 guide: Add `playground.runnable` = false to book.toml 2023-09-05 22:28:43 +02:00
David Hewitt e67b283b25
Merge pull request #3358 from alex/ptr-unsafe-trait
fixes #3325 -- mark `AsPyPointer` as `unsafe trait`
2023-09-04 05:05:56 +00:00
David Hewitt 4c46d81afd simplify thread checker implementation 2023-09-03 14:15:26 +01:00
David Hewitt cc1aa598cd
Merge pull request #3411 from OliverFM/main
Update docs with fresher bazel example
2023-08-29 06:17:51 +00:00
oliver 9714f819f0 Update docs with fresher bazel example 2023-08-29 06:44:22 +01:00
Shahriar Heidrich 2855b9d508 Mention no subclassing of Python classes in docs 2023-08-28 12:34:13 +02:00
Alex Gaynor df5aa77800
fixes #3325 -- mark `AsPyPointer` as `unsafe trait` 2023-08-18 10:16:34 -04:00
Adam Reichold 9363491d54
Merge pull request #3384 from DataTriny/pyclass_rename_variants
Add  `rename_all` attribute to `#[pyclass]`
2023-08-16 19:06:37 +00:00
DataTriny f02fe9478d
Make rename_all accept a renaming rule, allow applying it to classes as well 2023-08-15 10:15:48 +02:00
David Hewitt 5ad55d2dc7 Revert "Fix typos and other minor touchups to guide"
This reverts commit 24eee46128.
2023-08-15 08:55:41 +01:00
Alex Gaynor 5061b501a9
Remove IntoPyPointer
it wasn't used in any public APIs following #3359
2023-08-14 16:28:20 -04:00
DataTriny a9e9ec628d
Add attribute to 2023-08-13 18:25:07 +02:00
David Hewitt 64adab1a76 add as_ptr and into_ptr inherent methods 2023-08-11 10:49:42 +01:00
Tpt 1e5a49557d Makes PathBuf FromPyObject implementation work on all os.PathLike
PyOS_FSPath is in abi3-py36
2023-08-08 22:15:56 +02:00
CallMeMSL 5bcb513add
Update outdated link in python_typing_hints.md and fix typos 2023-07-14 15:50:14 +02:00
Pan Piłkarz f3d7cf6fac
Tiny grammar fix in error_handling.md 2023-07-12 15:51:18 +02:00
Adam Reichold 89b9bc384a
Merge pull request #3304 from PyO3/guide-perf-section
Start adding a performance section to the guide.
2023-07-11 19:36:56 +00:00
mejrs 092b73aa48 Two is not three 2023-07-11 13:56:34 +02:00
Adam Reichold bedb682d0e Add another performance subsection on implicit access to GIL token. 2023-07-09 15:02:12 +02:00
Adam Reichold ff78b92e77 Start adding a performance section to the guide. 2023-07-09 14:32:59 +02:00
David Hewitt 23d1a6d307 add some missing type conversions to the guide 2023-07-03 21:36:17 +01:00
Alex Gaynor 0b78bb851e
Allow `#[new]` to return existing instances
fixes #2384
2023-07-02 19:57:53 -04:00
CallMeMSL 23bdd4337f
Fix typos and add punctuation recommended by grammarly in Class.md 2023-06-28 13:46:13 +02:00
Luca Trevisani de9d760462
Add conversions between Rust Path/PathBuf and Python str / pathlib.Path 2023-06-25 20:40:51 +02:00
Adam Reichold 684002daf5 Format recently modified code example from the guide. 2023-06-16 12:46:26 +02:00
Adam Reichold 2996f92ade Extend guide section on classes regarding free functions
It might not be obvious from the reading the sections on free functions and on
classes that they combine in a frictionless manner, i.e. class instances can be
parameters to free functions in the same manner that the self parameters of
instance methods are handled.

This also explicitly calls out the interaction between `Clone` and
`FromPyObject` for classes.
2023-06-16 08:44:34 +02:00
Adam Reichold a0c85bb649
Merge pull request #3240 from davidhewitt/maturin-versions
bump maturin version in example files
2023-06-14 08:24:31 +00:00
David Hewitt 5fd5dcba44 bump maturin version in example files 2023-06-14 08:45:32 +01:00
David Hewitt 4f3fcdbf0f remove all functionality deprecated in PyO3 0.18 2023-06-13 22:27:43 +01:00
Adam Reichold 0d30bb7d3d Bump Rust edition to 2021 and make current Clippy happy. 2023-06-07 21:15:38 +02:00
bors[bot] dbf7b233aa
Merge #3203
3203: support ordering magic methods for `#[pyclass]` r=adamreichold a=davidhewitt

Closes #2089 

This adds `__lt__`, `__le__`, `__eq__`, `__ne__`, `__gt__`, and `__ge__` as per the Python implementations of what we call `__richcmp__`.

There's a UI test confirming that the user cannot implement split forms and `__richcmp__` simultaneously.

There's also a benchmark comparing implementing these split methods against using `__richcmp__`. I couldn't see a meaningful performance difference, so I'm tempted to deprecate `__richcmp__`, given that's not a magic method which exists in Python. Potentially we can provide options such as the opt-in `#[pyclass(eq, ord)]` to avoid boilerplate for people who don't want to implement six different methods.



Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2023-06-05 07:13:23 +00:00
Adam Reichold 5738edfdd4 Bump MSRV to 1.56 2023-06-04 23:02:30 +01:00
David Hewitt 8850d5d384 support ordering magic methods for `#[pyclass]` 2023-06-04 13:58:18 +01:00
David Hewitt 2500e22e13 release: 0.19.0 2023-05-31 13:53:37 +01:00
Adam Reichold 810ad00a76 Do not apply deferred ref count updates and prevent the GIL from being acquired inside of implementations. 2023-05-25 20:01:35 +02:00
David Hewitt 248230b8e4 refactor PyAny::is_instance_of for performance 2023-05-18 22:25:27 +01:00
Adam Reichold b9766cfa11 Add PyClass::get and Py::get for GIL-independent access to frozen classes. 2023-05-18 08:57:55 +02:00
Stu Hood 20c5618160
Add support for combining the `#[new]` and `#[classmethod]` method types. 2023-05-16 15:51:14 -07:00
bors[bot] 633b592ed5
Merge #2593
2593: docs: mention PyBuffer r=adamreichold a=davidhewitt

Uses PEP 688 `types.Buffer` to describe `PyBuffer<T>` in the conversion tables. Will leave as draft until PEP 688 is finalised.

Closes #954 

Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
Co-authored-by: Adam Reichold <adam.reichold@t-online.de>
2023-05-09 20:24:37 +00:00
David Hewitt 7c231a2372 docs: mention PyBuffer 2023-05-09 19:53:39 +01:00
Adrien 1676100dfd Added a few lines to document the main difference between maturin and setuptools-rust as far as building manylinux-compliant wheels is concerned.
Added newfragment
2023-05-09 14:54:30 +02:00
David Hewitt dd24c9ea71 remove `Python::acquire_gil` 2023-05-09 09:39:23 +02:00
Adam Reichold 3c634dd9a9 Add migration guide entry on replacing acquire_gil by with_gil. 2023-05-09 09:39:23 +02:00
BlueGlassBlock fdd43d0685 feat: unwrap dyn Err when inner is simple PyErr 2023-05-09 07:17:10 +01:00
bors[bot] 1cdac4fde4
Merge #2980
2980: support `text_signature` on `#[new]` r=adamreichold a=davidhewitt

Closes #2866 

This is a breaking change for 0.19.0, because it starts autogenerating `text_signature` for `#[new]`. This could affect runtime behaviour if the user is relying on the class docs at runtime for some reason.

Guide & tests all updated accordingly.

`#[pyclass(text_signature = "...")]` is deprecated by this PR, however if it's set, it will be used in preference to `#[new]`.

(The signature / `text_signature` from `#[new]` will simply be ignored in this case. I figure that when users fix their deprecation warnings by removing `#[pyclass(text_signature = "...")]` then the `#[new]` signatures will start flowing properly, and this is good enough.)

Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
Co-authored-by: Adam Reichold <adam.reichold@t-online.de>
2023-05-04 16:51:54 +00:00
bors[bot] 6356acb2f9
Merge #3120
3120: feat: add #[pyo3(from_item_all)] for FromPyObject r=davidhewitt a=BlueGlassBlock

This PR addresses #3112 by implementing ~~`#[pyo3(item_all)]`~~ `#[pyo3(from_item_all)]`.

Co-authored-by: BlueGlassBlock <blueglassblock@outlook.com>
2023-05-04 07:10:21 +00:00
David Hewitt 8bd17f02c7 support `text_signature` on `#[new]` 2023-05-04 07:15:11 +01:00
cfour2 559b540b5c Fix a crate doc link for IterNextOutput 2023-05-02 15:05:53 +08:00
BlueGlassBlock 1d6ab21781
fix: change to from_item_all 2023-04-26 19:47:07 +08:00
BlueGlassBlock 30b2ed1d85
feat: add #[pyo3(item_all)] for FromPyObject 2023-04-25 19:37:05 +08:00
xcharleslin 512847257e
Fix crate docs links in python_from_rust.md 2023-04-24 15:21:08 -07:00
Walnut 24ab144a41
minor grammar fix in documentation 2023-04-23 02:05:51 -05:00
Doug Goldstein 8e0bde14c9 implement Decimal to rust_decimal conversions
Implement conversion between rust_decimal::Decimal and decimal.Decimal
from Python's stdlib. The C API does not appear to be exposed on the
Python side so we need to call into it via Python.
2023-04-22 19:55:21 +02:00
Jonathan Daniel 3a9c6b175d
Update getting_started.md
Update Poetry command to Poetry groups syntax (1.2+).
https://python-poetry.org/docs/cli/#options-4
2023-04-21 23:19:57 +03:00
bors[bot] a0e285b497
Merge #3066 #3098
3066: Improve default value for `None` in `text_signature` r=davidhewitt a=messense

xref #2863

3098: readme: add new pyo3 article r=adamreichold a=davidhewitt

With thanks to `@ohadravid` for the great piece!

Co-authored-by: messense <messense@icloud.com>
Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2023-04-12 07:40:50 +00:00
David Hewitt 80d95f9134 docs: fix migration guide entry for pyproto 2023-04-11 21:23:05 +01:00
Adam Reichold 48f79718f9 Fix redundant imports in doc tests thereby fixing the careful CI job. 2023-04-10 08:09:06 +02:00
Will Jones 52a0378e56 docs: show pattern for self.__class__.__name__ in __repr__
Co-authored-by: Bruno Kolenbrander <59372212+mejrs@users.noreply.github.com>
2023-03-30 10:59:41 +02:00
messense 57dbc94293
Improve default value for `None` in `text_signature` 2023-03-29 10:14:44 +08:00
bors[bot] ebedcfb8b2
Merge #3050
3050: Improve default values for str, numbers and bool in `text_signature` r=davidhewitt a=messense

xref #2863

Co-authored-by: messense <messense@icloud.com>
2023-03-25 07:07:06 +00:00
bors[bot] e5e8c7a6d0
Merge #2975 #3022 #3023
2975: RFC: Add GILProtected synchronization primitive and use it for LazyTypeObjectInner. r=davidhewitt a=adamreichold

I would also like to use that type in rust-numpy and it seems we can avoid ~~both a manual unsafe impl and~~ a full blown mutex if we apply it to `LazyTypeObjectInner`.

One downside might be that it ties us closer to the GIL when we want to enable nogil experimentation, but on the other hand, it may also help by reifying the GIL usage. (This is currently limited to comments in unsafe code in rust-numpy for example.)

3022: Fix function name shadowing r=davidhewitt a=mejrs

Fixes https://github.com/PyO3/pyo3/issues/3017

3023: Emit a better error for bad argument names r=davidhewitt a=mejrs

This will emit a better error for code like 
```rust
#[pyfunction]
fn output([a,b,c]: [u8;3]) {}
```



Co-authored-by: Adam Reichold <adam.reichold@t-online.de>
Co-authored-by: mejrs <59372212+mejrs@users.noreply.github.com>
2023-03-23 08:04:11 +00:00
messense 79a70f3923
Improve default values for str, numbers and bool in `text_signature` 2023-03-16 11:06:51 +08:00
Adrian Garcia Badaracco 626a67ca49 Add note about garbage collection on PyPy 2023-03-12 23:35:47 +00:00
Antoine Romero-Romero a629e8267a feat: add #[pyo3(get, set)] for Cell 2023-03-09 23:09:30 +00:00
bors[bot] 410bb15d71
Merge #2982
2982: explain STATUS_DLL_NOT_FOUND r=adamreichold a=mejrs

I had someone ask me this today, and googling for it I found various other places where this was asked, with no (good) answers. 

Co-authored-by: mejrs <59372212+mejrs@users.noreply.github.com>
2023-02-24 17:13:38 +00:00
mejrs db16580b63 Make changes 2023-02-23 12:36:54 +01:00
Adam Reichold 9534749d8b Add GILProtected synchronization primitive replacement and use it for LazyTypeObjectInner. 2023-02-23 09:38:02 +01:00
mejrs 90ce52175f explain STATUS_DLL_NOT_FOUND 2023-02-22 23:30:19 +01:00
Adam Reichold a16f2e45c8 Include conversions for bytes, bytearrays and Cow<[u8]> in the guide. 2023-02-22 22:07:59 +01:00
Azat Ibrakov 9f7368922f docs: fix typo in method name 2023-02-18 22:02:05 +01:00
David Hewitt c7cc48f8e4 use PyO3 types within LazyTypeObject 2023-02-18 09:06:36 +00:00
David Hewitt 00ddd21535 change PyModule::add_class to return an error if class creation fails 2023-02-14 22:08:35 +00:00
David Hewitt dbeb3b4453 move some private internals out of public implementation 2023-02-11 21:28:27 +00:00
bors[bot] 9e5c845dee
Merge #2934
2934: guide: add documentation for trailing option arguments r=davidhewitt a=davidhewitt

Following the increased clarity around PyO3's handling of function signatures of 0.18.0, I wanted to add a section to the guide documenting the default-to-none behaviour for trailing `Option<T>` arguments.

Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2023-02-07 08:15:57 +00:00
Jeff Hodges bc1a33f9fe
bump maturin version in getting_started.md
Latest maturin is 0.14.x
2023-02-04 00:09:04 -08:00
Julien Jerphanion 9306d56b27 docs: Precise the abscense of `py: Python` for the #[pyo3(signature)] 2023-02-03 20:57:23 +00:00
David Hewitt c709f30638 guide: add documentation for trailing option arguments 2023-02-03 20:54:51 +00:00
David Hewitt e83803e813 add link on how to obtain GIL to guide 2023-01-20 08:21:57 +00:00
David Hewitt 586fed2c4b send errors in `__releasebuffer__` to `sys.unraisablehook` 2023-01-19 19:10:06 +00:00
David Hewitt ca1bbe3d39 add migration notes for PyO3 0.18 2023-01-17 08:14:32 +00:00
David Hewitt 20ca3be659 inspect: gate behind `experimental-inspect` feature 2023-01-15 12:41:23 +00:00
David Hewitt eea2a31bd3 adjust location and wording for extension module memory management 2023-01-10 07:42:39 +00:00
Haixuan Xavier Tao 8af9d2a19a Add a section on memory management for `extension`
Adding a special case of memory management when writing an extension.

This is a documentation of: https://github.com/PyO3/pyo3/issues/1056 and https://github.com/PyO3/pyo3/issues/2853
2023-01-10 07:37:21 +00:00
David Hewitt 8651d3b0e8 address feedback in review #2678 2023-01-06 08:53:00 +00:00
James Welchman e52dbc907d GH-2649 example for inserting moulde in sys.dict 2023-01-05 21:26:47 +00:00
messense c722402e46
Fix links in `logging.md` 2023-01-03 20:03:51 +08:00
Dylan Storey fefd224e4a Update logging.md for logging->rust
Demonstrates how to register a rust log consumer with a pythong logging instance.
2023-01-03 10:22:54 +00:00
David Hewitt f2608a923c remove functionality deprecated in 0.16 2022-12-28 12:23:53 +00:00
David Hewitt 5039fd746a add automatic text signature generation 2022-12-24 09:43:02 +00:00
David Hewitt 97487ffbb5 add abi3-py311 feature 2022-11-23 08:08:12 +00:00
Georg Brandl f1f1ffcdc7 More typos and grammar. 2022-11-23 07:42:53 +01:00
Georg Brandl c91ed70bbc Fix various typos/omissions in guide. 2022-11-23 07:42:17 +01:00
Georg Brandl 5f7d67615c Use PYO3_DOCS_URL in guide-to-rustdoc links. 2022-11-23 07:42:17 +01:00
bors[bot] 08423557d4
Merge #2739
2739: error when `#[pyo3(signature = ())]` used on invalid methods r=davidhewitt a=davidhewitt

A follow-up to #2702 to reject some invalid applications of `#[pyo3(signature = (...))]` attribute, specifically on magic methods and getters / setters / class attributes.

Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2022-11-22 19:41:27 +00:00
bors[bot] b485199cfb
Merge #2762
2762: Add a nox task to rustfmt code in the guide r=birkenfeld a=birkenfeld

Also apply it. Two caveats:

1) needs nightly rustfmt to be available
2) not all reformat diffs have been applied; using best judgment for readability


Co-authored-by: Georg Brandl <georg@python.org>
2022-11-22 11:11:19 +00:00
Georg Brandl a7a53d6c0d Add a nox task to rustfmt code in the guide.
Also apply it. Two caveats:

1) needs nightly rustfmt to be available
2) not all reformat diffs have been applied; using best judgment for readability.
2022-11-22 09:19:40 +01:00
Saul Shanabrook 8a75352122
Add link to Python typing docs for type stubs
AFAIK there isn't currently a link to the article on ["Type Stubs"](https://typing.readthedocs.io/en/latest/source/stubs.html) in the official Python static typing documentation. This PR adds a link to this documentation, which is the most comprehensive I have seen around type stubs.
2022-11-21 16:48:43 -05:00
Matthew Lloyd b2014c30aa
guide: linkify "Method arguments" in class.md 2022-11-20 16:33:15 -05:00
David Hewitt 8ca41be87b
Merge pull request #2749 from PyO3/2748-fix
Fix being able to call arg-less `#[new]` with any args from Python
2022-11-20 11:39:42 +00:00
Georg Brandl 51eeb6db96 guide: explain how #[new] works w.r.t. native base types 2022-11-20 08:25:42 +01:00
Georg Brandl 77f5fc107e guide: better document negative index behavior w.r.t. PySequence
Fixes #2601
2022-11-20 08:09:50 +01:00
Georg Brandl c489809938 Py/PyAny: deprecate cast_as() in favor of downcast()
They are (practically) identical on PyAny, and `downcast()` is the more
useful name.
2022-11-18 07:00:40 +01:00
David Hewitt 00fc0358b9 error when `#[pyo3(signature = ())]` used on invalid methods 2022-11-17 08:28:34 +00:00
messense dee791de90
`pyo3-build-config`: rebuild when `PYO3_ENVIRONMENT_SIGNATURE` value changed 2022-11-09 20:28:18 +08:00
Marc Garcia 47490a7a31
Fix module name in getting started 2022-11-01 14:08:28 +07:00
David Hewitt 8e8b484169
add `#[pyo3(signature = (...))]` attribute (#2702) 2022-10-25 07:23:21 +01:00
David Hewitt 446c0e82f0
Merge pull request #2692 from mejrs/all
Implement get/set all on pyclass
2022-10-18 21:39:44 +01:00
Georg Brandl 676227d2a1
Make `is_instance()` and `is_subclass()` take `&PyAny` (#2695) 2022-10-18 19:22:23 +02:00
mejrs d254134154 Implement get/set all on pyclass 2022-10-17 02:37:43 +02:00
C. Titus Brown ca1c9c1dba update per review 2022-10-16 11:04:15 -07:00
C. Titus Brown 8e6bf1875f
Apply suggestions from code review
Co-authored-by: Georg Brandl <georg@python.org>
2022-10-16 11:01:15 -07:00
C. Titus Brown 78e4130762
Update getting_started.md 2022-10-15 20:55:49 -07:00
C. Titus Brown b265ee7907
Point new users at specific source file for Rust code.
This was a minor confusion for me so I thought I'd suggest the change - it was the first place I looked, but I did have to think about it :)
2022-10-15 20:49:24 -07:00
Bruno Kolenbrander c9b26f57cd
Merge pull request #2657 from mejrs/decorator_fix
Update decorator to use Cell counter
2022-10-10 19:55:36 +02:00
mejrs d8fa6be28a is 2022-10-04 19:33:02 +02:00
mejrs e0602b641c Just use Cell 2022-10-04 19:05:44 +02:00
mejrs 611ea4db49 Update decorator to use atomics 2022-10-04 17:59:46 +02:00
David Hewitt bd40011e93 release: 0.17.2 2022-10-04 08:13:53 +01:00
David Hewitt 372176630e guide: doctest function/ subpages 2022-09-27 07:52:14 +01:00
Bruno Kolenbrander fad5f6a07a
Merge pull request #2639 from mrob95/err-self-typo
docs: fixed typo in error_handling.md
2022-09-26 23:16:26 +02:00
smheidrich 2dd3c6c71f Document needing resolve-config for pyo3 cfgs 2022-09-24 16:18:05 +02:00
smheidrich a731c2ae60 Fix pyo3-build-config version in docs 2022-09-24 15:50:41 +02:00
Mike Roberts 4275abff0c docs: fixed typo in error_handling.md 2022-09-24 14:03:13 +01:00
messense 86ce4d1a13
Add git repository and edit urls to user guide (#2635) 2022-09-23 00:56:25 +00:00
David Hewitt c5ba1f0632
pyclass: better error and explanation why lifetimes are disallowed (#2633)
* pyclass: better error and explanation why lifetimes are disallowed

* extend detail on lifetimes
2022-09-22 11:14:06 +02:00
Federico Dolce 63f7df905d
Add chrono 0.4 integration (#2612)
Co-authored-by: Ivan Tham <pickfire@riseup.net>
Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2022-09-22 09:00:09 +02:00
Ryan Russell 04a7b5f14d docs: codeblock labels to `rust,ignore` format
Signed-off-by: Ryan Russell <git@ryanrussell.org>
2022-09-10 11:21:04 -05:00
David Hewitt 5718adeec7 pyproto: remove deprecated feature 2022-09-06 08:38:44 +01:00
David Hewitt caaf7bbda7 release: 0.17.1 2022-08-28 08:27:56 +01:00
David Hewitt 04c1ac87f1 release: 0.17.0 2022-08-23 21:21:19 +01:00
David Hewitt f7537909a1 guide: note existence of PyFunction::new_closure 2022-08-23 20:49:14 +01:00
David Hewitt 86a11164e0 guide: note __hash__ can have any integer type up to 64 bits 2022-08-23 20:49:14 +01:00
David Hewitt c5ecf47890 docs: note `__richcmp__` disables default `__hash__` 2022-08-23 20:49:14 +01:00
David Hewitt fb05e1d7a7 guide: additional detail on how to handle foreign errors 2022-08-23 20:49:14 +01:00
David Hewitt 580e747521 guide: use sentence case, move function signatures to own section 2022-08-23 20:49:14 +01:00
David Hewitt af60a359c5 guide: don't use `::pyo3` 2022-08-23 20:49:14 +01:00
David Hewitt ef8ccc0deb docs: demonstrate `NotImplemented` in `__richcmp__` 2022-08-23 20:49:14 +01:00
Sergey Kvachonok 97eaa77db8 docs: Update the guide for `python3-dll-a` v0.2.6
Bump the minimum `python3-dll-a` dependency version.

Document the implemented workaround for
https://github.com/PyO3/python3-dll-a/issues/28
2022-08-21 14:33:52 +03:00
David Hewitt d0492b7c72
Merge pull request #2570 from davidhewitt/pyclass-frozen-tidy
pyclass: tidy up frozen implementation
2022-08-21 09:35:51 +01:00
David Hewitt 24456f3f41 pyclass: tidy up frozen implementation 2022-08-21 08:21:06 +01:00
David Hewitt fd8026c7bb pyclass: add `sequence` option to implement `sq_length` 2022-08-20 07:14:26 +01:00
Ashley Anderson 5d88e1d1c4
Update PyTryFrom for PyMapping and PySequence to more accurately check types (#2477)
Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2022-08-10 21:03:18 +01:00
David Hewitt 78ba70d2b4 pymodule: only allow initializing once per process 2022-08-09 19:52:25 +01:00
Nathan Henrie 1ebceb4f86 Additional link args and troubleshooting for MacOS
Fixes https://github.com/PyO3/pyo3/issues/1800

Documents issues linking with the system python (`/usr/bin/python3`) as
well as reemphasizes the need for `--no-default-features` with `cargo
test` on MacOS
2022-08-02 16:52:53 -06:00
Sam Vente 6503128442
add first version of getting started page to the guide (#2499)
* add first version of getting started page to the guide

* add more info on maturin
2022-08-01 10:30:53 +08:00
Acshi Haggenmiller 6831b4875b Add documentation for more workarounds for enabling the extension-module feature
Closes https://github.com/PyO3/pyo3/issues/2521
2022-07-29 00:03:51 -07:00
Jonas Pleyer 9d081e76a4 guide: python_from_rust: fix typo for call0 2022-07-25 12:36:51 -04:00
David Hewitt 209c942277 pyfunction: use extract_argument with holder to avoid extractext 2022-07-14 08:42:22 +01:00
David Hewitt 0391b3b0c1 inventory: update to 0.3 2022-07-03 15:22:25 +01:00
Bruno Kolenbrander 8babae655e
Merge pull request #2468 from mejrs/frozen
Add frozen documentation
2022-06-30 14:45:45 +02:00
mejrs a62930bd95 Fix duplication 2022-06-28 19:53:45 +02:00
David Hewitt 4da9c3a55f llvm-lines: use iterator to collect class items 2022-06-25 22:03:28 +01:00
David Hewitt 510c126f57
Merge pull request #2457 from yodaldevoid/enum_naming_improvements
Enum naming improvements
2022-06-22 22:12:06 +01:00
Gabriel Smith 845be0486a guide: Update with enum naming macro changes 2022-06-22 09:36:40 -04:00
mejrs e4e7e6e51c Add frozen documentation 2022-06-22 01:47:40 +02:00
Sam Vente cdb3b6ff32
remove outdated workaround in module documentation (#2466)
* remove workaround section in module.md that is no longer needed after merging #2081

* update changelong

* revert CHANGELOG
2022-06-21 21:02:10 +00:00
Georg Brandl 53b83cccbf
add `CompareOp::matches` (#2460) 2022-06-21 15:36:20 +02:00
David Hewitt 7725f17c46 pyclass: switch from immutable to frozen 2022-06-19 21:18:15 +01:00
David Hewitt 9dfeaa38d4
guide: add contributing page (#2442)
Co-authored-by: messense <messense@icloud.com>
2022-06-08 13:30:11 +00:00
David Hewitt f22a69e223 guide: document platform tag for pypy 2022-06-03 20:10:02 +01:00
David Hewitt 126bf49b8b
Merge pull request #2377 from herquan/herquan_cr1
Add macro append_to_inittab (issue #2359)
2022-05-24 08:02:47 +01:00
herquan 2ec477344d Add macro append_to_inittab
Sometimes we need to debug in a real environment with our module installed. `append_to_inittab` will be a wrapper for PyImport_AppendInittab (https://docs.python.org/3/c-api/import.html#c.PyImport_AppendInittab) and help us to do this
2022-05-24 07:42:15 +01:00
David Hewitt 0de0e3f8d6 Allow `#[classattr]` methods to be fallible 2022-05-17 21:19:41 +01:00
messense c477718fe7
Add support for generating non-abi3 python import libraries for Windows
targets
2022-05-12 14:32:20 +08:00
Colin Jermain f5357f9395
Updating debugging docs with more info on rust-gdb (#2361) 2022-05-10 07:00:56 +01:00
Bruno Kolenbrander c57e5098b8
Fix IntoPyCallbackOutput paper cuts (#2326)
* Implement IntoPy for arrays of IntoPy

* Improve `IntoPyCallbackOutput` compile error
2022-05-09 18:15:43 +01:00
David Hewitt bc8641c790
Merge pull request #2350 from mejrs/ignore-less
Expand on AsPyPointer docs and un-ignore doc examples
2022-05-06 06:51:54 +01:00
mejrs 5bdf6987c3 Delete section about immutability of pyclasses 2022-05-05 22:24:49 +02:00
David Hewitt 5d8fd4d30e ffi: remove with_thread cfg 2022-05-05 07:26:05 +01:00
mejrs 8921d5d1c0 Fix CI 2022-05-03 11:36:24 +02:00
mejrs f1e5d4c9a1 Un-ignore and expand on doc examples 2022-05-03 00:47:09 +02:00
Bruno Kolenbrander dce4377eb4
Allow more methods to take interned arguments (#2312)
* Allow more methods to take interned arguments

* Changelog

* Unify name bounds

* Resolve merge conflict

* reduce use of py_decref

* Add some attr tests

* Update migration
2022-05-02 11:13:15 +02:00
cuishuang 19e32a0621 fix some typos
Signed-off-by: cuishuang <imcusg@gmail.com>
2022-04-24 22:06:32 +08:00
David Hewitt 7e2d3117ce cleanup: deprecate PyTypeObject trait 2022-04-23 13:36:32 +01:00
David Hewitt 76bc2a6a4a
Merge pull request #2322 from davidhewitt/opt-in-pyproto
pyproto: make deprecated feature opt-in
2022-04-23 13:34:21 +01:00
David Hewitt e9bd41efb2 better mutability inheritance rules 2022-04-21 20:51:28 +01:00
David Hewitt 0787b670e8 pyproto: make deprecated feature opt-in 2022-04-21 20:19:14 +01:00
David Hewitt 7118e94947 Merge branch 'main' into immutable 2022-04-19 19:00:33 +01:00
Sergey Kvachonok ae7e1f5ee9 pyo3-build-config: Build "abi3" extensions without an interpreter
Support compiling portable "abi3" extension modules even when
the build host Python interpreter configuration is not available
or the discovered Python interpreter version is not supported.

Maturin already implements this by building "abi3" extension wheels
with `PYO3_NO_PYTHON` environment veriable set for cargo when
an `abi3-py3*` feature is detected.

Closes #2292
2022-04-13 10:40:08 +03:00
Bruno Kolenbrander bc6bd6099c
Merge branch 'main' into immutable 2022-04-12 14:22:33 +02:00
Sergey Kvachonok 4347624bd3 Mention `generate-abi3-import-lib` in the features guide
Update the feature list section of the user guide
to include `generate-abi3-import-lib` description.
2022-04-11 09:56:52 +03:00
Sergey Kvachonok a7c0de3628 Document `generate-abi3-import-lib` crate feature
Update the user guide to describe its applicability to the native
and cross-compilation build scenarios.
2022-04-10 16:45:32 +03:00
David Hewitt 981eb2d90e
Merge pull request #2265 from davidhewitt/pyclass-mapping
pyclass: mapping flag
2022-04-04 19:54:37 +01:00
David Hewitt 9f3ccff8c9 guide: improve documentation for `#[pyclass(mapping)]` 2022-04-04 15:51:01 +01:00
Sergey Kvachonok 80675361f4 pyo3-build-config: Add `PYO3_CROSS_PYTHON_IMPLEMENTATION` env var
Adds a new cross-compile target interpreter configuration
environment variable.

This feature allows PyO3 to target PyPy on both Windows and Unix
cross compile targets.
2022-04-04 15:23:11 +03:00
David Hewitt c16cc35b30 pyclass: mapping flag 2022-04-02 16:15:44 +01:00
mejrs 086424b88c Merge branch 'main' of https://github.com/mejrs/pyo3 into immutable 2022-04-01 23:11:02 +02:00
Sergey Kvachonok 2d2b9f5c33 Update the user guide and add a ChangeLog entry
Update Architecture.md to reflect the current cross compilation
support state.
2022-04-01 11:32:46 +03:00
Bruno Kolenbrander fb689340b4
Merge branch 'main' into lint-more 2022-03-23 09:34:31 +01:00
mejrs 6f1cf1b662 Add more lints 2022-03-23 08:07:28 +01:00
David Hewitt 87c79c0319
Merge pull request #2234 from davidhewitt/pyclass-args-refactor
pyclass: unify pyclass with its pyo3 arguments
2022-03-22 11:38:05 +00:00
David Hewitt 49c1d22606 docs: for #2234 2022-03-22 10:38:36 +00:00