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
David Hewitt
16ac7d481d
Merge pull request #1844 from davidhewitt/mapping-type
...
types: add PyMapping
2021-09-26 14:55:59 +01:00
David Hewitt
d929916071
types: add PyMapping
2021-09-26 13:57:33 +01:00
David Hewitt
9e80f3dfdd
pep 604: use `T | U` instead of `Union[T, U]` in messaging
2021-09-24 22:46:25 +01:00
David Hewitt
a551b005b4
pymethods: finish support for number protocol
2021-09-18 12:59:25 +01:00
Gregory Szorc
1e951d5d8b
pyo3-build-config: add a crate feature to control build script
...
I have a use case in PyOxidizer where I want to use the
pyo3-build-config crate as a library crate so I can access the
`InterpreterConfig` struct so I can read/write config files without
reinventing the wheel.
This is doable before this commit. But it requires that the
build environment have a Python interpreter. This is undesirable
for library usage.
This commit introduces a cargo feature flag to control whether the
build script does anything. The feature flag must be present for
the build script to resolve a config. The feature flag is enabled
by default for backwards compatibility. The pyo3 and pyo3-macros-backend
crates use this feature by default, for backwards compatibility and
because it is the reasonable default.
This is probably room to conditionalize some APIs and other behavior
based on this feature flag. But we stop short of doing that for
the time being.
2021-09-01 19:44:54 -07:00
David Hewitt
4a50a26c87
changelog: remove function parentheses
2021-08-26 18:59:07 +01:00
David Hewitt
a2375f336f
Merge pull request #1832 from mejrs/decorator
...
guide: add decorator example
2021-08-26 18:55:59 +01:00
mejrs
76179967f3
use &mut self receiver and py args.
2021-08-26 15:28:52 +02:00
David Hewitt
f20079bf78
Merge pull request #1829 from davidhewitt/slice-index
...
list,tuple,sequence: add slice indexing
2021-08-26 08:30:30 +01:00
David Hewitt
3a90ff77f4
list,tuple,sequence: add slice indexing
2021-08-26 07:57:12 +01:00
David Hewitt
f2ff6cad37
guide: add "Optional Dependencies" section
...
Co-authored-by: mejrs <59372212+mejrs@users.noreply.github.com>
2021-08-26 07:22:54 +01:00
mejrs
eaf5e6de9c
add decorator example
2021-08-26 04:18:49 +02:00
Georg Brandl
54e7da515a
migration: add guide entry for sequence indexing
2021-08-24 08:32:19 +02:00
Benjamin Kay
ac4613eb9f
Improve documentation about when we free memory, resolves #311 ( #1807 )
...
* Improve API docs regarding when we free memory, resolves #311
* Add chapter to guide about when we free memory, resolves #311
* Fix typos in documentation
Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
* Add links from guide to docs.rs
* Update guide/src/memory.md
Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2021-08-21 09:23:10 +01:00
David Hewitt
37d39aa83a
Merge pull request #1751 from davidhewitt/pyany-py
...
pyany: add PyAny::py()
2021-08-17 14:10:16 +01:00
Gregory Szorc
410c9f13c9
macros: raise AttributeError on property deletion requests
...
The setter function will receive a NULL value on deletion requests.
This wasn't properly handled before, leading to a panic.
The new code raises AttributeError in this scenario instead.
A test for the behavior has been added. Documentation has also
been updated to reflect the behavior.
2021-08-13 21:01:00 -07:00
David Hewitt
ebada76ae3
pyany: add PyAny::py()
2021-08-13 08:00:13 +01:00
Sanskar Jethi
aac3d1da6e
Add documentation to call async python from rust
2021-08-12 00:22:10 +01:00
David Hewitt
290ded4d4e
guide: don't bother doctesting async guide
2021-08-10 07:56:36 +01:00
Andrew J Westlake
f4975c6e1d
Fixed broken link in async-await.md
2021-08-09 09:07:57 -05:00
Andrew J Westlake
bf23f8bda7
Shortened the async/await guide
2021-08-08 14:58:46 -05:00
Andrew J Westlake
9037697bed
Update guide/src/ecosystem/async-await.md
...
Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2021-08-08 10:15:01 -05:00
Andrew J Westlake
d578f37f70
Removed "auto-initialize" feature from uvloop example
...
Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2021-08-08 10:13:47 -05:00
Andrew J Westlake
92c3af5088
Forgot to bump another pyo3 version
...
Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2021-08-08 09:59:17 -05:00
Andrew J Westlake
dbb956fd4c
Forgot to bump pyo3 version
...
Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2021-08-08 09:59:01 -05:00
Andrew J Westlake
5c5a406ce4
Updated async-await guide for pyo3-asyncio 0.14
2021-08-07 22:53:26 -05:00
David Hewitt
2cf2c2fef9
pyo3-build-config: improve test coverage
...
[review] birkenfeld
Co-authored-by: Georg Brandl <georg@python.org>
2021-08-06 12:55:03 +01:00
David Hewitt
49387e9a70
pyo3-build-config: many tidy ups
2021-08-05 23:19:43 +01:00
David Hewitt
c2d6a50b35
build: revert usage of cargo:rustc-cdylib-link-arg
2021-08-03 20:04:56 +01:00
David Hewitt
582d9c530f
build: move print-config into environment variable
2021-08-01 17:26:27 +01:00
David Hewitt
3d3dacf2ac
guide: rewrite "Building and Distribution" chapter
2021-08-01 16:59:47 +01:00
David Hewitt
13f8953d1a
readme: slightly improve getting started notes
2021-07-31 16:18:49 +01:00
Ivan Carvalho
bd0e0d808f
Add optional support for conversion from `indexmap::IndexMap` ( #1728 )
...
* Add support to IndexMap
* Fix indexmap version to 1.6.2
* Remove code duplication by mistake
* Fix ambiguity in test
* Minor change for doc.rs
* Add to lib.rs docstring
* Add indexmap to conversion table
* Add indexmap flag in docs.rs action
* Add indexmap feature to CI
* Add note in changelog
* Use with_gil in tests
* Move code to src/conversions/indexmap.rs
* Add PR number to CHANGELOG
Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
* Add round trip test
* Fix issue in MSRV Ubuntu build
* Fix Github workflow syntax
* Yet Another Attempt to Fix MSRV Ubuntu build
* Specify hashbrown to avoid ambiguity in CI
* Add suggestions
* More flexible version for indexmap
* Add documentation
* Address PR comments
* Export indexmap for docs
Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2021-07-22 08:15:26 +01:00
Eric Arellano
9ab7b1fad1
Rewrite `module.md` for clarity and add tip on code organization ( #1693 )
...
* Rewrite `module.md` for clarity and add tip on code organization
* Add section on how to build the guide + add workaround proposed by David
* Make more clear references to #1709
2021-07-22 08:10:32 +01:00
David Hewitt
6e0fb9e3a1
guide: bump mdbook to 0.4.10
2021-07-20 08:54:21 +01:00
messense
b5b9a480cd
Add `wrap_pyfunction` macro to prelude
2021-06-24 22:34:55 +08:00
Aviram Hassan
13cd092c4e
Update class.md - add example of `new` returning a `PyResult` ( #1688 )
...
* Update class.md - add example of `new` returning a `PyResult`
* Update class.md
2021-06-23 17:40:01 +08:00
David Hewitt
f916867375
pyclass: refactor initialization, call native type dealloc
2021-06-23 07:45:51 +01:00
mejrs
d5d2cf9fda
document + refactor numcomplex/bigint dependencies
2021-06-07 22:16:23 +02:00
David Hewitt
18e0aa17e0
pymodule: accept `#[pyo3(name = "...")]` option
2021-06-06 08:41:20 +01:00
David Hewitt
9b8b133905
pyfunction: document `#[pyo3(pass_module)]`
2021-06-05 17:36:50 +01:00
David Hewitt
cec4c2d2e9
text_signature: move to `#[pyo3(text_signature = "...")]`
2021-06-05 16:33:03 +01:00
Georg Brandl
3e8d003faf
Implement METH_FASTCALL for pyfunctions and pymethods.
2021-06-05 12:57:22 +02:00
David Hewitt
d011467e63
pyclass: allow `#[pyo3(get, set, name = "foo")]`
2021-06-04 11:30:40 +01:00
mejrs
dbf9a91a8b
mark toml field as toml
2021-05-31 21:05:52 +02:00
mejrs
e2cb176f6c
mark non-rust code as text fields
2021-05-31 20:58:38 +02:00
mejrs
161f1bd678
faq: add section about pyo3(get) cloning fields
2021-05-31 17:16:25 +02:00
Georg Brandl
d680fbee0a
Merge pull request #1643 from mejrs/main
2021-05-31 15:14:31 +02:00
mejrs
d86559b163
move manual builds to its own header
2021-05-31 12:39:00 +02:00
mejrs
ce3b0d1dc0
add renaming method to guide
2021-05-30 14:13:24 +02:00
Tim Robinson
1ba32178dd
Method and slot visitors accept slices instead of individual items
2021-05-29 09:38:15 +01:00
David Hewitt
9a4e7b5877
Merge pull request #1622 from davidhewitt/pyo3-build-config
...
pyo3-build-config: new crate to re-use build.rs across crates
2021-05-25 07:11:24 +01:00
David Hewitt
1e1605f0db
pyo3-build-config: finish docs
2021-05-24 08:44:20 +01:00
David Hewitt
825ec08681
pyo3-build-config: docs wip
2021-05-21 08:34:51 +01:00
David Hewitt
a109640850
pyfn: deprecate name argument
2021-05-20 08:54:29 +01:00
Tim Robinson
735a9a1156
Update for_each_proto_slot for consistency
2021-05-13 17:32:59 +01:00
Tim Robinson
c3b935f06c
Reduce size of compiled code for class initialization
2021-05-13 13:08:58 +01:00
David Hewitt
4d46abde73
macros: support `#[pyo3(name = "...")]`
2021-05-07 22:35:52 +01:00
David Hewitt
7536554ceb
type_object: remove layout and base type from PyTypeInfo
2021-05-04 21:39:42 +01:00
David Hewitt
48823e22d6
pyproto: deprecate py_methods
2021-04-20 00:21:19 +01:00
David Hewitt
2b9085abdb
build: avoid rebuilds when using clippy in a virtualenv
2021-04-19 09:45:01 +01:00
David Hewitt
355df5a37f
auto-initialize: better error messages and embedding docs
2021-04-12 01:29:03 +01:00
Sergey Kvachonok
e8a277e1ff
Apply suggestions from code review
...
- Style
Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2021-04-07 08:23:43 +03:00
Sergey Kvachonok
88849bd96b
Add `PyMappingProtocol` description to the guide
...
References:
[1]: https://docs.python.org/3/reference/datamodel.html#emulating-container-types
[2]: https://docs.python.org/3/c-api/mapping.html
[3]: https://docs.python.org/3/c-api/typeobj.html#c.PyMappingMethods
2021-04-05 14:19:18 +03:00
Sergey Kvachonok
b1aae93645
Add `PySequenceProtocol` description to the guide
...
References:
[1]: https://docs.python.org/3/reference/datamodel.html#emulating-container-types
[2]: https://docs.python.org/3/c-api/sequence.html
[3]: https://docs.python.org/3/c-api/typeobj.html#c.PySequenceMethods
2021-04-05 14:18:48 +03:00
Sergey Kvachonok
4b675cc364
Insert missing `impl` keywords
...
Updates the class customization guide.
2021-04-05 12:02:46 +03:00
Sergey Kvachonok
0c0214690f
Remove issue #844 mention from the guide
...
Supposedly resolved by https://github.com/PyO3/pyo3/pull/1107
Fix a typo in the subsection header.
2021-04-05 08:35:02 +03:00
David Hewitt
f953059880
guide: fixups to build
2021-04-03 10:50:57 +01:00
David Hewitt
31eeb86e98
guide: automatically set pyo3 version in links and cargo toml
2021-04-03 07:05:10 +01:00
Sergey Kvachonok
80c747d2c0
Remove `pyconfig.h` header parsing
...
The config header parsing code was supposed to be only invoked when
cross-compiling for Windows, but in reality it fails to correctly parse
the config header files shipped with the upstream Python for Windows.
Given that there are now better options for reliable cross-compiling
for Windows such as `PYO3_CROSS_PYTHON_VERSION` or the `abi3-py3*` features,
it should be OK to remove this config for v0.14.
Update the cross-compilation instructions section of the user guide.
Fixes https://github.com/PyO3/pyo3/issues/1337
2021-03-26 09:57:18 +03:00
kngwyu
aedd6352e3
Use with_gil instead of acquire_gil in examples
2021-03-20 19:02:50 +09:00
David Hewitt
f22fb423cb
Merge pull request #1503 from davidhewitt/main-tweaks
...
main: tweaks from rename
2021-03-17 21:07:58 +00:00
David Hewitt
971b48f091
Update guide/src/parallelism.md
...
Co-authored-by: Yuji Kanagawa <yuji.kngw.80s.revive@gmail.com>
2021-03-17 07:02:29 +00:00
Yuji Kanagawa
6137e3a726
Merge pull request #1456 from davidhewitt/pyclass-impl-flags
...
pyclass: move flags to PyClassImpl
2021-03-17 12:50:49 +09:00
David Hewitt
4d2913dc06
main: tweaks from rename
2021-03-16 22:14:57 +00:00
David Hewitt
b10cefdca2
pymodule: remove call_function etc.
2021-03-14 11:19:55 +00:00
David Hewitt
d9fe404d69
[review] kngwyu
2021-03-14 00:50:59 +00:00
Matthew Scheffel
e24f29dbf5
Add context manager example to user guide ( #1476 )
...
* Add context manager example
A simple illustrative example on how to use context managers. I required this to use pymc3, which relies heavily on the context stack for modelling.
* Clippy changes to context example
* Extend context manager example with exit exceptions
* Context manager, s/call1/call_method1/ and comments for clarity
* Add newline to context manager section to avoid horizontal scrolling
* Change generic, potentially confusing label.
s/objects.py/house.py/
* Use call_function1 rather than call_method1.
* Missed a call_method0, change to call_function0
* Update guide/src/python_from_rust.md
Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
* Update guide/src/python_from_rust.md
Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2021-03-13 22:54:13 +00:00
David Hewitt
31c7af2ac7
pyclass: move flags to PyClassImpl
2021-03-13 22:44:53 +00:00
David Hewitt
a45f520ec1
Merge pull request #1457 from davidhewitt/multiple-pymethods
...
pymethods: make inventory optional
2021-03-06 23:09:02 +00:00
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