Commit Graph

6284 Commits

Author SHA1 Message Date
Alex Gaynor ae3ac7d872
Fixed error string when failing to import an exception (#4012) 2024-03-29 15:49:50 +00:00
Alex Gaynor 60e3f44dcf
Ensure all arguments to _run are strings (#4013)
Otherwise you get errors like https://github.com/PyO3/pyo3/actions/runs/8480723060/job/23236947935?pr=4012
2024-03-29 14:16:45 +00:00
David Hewitt cf74624de9
refactor to remove add_to_module functions from generated code (#4009)
* refactor to remove add_to_module functions from generated code

* mrsv, newsfragment

* clippy
2024-03-29 11:54:33 +00:00
David Hewitt b053e83c08
implement `Send` and `Sync` for `PyBackedStr` and `PyBackedBytes` (#4007) 2024-03-29 11:28:42 +00:00
Icxolu dd1710256d
use `extract_argument` for `#[setter]` extraction (#3998)
* use `extract_argument` for `#[setter]` extraction

* add newsfragment
2024-03-27 15:41:04 +00:00
David Hewitt bcfc848703
docs: fix link in CHANGELOG (#4001) 2024-03-27 11:48:56 +00:00
tison 7c03d65cda
chore: add Python scripting in database example (#3999) 2024-03-27 11:16:22 +00:00
Icxolu 35faeff6f1
handle `#[pyo3(from_py_with = "")]` in `#[setter]` methods (#3995)
* handle `#[pyo3(from_py_with = "")]` in `#[setter]` methods

* add newsfragment
2024-03-26 18:53:11 +00:00
David Hewitt 1be2fad9bf
release: 0.21.0 (#3983) 2024-03-25 23:36:08 +00:00
Tim Felgentreff 9a38e709bb
Basic GraalPy Support (#3247)
* graalpy: recognize graalpy implementation when building

* graalpy: global Ellipse, None, NotImplemented, True, and False are only available as pointers

* graalpy: PyObject struct is opaque, use functions for everything

* graalpy: missing many of the same functions as pypy

* graalpy: do not have 128bit conversion functions

* graalpy: add functions for datetime accessor macros

* graalpy: add implementations for list macro functions

* graalpy: skip tuple macros

* graalpy: always use extern Py_CompileString function

* graalpy: disable assertion that does not apply to graalpy

* graalpy: floatobject structure is opaque on graalpy

* graalpy: ignore gc dependent test

* graalpy: add CI config

* graalpy: run rust fmt

* graalpy: add changelog entry

* graalpy: discover interpreter on PATH

* graalpy: interpreter id is not applicable to graalpy (just like pypy)

* graalpy: skip tests that cannot work on GraalPy

* graalpy: fix constructing normalized Err instances

Co-authored-by: David Hewitt <mail@davidhewitt.dev>

* graalpy: correct capi library name, but skip rust tests due to missing symbols

* graalpy: no support for C extensions on windows in latest release

* graalpy: declare support versions

* graalpy: frame, code, method, and function objects access from C API is mostly missing

* graalpy: take care only to expose C structure that GraalPy allocates

* graalpy: Bail out if graalpy version is less than what we support

---------

Co-authored-by: David Hewitt <mail@davidhewitt.dev>
2024-03-25 18:54:52 +00:00
Icxolu 54ffaecd65
add `AsRef` impls for `PyBackedStr` and `PyBackedBytes` (#3991)
* add `AsRef` impls for `PyBackedStr` and `PyBackedBytes`

* add newsfragment
2024-03-25 16:21:27 +00:00
David Hewitt 7d319a906e
ci: tidy up benchmarks a little (#3986) 2024-03-23 20:17:33 +00:00
David Hewitt aeb74c7093
ci: use macos-14 runners (#3985)
* ci: use macos-14 runners

* use arm64 python architecture
2024-03-23 20:16:37 +00:00
Lily Foote 009cd32a44
Add into_mapping and into_sequence methods to Bound types (#3982)
* Add Bound<'py, PyDict>.into_mapping method

* Add Bound<'py, PyTuple>.into_sequence method

* Add Bound<'py, PyList>.into_sequence method

* Add newsfragment

* Add tests for into_mapping and into_sequence
2024-03-23 01:13:24 +00:00
David Hewitt 9808f7111c
ci: add `update-ui-tests` nox session (#3979)
* ci: add `update-ui-tests` nox session

* defer error messages after the group closes

* fix syntax warnings
2024-03-22 22:43:08 +00:00
David Hewitt 20e477a7cd
avoid reference count cycle in tuple extraction (#3976) 2024-03-22 22:43:05 +00:00
David Hewitt 990886efda
docs: better document `FromPyObject` for `&str` changes in migration guide (#3974)
* docs: better document `FromPyObject` for `&str` changes in migration guide

* review: LilyFoote
2024-03-22 22:16:28 +00:00
David Hewitt d0f5b6af46
ci: updates for Rust 1.77 (#3978)
* ci: updates for Rust 1.77

* move `SendablePtr` inside of test which uses it
2024-03-22 20:43:23 +00:00
David Hewitt 351c6a0a49
deprecate optional GIL Ref in function argument (#3975) 2024-03-21 07:24:40 +00:00
David Hewitt 870a4bb20d
deprecate GIL refs in function argument (#3847)
* deprecate GIL Refs in function arguments

* fix deprecated gil refs in function arguments

* add notes on deprecations limitations to migration guide

* Apply suggestions from code review

Co-authored-by: Icxolu <10486322+Icxolu@users.noreply.github.com>

* review: Icxolu

* fix proto method extract failure for option

* fix gil refs in examples

---------

Co-authored-by: Icxolu <10486322+Icxolu@users.noreply.github.com>
2024-03-20 22:35:08 +00:00
David Hewitt cedac43dbb
add Bound::as_unbound (#3973)
* add Bound::as_unbound

* Update src/instance.rs
2024-03-20 12:52:09 +00:00
Icxolu 2736cf670c
deprecate gil-refs in `from_py_with` (Part 2) (#3972)
* deprecate `from_py_with` in `#[derive(FromPyObject)]` (NewType)

* deprecate `from_py_with` in `#[derive(FromPyObject)]` (Enum, Struct)
2024-03-20 09:27:38 +00:00
David Hewitt caf80eca66
handle clippy `new_without_default` warnings (#3971)
* handle clippy `new_without_default` warnings

* add newsfragment
2024-03-19 21:41:27 +00:00
David Hewitt 02e188e4b4
adjust path for GIL Refs deprecation warnings (#3968) 2024-03-19 21:08:20 +00:00
David Hewitt cbed7c11b6
ci: tidy ups for 3.7 (#3969) 2024-03-19 19:36:22 +00:00
David Hewitt e29fac9c46
docs: use details to condense migration guide (#3961) 2024-03-19 08:59:05 +00:00
Icxolu b06e95727b
deprecate gil-refs in `from_py_with` (#3967)
* deprecate gil-refs in `from_py_with`

* review feedback davidhewitt
2024-03-19 08:58:41 +00:00
David Hewitt ebeea943fe
ci: fixes to actions caches (#3970) 2024-03-19 08:14:42 +00:00
Icxolu da24f0cf93
exposes `Borrowed::to_owned` as public API (#3963)
* exposes `Borrowed::to_owned` as public API

* add newsfragment
2024-03-17 09:17:09 +00:00
David Hewitt dcba984b51
deprecate `GILPool` (#3947)
* deprecate `GILPool`

* review: adamreichold

* fix deprecation warnings in tests
2024-03-15 10:25:27 +00:00
Icxolu 5c86dc35c1
allow borrowed extracts with `gil-refs` disabled (#3959) 2024-03-15 07:53:52 +00:00
Bruno Kolenbrander 989d2c53ab
Fix non_local_definitions lint triggers (#3955) 2024-03-12 22:59:33 +00:00
Thomas Tanon 7cde95bba4
Documents experimental-declarative-modules feature (#3953)
* Documents experimental-declarative-modules feature

* More details on experimental-declarative-modules progress
2024-03-12 22:57:31 +00:00
Icxolu ee89b2e8e2
deprecate `wrap_pyfunction` with `py` argument (#3954)
* deprecate `wrap_pyfunction` with `py` argument

The Python token in `wrap_pyfunction` is not handled automatically by
`WrapPyFunctionArg`, for backwards compatibility. This uses deref
specialization to deprecate this variant.

* merge `Extractor`s

* add deprecation ui test, revert closure variant due to test failure

* fix nightly
2024-03-12 22:57:03 +00:00
Georg Brandl a7fa1bdf22
fix: remove "track_caller" cfg check (#3951)
This "cfg" value does not seem to exist (any more?), and #[track_caller]
is used a lot elsewhere without cfg_attr.

Found using cargo check -Zcheck-cfg.
2024-03-11 12:40:26 +00:00
acceptacross 93323bc922
chore: remove repetitive words (#3950)
Signed-off-by: acceptacross <csqcqs@gmail.com>
2024-03-11 10:15:03 +00:00
David Hewitt 67b1b35013
release: 0.21.0-beta.0 (#3944) 2024-03-10 22:16:18 +00:00
David Hewitt db0a98c040
ci: pin pytest < 8.1 (#3946) 2024-03-10 16:17:15 +00:00
David Hewitt 9145fcfe19
docs: major rewrite for Bound API (#3906)
* wip bound docs

* Update guide/src/python_from_rust/calling-existing-code.md

Co-authored-by: Lily Foote <code@lilyf.org>

* continue to move and tidy up

* Apply suggestions from code review

Co-authored-by: Lily Foote <code@lilyf.org>

* update URL

* complete python-from-rust.md

* progress on types.md; probably more to go

* update doctest paths

* review: Icxolu

* finish updating `types.md` to Bound API

* update remainder of the guide to Bound API

* Update guide/src/performance.md

Co-authored-by: Icxolu <10486322+Icxolu@users.noreply.github.com>

* Update guide/src/types.md

Co-authored-by: Icxolu <10486322+Icxolu@users.noreply.github.com>

* Update src/lib.rs

* review: Icxolu

* Update guide/src/python-from-rust.md

Co-authored-by: Adam Reichold <adamreichold@users.noreply.github.com>

* Update guide/src/async-await.md

Co-authored-by: Adam Reichold <adamreichold@users.noreply.github.com>

* review: adamreichold

---------

Co-authored-by: Lily Foote <code@lilyf.org>
Co-authored-by: Icxolu <10486322+Icxolu@users.noreply.github.com>
Co-authored-by: Adam Reichold <adamreichold@users.noreply.github.com>
2024-03-10 15:51:51 +00:00
David Hewitt 75af678f43
docs: use kebab-case instead of snake_case for guide URLs (#3942)
* guide: use kebab-case instead of snake_case

* fixup doctest names

Co-authored-by: Icxolu <10486322+Icxolu@users.noreply.github.com>

* review: Icxolu

* fix relative url

* also remap latest pyo3

* fixup python_from_rust

---------

Co-authored-by: Icxolu <10486322+Icxolu@users.noreply.github.com>
2024-03-09 20:10:58 +00:00
Icxolu 908e661237
deprecate gil-refs in "self" position (#3943)
* deprecate gil-refs in "self" position

* feature gate explicit gil-ref tests

* fix MSRV

* adjust bracketing

---------

Co-authored-by: David Hewitt <mail@davidhewitt.dev>
2024-03-09 09:52:12 +00:00
David Hewitt 14d1d2a9ee
docs: use `lychee` to check link URLs (#3941)
* guide: install `mdbook-linkcheck`

* use `shutil` to copy license files

* move from `mdbook-linkcheck` to `lychee`

* clean guide & doc build products before build

* fix more broken links

* review: mejrs
2024-03-08 14:10:47 +00:00
David Hewitt 770d9b7f01
add `FromPyObjectBound` trait for extracting `&str` without GIL Refs (#3928)
* add `FromPyObjectBound` adjustment for `&str` without GIL Refs

* review: alex, Icxolu feedback

* add newsfragment

* add newsfragment for `FromPyObject` trait change

* make some examples compatible with abi3 < 3.10

* seal `FromPyObjectBound`

* fixup chrono_tz conversion
2024-03-08 07:43:48 +00:00
Icxolu 31c4820010
deprecate `&PyModule` as `#[pymodule]` argument type (#3936)
* deprecate `&PyModule` as `#[pymodule]` argument type

* cleanup

* add ui tests

* fix deprecations in tests

* fix maturin and setuptools-rust starters

* run `deprecated` ui test only when `gil-refs` as disabled
2024-03-08 00:28:11 +00:00
Thomas Tanon fbd531195a
PyAddToModule: Properly propagate initialization error (#3919)
Better than panics
2024-03-06 18:20:02 +00:00
Thomas Tanon 0f7ddb19a5
PyPy: remove PyCode (PyCode_Type does not exist) (#3934) 2024-03-06 18:19:43 +00:00
Thomas Tanon d35f41e0bf
Chrono: allow deprecation warning until upgrading to 0.4.35+ (#3935)
* Chrono: allow deprecation warning until upgrading to 0.4.35+

Requiring 0.4.35 is blocked on MSRV (Chrono: 1.61, PyO3: 1.56)

* also allow deprecated chrono in example

---------

Co-authored-by: David Hewitt <mail@davidhewitt.dev>
2024-03-06 17:49:43 +00:00
David Hewitt 57bbc32e7c
add `experimental-async` feature (#3931)
* add `experimental-async` feature

* gate async doctests on feature
2024-03-06 00:54:45 +00:00
Thomas Tanon fe84fed966
Allow inline struct, enum, fn and mod inside of declarative modules (#3902)
* Inline struct, enum, fn and mod inside of declarative modules

* remove news fragment

---------

Co-authored-by: David Hewitt <mail@davidhewitt.dev>
2024-03-06 00:31:56 +00:00
David Hewitt b08ee4b7e1
remove `gil-refs` feature from `full` feature (#3930) 2024-03-04 22:23:35 +00:00