Commit Graph

624 Commits

Author SHA1 Message Date
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
Mo Mirza 143b7d368f
Replace nbsp with space (#2237)
This fixes markdown heading rendering
2022-03-20 16:45:33 +01:00
Georg Brandl f084ceb9b1 guide: fix duplicated example for #[new]
The second one was probably intended to show a fallible `#[new]`.

Also show that the method does not need to be named `new()`, which
is nice because `new()` can be used for a Rust-level constructor
if they differ.
2022-03-06 10:57:49 +01:00
David Hewitt 0f1b8dd43f
Merge pull request #2207 from davidhewitt/tidy-doctests
guide: tidy up doctests
2022-03-05 16:18:43 +00:00
Alex Gaynor 01d8f1e696
added missing proc-macro invocation to migration guide (#2209) 2022-03-05 15:46:36 +00:00
David Hewitt 2bd64c4962 guide: tidy up doctests 2022-03-04 22:50:12 +00:00
Jerzy Spendel eaa82b2856 Remove typying 2022-03-04 16:24:49 +01:00
Georg Brandl 6bc8943df5 changelog/guide: visibility is also important for wrap_pyfunction! now
Fixes #2202
2022-03-04 07:48:41 +01:00
David Hewitt b59ee9b54b misc: tidy ups pre 0.16 2022-02-27 10:02:28 +00:00
Georg Brandl 0678f11266 Protocols: implement __getattribute__
converting tp_getattro to a shared slot

Fixes #2186
2022-02-26 20:05:50 +01:00
Georg Brandl 03dc96bff1
Py/PyAny: remove PartialEq impl and add is() (#2183) 2022-02-25 19:39:45 +00:00
David Hewitt 7c865fcc25
Merge pull request #2173 from davidhewitt/deprecate-pyproto
pyproto: deprecate protocol traits
2022-02-24 23:54:40 +00:00
David Hewitt 424644181b pymethods: add support for inplace concat & repeat 2022-02-24 23:07:24 +00:00
Rico Hageman ed698c4b43 Add documentation related to from_py_with for the FromPyObject trait 2022-02-24 22:54:30 +01:00
Bruno Kolenbrander af0cef0e59
Merge branch 'main' into object 2022-02-23 10:13:29 +01:00
mejrs be84e0fbb9 Add numeric and object protocol examples 2022-02-23 10:09:45 +01:00
David Hewitt 253507b5dd migration: add note on pymethods -> pyproto 2022-02-23 07:50:55 +00:00
Georg Brandl a21cf677e3 docs: remove/deprecate pyproto 2022-02-23 07:50:55 +00:00
David Hewitt d8ee35e19c
Merge pull request #2165 from mejrs/auto_trait
Implement Auto trait
2022-02-23 07:16:17 +00:00
mejrs 9e29c1058c Gut specialization and implement auto trait
Implement auto trait

Implement auto trait

Undo oopsie

Fix versions

Fix CI errors

Fix CI

Remove more specialization remnants
2022-02-22 22:43:23 +01:00
David Hewitt 79123b396c pyclass: deprecate gc option 2022-02-15 08:01:46 +00:00
David Hewitt 676295b8de pymethods: support gc protocol 2022-02-15 08:01:23 +00:00
David Hewitt f5b2a88a70 refactor: include __new__ as slot 2022-02-09 08:07:14 +00:00
David Hewitt 75e44585de refactor: pass tp_alloc and tp_free via slots 2022-02-09 08:07:14 +00:00
mejrs 7520b49ac1 Implement opt-in immutable pyclasses 2022-02-08 18:08:18 +00:00
b05902132 78f5afc82e Finish implementation for pyclass enums 2022-02-07 22:17:11 +00:00
David Hewitt 4fd01c3cd6
fix: guide example for pyclass expansion 2022-02-07 07:46:12 +00:00
David Hewitt 9def53317f
Merge pull request #2153 from davidhewitt/simplify-intrinsic-items
refactor: inline pyclass_intrinsic_items
2022-02-07 00:05:30 +00:00
David Hewitt e39881c208 refactor: inline pyclass_intrinsic_items 2022-02-06 23:26:57 +00:00
David Hewitt f75579a489 python-3.11: support buffer API on abi3 2022-02-06 22:46:45 +00:00
David Hewitt ecfd2c2434 pyclass: simplify generated code for PyClassImpl 2022-02-05 16:58:01 +00:00
David Hewitt 558549e1c2 pyproto: split into new feature 2022-02-05 16:51:31 +00:00
David Hewitt 53c170078d pymethods: seq methods from mapping methods 2022-02-05 15:59:22 +00:00
mejrs 463543ad58 Annotate Rust blocks with "rust" 2022-01-29 01:03:57 +01:00
Jakub Kołodziejczak d1542a8a79
docs(guide): example of loading python file from path at runtime in a way that it sees its dependencies (#2109)
* docs(guide): example of loading python file from path at runtime in a way that it sees its dependencies

* docs: editorial fixes

suggested by @mejrs

Co-authored-by: Bruno Kolenbrander <59372212+mejrs@users.noreply.github.com>

Co-authored-by: Bruno Kolenbrander <59372212+mejrs@users.noreply.github.com>
2022-01-24 11:03:47 +01:00
Jakub Kołodziejczak 020488efee
docs: example how to include multiple Python files into the binary and at runtime (#2095) 2022-01-17 10:57:39 +01:00
messense ce80b7e0f3 Switch from tox to nox 2022-01-17 00:24:33 +08:00
David Hewitt 2cee7feaaf
Merge pull request #2083 from aviramha/magic_methods
verify py method args count
2022-01-07 00:13:05 +00:00
Aviram Hassan 50659b6b02
`__ipow__` now supports modulo argument on Python 3.8+.
`pyo3-macros-backend` is now compiled with PyO3 cfgs to enable different magic method definitions based on version.
Add check for correct number of arguments on magic methods.
2022-01-03 09:53:56 +02:00
David Hewitt cf965155f4 pymethods: support buffer protocol 2021-12-30 15:48:55 +00:00
David Hewitt e33b3e6a5b opt: don't emit T::dict_offset and T::weakref_offset without attributes 2021-12-30 14:57:27 +00:00
Bruno Kolenbrander 4d1d859a64
Merge branch 'main' into aliases 2021-12-24 22:28:22 +01:00
James Hilton-Balfe a5511b8f8a
Fix markdown link (#2071) 2021-12-22 16:51:03 +00:00
mejrs 9512ce4e87 Fix call example 2021-12-22 12:12:16 +01:00
Bruno Kolenbrander 39cac9075b
Organize examples + add __call__ example (#2043)
* Add decorator example crate and split off chapter

* Move not-examples to their own folder

* Add some readme's

* Make black happy

* Make clippy happy

* Add decorator example crate and split off chapter

* Fix ci

* Add empty workspace key

* Try fix ci

* fix ci

* reuse target dir for examples CI

* add pytests folder to makefile recipes

* fix ci, try 2

* add missing pyproject.toml

* remove TOX_TESTENV_PASSENV from Makefile

Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2021-12-15 00:45:26 +00:00
Georg Brandl a5b76bc365 pyo3_path, part 4: rename to `crate` to keep consistent with serde 2021-12-09 07:36:48 +01:00
Georg Brandl e4f608f605 pyo3_path, part 2: add pyo3_path options and use them. 2021-12-09 07:24:18 +01:00
David Hewitt 2ac30ec411 err: tweak names, inlining and docs 2021-11-27 08:26:04 +00:00
David Hewitt e9b46f76da
Merge pull request #1985 from PyO3/is_instance_of
add PyType::is_subclass_of and PyAny::is_instance_of
2021-11-20 14:56:36 +00:00
David Hewitt ded44eebfb
Merge pull request #2006 from davidhewitt/drop-py36
python: drop support for 3.6
2021-11-20 14:04:31 +00:00
Georg Brandl 43893158b1 switch is_instance/is_instance_of, is_subclass/is_subclass_of 2021-11-20 13:18:43 +00:00
David Hewitt cc91a7c574
Merge pull request #2007 from davidhewitt/remove-0.14-deprecations
deprecations: remove items deprecated in PyO3 0.14
2021-11-20 13:09:04 +00:00
David Hewitt 70030f130d python: drop support for 3.6 2021-11-20 13:02:42 +00:00
David Hewitt c9a4cd1f87 deprecations: remove items deprecated in PyO3 0.14 2021-11-19 16:33:29 +00:00
David Hewitt b9cc10f3fb pyo3-build-config: don't enable resolve-config by default 2021-11-19 14:19:24 +00:00
Dan Svoboda d9a3f67287
Fix broken relative markdown link in guide
This link needs to point up one dir to the location of class.md
2021-11-15 14:04:53 -05:00
Gertjan van Zwieten 0e40277112 add missing annotation to PyCounter.__call__
This patch annotates the `__call__` method of `PyCounter` in example: callable
objects with `#[args(args="*", kwargs="**")]`. Without it (at least in PyO3
0.15.0) the example fails with `TypeError: counter.__call__() missing 1
required positional argument: 'args'`.
2021-11-15 09:01:05 +01:00
David Hewitt a978b0875a
Merge pull request #1968 from KRunchPL/guide-python-typing-hints
#1959 - Add Python Typing Hints to the Guide
2021-11-11 23:00:53 +00:00
David Hewitt 20091826a5
Merge pull request #1976 from davidhewitt/pyo3-build-config-docs
docs: pyo3 config files
2021-11-11 08:53:36 +00:00
David Hewitt 2784b31bea
Merge pull request #1971 from davidhewitt/disable-unwanted-protos
pymethods: test and document opt-out of protos
2021-11-11 08:52:58 +00:00
David Hewitt 23778f5386 pymethods: test and document opt-out of protos 2021-11-10 23:28:01 +00:00
David Hewitt b0af3ec25f docs: pyo3 config files 2021-11-10 08:34:54 +00:00
David Hewitt 3d1bcae3aa guide: document `#[pyo3(from_py_with)]` 2021-11-07 12:57:40 +00:00
KRunchPL a0716ce519 Description of simple solution implemented in Maturin guide 2021-11-06 17:29:02 +01:00
KRunchPL 1531ac8d7e #1959 - Add Python Typing Hints to the Guide 2021-11-06 15:34:30 +01:00
Georg Brandl 9ce363a125 guide: add hints for the signature of pymethods protos 2021-11-03 08:00:09 +01:00
David Hewitt 3ab32ff01f guide: magic methods in pymethods 2021-10-24 15:59:22 +01:00
David Hewitt dc0e29af1c
Merge pull request #1929 from davidhewitt/call-proto
pymethods: support __call__ proto
2021-10-23 22:55:30 +01:00
David Hewitt 4b2345fe80 pymethods: support __call__ proto 2021-10-23 00:06:46 +01:00
Nikita Sobolev 5ae9178781 Fixes typo in docs 2021-10-23 00:03:41 +01:00
Ashley Anderson bf26daec2d
Positional-only args (#1925)
* Add support for positional-only args

* Update changelog. Add a few more tests. Run rust-fmt.

* Fix test.

* Fix tests again.

* Update CHANGELOG.md to link PR instead of issue

* Update guide to mention positional-only params

* Add unreachable!() per code review

* Update and expand tests for pos args.

* Fix tests, lint, add UI tests.

Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2021-10-19 23:13:27 +01:00
Chris Laplante 3b94f4b70c
Add `anyhow-integration` feature which implements From<anyhow::Error> for PyErr (#1822)
* Add 'anyhow' feature which provides simple From<anyhow::Error> for PyErr impl

This makes it possible to use anyhow::Result<T> as the return type for
methods and functions exposed to Python.

The current implementation just stringifies the anyhow::Error before
shoving it into a PyRuntimeError. Conversion back to the anyhow::Error
is not possible, but it is better than nothing.

Signed-off-by: Chris Laplante <chris.laplante@agilent.com>

* Document `anyhow` feature in the guide

Signed-off-by: Chris Laplante <chris.laplante@agilent.com>

* update changelog to document anyhow feature

* WIP adding tests

* Finish up anyhow feature

* Fix formatting

* Fix tests

* Fix tests

* Apply review suggestions

Co-authored-by: Bruno Kolenbrander <59372212+mejrs@users.noreply.github.com>
Co-authored-by: mejrs <brunokolenbrander@hotmail.com>
2021-10-17 07:54:29 +01:00
Bruno Kolenbrander 8a57fe2d20
Clean up doctests, deny some lints (#1900)
* Clean up doctests, deny some lints

* Apply suggestions from review.

* replace \" with '

* Fix some more doc examples

* Fix formatting

* Fix some more things

* Remove unused parentheses

* Only test class sig on supported abi/platforms

* Only test class signature on correct versions

* Fix tests to compile on msrv

* msrv strikes yet again

* Add feedback

* Pin `half` to 1.7.1 on msrv
2021-10-14 22:15:25 +01:00
Bruno Kolenbrander ae873698d4
Implement `eyre` feature (#1893)
* Implement `eyre` feature

* Punctuation

* Add `eyre` entry in changelog

* Add `eyre` feature entry to guide

* Set eyre upper bound and move comment back

* Add eyre feature to docs.rs metadata

* Finish up review suggestions

* Update CHANGELOG.md

Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2021-10-13 22:36:06 +00:00
David Hewitt c986b5d4ae
Merge pull request #1889 from davidhewitt/py310
packaging: formal support for Python 3.10
2021-09-29 19:36:52 +01:00
David Hewitt a5d0aa777c py310: add abi3-py310 feature 2021-09-26 16:21:35 +01:00