Commit Graph

6404 Commits

Author SHA1 Message Date
David Hewitt a5a3f3f7f2
allow `#[pymodule(...)]` to accept all relevant `#[pyo3(...)]` options (#4330) 2024-07-10 22:38:38 +00:00
Larry Z 6be80647cb
Prevent building in GIL-less environment (#4327)
* Prevent building in GIL-less environment

* Add change log

* add "yet" to phrasing

* Add testing to build script

* add link to issue

* Fix formatting issues

---------

Co-authored-by: David Hewitt <mail@davidhewitt.dev>
2024-07-10 18:39:39 +00:00
David Hewitt 90c4799951
docs: fixups to 0.22 migration guide (#4332) 2024-07-10 14:18:13 +00:00
David Hewitt 3c65132da5
remove all functionality deprecated in PyO3 0.21 (#4323)
* remove all functionality deprecated in PyO3 0.21

* further adjustments after removing deprecated APIs
2024-07-10 13:38:30 +00:00
David Hewitt 32b6a1aef1
docs: use versioned links from docs to guide (#4331)
* use versioned links from docs to guide

* use standard python version in `guide-build` ci job
2024-07-10 12:30:01 +00:00
David Hewitt c7c1dff710
ci: check minimal-versions on MSRV feature powerset (#4273)
* ci: check minimal-versions on MSRV feature powerset

* fix msrv arg

* bump num-bigint floor to 0.4.2

* try fix build syntax
2024-07-10 11:36:31 +00:00
Giovanni Barillari 1279232701
Add Granian to example projects (#4329) 2024-07-10 09:16:23 +00:00
David Hewitt 97d60e869b
clean up hygiene tests (#4328) 2024-07-09 21:28:15 +00:00
David Hewitt 8652ac8e1c
remove all functionality deprecated in 0.20 (#4322)
* remove all functionality deprecated in 0.20

* bump version to 0.23.0-dev

* undo unintended revert

* fixup UI test
2024-07-09 16:44:27 +00:00
Alex Gaynor e73112f3f6
Automatically treat nested modules as submodules (#4308)
fixes #4286
2024-07-09 12:15:12 +00:00
David Hewitt 186c7d3315
docs: improve signposting to bound and traits (#4325)
* docs: improve signposting to bound and traits

* update UI tests
2024-07-09 11:53:11 +00:00
Sede Soukossi 1861d6d379
docs: Fix mismatch return value, remove redundant error propagation, and additional fixes (#4318)
* Fix mismatch return value, remove redundant error propagation, and fix typo

* Update guide/src/function/signature.md

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

---------

Co-authored-by: Lily Foote <code@lilyf.org>
2024-07-08 20:30:44 +00:00
Icxolu 3c155d9fef
remove the gil-ref deprecations infrastructure (#4320) 2024-07-08 13:40:27 +00:00
David Hewitt d5c886f4c0
simplify implementation of `Py::clone_ref` (#4313) 2024-07-07 06:53:43 +00:00
David Hewitt 59c4fa3f24
release: 0.22.1 (#4314) 2024-07-06 22:00:28 +00:00
Alex Gaynor 9afc38ae41
fixes #4285 -- allow full-path to pymodule with nested declarative modules (#4288) 2024-07-05 09:16:06 +00:00
Owen Leung 5860c4f7e9
implement PartialEq for Pybool & bool (#4305)
* implement PartialEq for Pybool

implement PartialEq for Pybool

* fix failing cargodoc and add changelog file

* Use PR number for change log file

* Add false checking into test
2024-07-05 09:10:38 +00:00
David Hewitt 0af0227834
fix deprecation warning for trailing optional on `#[setter]` functions (#4304)
* fix deprecation warning for trailing optional on `#[setter]` functions

* add comment
2024-07-04 10:08:22 +00:00
Nathan Goldbaum ee9123a2d2
Fix link in the contribution guide (#4306) 2024-07-02 19:28:26 +00:00
Alex Gaynor ccd04475a3
refs #4286 -- allow setting submodule on declarative pymodules (#4301) 2024-07-02 11:24:47 +00:00
Alex Gaynor f3603a0a48
Avoid generating functions that are only ever const evaluated with declarative modules (#4297)
Refs #4286
2024-07-01 21:54:50 +00:00
Kyle Barron 872bd7e6f7
Add pyo3-arrow to README (#4302) 2024-07-01 16:26:17 +00:00
Ben Beasley 8f7450e33d
Fix 128-bit int regression on big-endian with Python <3.13 (#4291)
Fixes #4290.
2024-06-26 19:21:31 +00:00
jatoben 7c2f5e80de
Don't raise `TypeError` from generated equality method (#4287)
* Don't raise TypeError in derived equality method

* Add newsfragment
2024-06-26 05:41:42 +00:00
David Hewitt 2e2d4404a6
release: 0.22.0 (#4266) 2024-06-24 19:06:42 +00:00
David Hewitt 91d8683814
improve deprecation message on implicit trailing optionals (#4282) 2024-06-24 13:38:33 +00:00
Bruno Kolenbrander 6a0221ba2c
document FnType and refactor FnType::self_arg (#4276) 2024-06-23 10:36:19 +00:00
Aneesh Agrawal c67625d683
Revamp PyType name functions to match PEP 737 (#4196)
* Revamp PyType name functions to match PEP 737

PyType::name uses `tp_name`, which is not consistent.
[PEP 737](https://peps.python.org/pep-0737/) adds a new path forward,
so update PyType::name and add PyType::{module,fully_qualified_name}
to match the PEP.

* refactor conditional code to handle multiple Python versions better

* return `Bound<'py, str>`

* fixup

---------

Co-authored-by: David Hewitt <mail@davidhewitt.dev>
2024-06-22 22:10:27 +00:00
David Hewitt a2f9399906
make datetime from timestamp tests compare against Python result (#4275)
* attemp to fix range for st.datetime

* remove example

* try fixing to utc

* make datetime from timestamp tests compare against Python result

---------

Co-authored-by: Cheukting <cheukting.ho@gmail.com>
2024-06-22 22:09:59 +00:00
Code Apprentice 908ef6ad84
Implement PartialEq for PyBytes and [u8] (#4259)
* Copy pasta implementation from types/string.rs

* changelog

* I think I don't need a special implementation for 3.10 or ABI

* Copy pasta tests

* Fix comment with correct type

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

* Fix implementation

* Use slice in tests

* Try renaming changelog file

* Fix doc example

* Fix doc example

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

---------

Co-authored-by: Icxolu <10486322+Icxolu@users.noreply.github.com>
2024-06-22 22:08:57 +00:00
Weijie Guo c4d18e5ee3
Change `search_lib_dir`'s return type to Result (#4043)
* Change `search_lib_dir`'s return type to Result

* add changelog

* add coverage and a hint to `PYO3_CROSS_LIB_DIR`

---------

Co-authored-by: David Hewitt <mail@davidhewitt.dev>
2024-06-22 14:01:33 +00:00
David Hewitt 0b967d427a
use `ffi::MemberGef` for `#[pyo3(get)]` fields of `Py<T>` (#4254)
* use `ffi::MemberGef` for `#[pyo3(get)]` fields of `Py<T>`

* tidy up implementation

* make it work on MSRV :(

* fix docs and newsfragment

* clippy

* internal docs and coverage

* review: mejrs
2024-06-21 23:33:34 +00:00
David Hewitt 41fb9572b6
docs: update docstring on `Python` for `Bound` API (#4274) 2024-06-21 11:30:57 +00:00
Alex Gaynor 9ff3d237c1
Update dependencies to reflect minimal versions (#4272)
Based on testing locally with `rm -f Cargo.lock && cargo +nightly check --tests --all -Z minimal-versions`
2024-06-21 10:05:09 +00:00
Icxolu 56341cbc81
emit c-string literals on Rust 1.77 or later (#4269)
* emit c-string literals on Rust 1.77 or later

* only clone `PyO3CratePath` instead of the whole `Ctx`

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

---------

Co-authored-by: mejrs <59372212+mejrs@users.noreply.github.com>
Co-authored-by: David Hewitt <mail@davidhewitt.dev>
2024-06-21 08:49:33 +00:00
David Hewitt ca82681615
ci: minor cleanups following 1.63 MSRV (#4239)
* ci: minor cleanups following 1.63 MSRV

* correct `invalid_pymethods_duplicates` UI test

* fix `nightly` feature
2024-06-21 07:02:31 +00:00
Bruno Kolenbrander a983b2fe7b
Bump diagnostic_namespace rust version (#4268) 2024-06-20 21:56:17 +00:00
David Hewitt 30add032b5
improve code generated by `c_str!` macro (#4270)
* improve code generated by `c_str!` macro

* fix clippy
2024-06-20 21:41:16 +00:00
Bruno Kolenbrander b25b3b3a7b
Improve the span and message for return types of pymethod/functions (#4220)
* Improve the span and message for return types of pymethod/functions

* Don't pass the span

* fixup trybuild output

---------

Co-authored-by: David Hewitt <mail@davidhewitt.dev>
2024-06-20 09:23:40 +00:00
WÁNG Xuěruì e6b2216b04
Add several missing wrappers to PyAnyMethods (#4264) 2024-06-20 08:16:06 +00:00
David Hewitt 0e142f05dd
add `c_str!` macro to create `&'static CStr` (#4255)
* add `c_str!` macro to create `&'static CStr`

* newsfragment, just export as `pyo3::ffi::c_str`

* fix doc link

* fix doc

* further `c_str!` based cleanups

* [review]: mejrs

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

* rustfmt

* build fixes

* clippy

* allow lint on MSRV

* fix GraalPy import

---------

Co-authored-by: Bruno Kolenbrander <59372212+mejrs@users.noreply.github.com>
2024-06-18 18:09:36 +00:00
Alex Gaynor ddff8bea25
Stabilize declarative modules (#4257) 2024-06-17 01:28:20 +00:00
Alex Gaynor baae9291cc
Update tests for numpy 2.0 (#4258) 2024-06-17 00:05:55 +00:00
Code Apprentice 79591f2161
Add error messages for unsupported macro features on compilation (#4194)
* First implementation

* tweak error message wording

* Fix boolean logic

* Remove redundant parens

* Add test for weakref error

* Fix test

* Reword error message

* Add expected error output

* Rinse and repeat for `dict`

* Add test output file

* Ignore Rust Rover config files

* cargo fmt

* Add newsfragment

* Update newsfragments/4194.added.md

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

* Use ensure_spanned! macro

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

* Use ensure_spanned! macro for weakref error, too

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

* Revert "Ignore Rust Rover config files"

This reverts commit 6c8a2eec581ed250ec792d8465772d649b0a3199.

* Update wording for error message

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

* Update weakref error message, too

* Refactor constant to a pyversions module

* Fix compiler errors

* Another wording update

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

* And make weakref wording the same

* Fix compiler error due to using weakref in our own code

* Fix after merge

* apply conditional pyclass

* update conditional compilation in tests

---------

Co-authored-by: cojmeister <luqas.c@gmail.com>
Co-authored-by: David Hewitt <mail@davidhewitt.dev>
Co-authored-by: Icxolu <10486322+Icxolu@users.noreply.github.com>
2024-06-16 10:23:03 +00:00
David Hewitt 9648d595a5
implement `PartialEq<str>` for `Bound<'py, PyString>` (#4245)
* implement `PartialEq<str>` for `Bound<'py, PyString>`

* fixup conditional code

* document equality semantics for `Bound<'_, PyString>`

* fix doc example
2024-06-16 08:19:21 +00:00
David Hewitt 0b2f19b3c9
fix `__dict__` on Python 3.9 with limited API (#4251)
* fix `__dict__` on Python 3.9 with limited API

* [review] Icxolu suggestions

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

* [review] Icxolu

* missing import

---------

Co-authored-by: Icxolu <10486322+Icxolu@users.noreply.github.com>
2024-06-16 07:57:44 +00:00
David Hewitt 591cdb0bf8
implement `PyModuleMethods::filename` on PyPy (#4249) 2024-06-14 19:08:35 +00:00
Icxolu 5749a08b63
ci: updates for Rust 1.79 (#4244)
* ci: updates for Rust 1.79

* ci: fix beta clippy

* ci: fix `dead_code` warning on nightly
2024-06-13 18:24:13 +00:00
David Hewitt f66124a79b
pypy/graalpy: set `Py_LIMITED_API` when `abi3` requested (#4237)
* pypy/graalpy: set `Py_LIMITED_API` when `abi3` requested

* add newsfragment
2024-06-10 07:26:05 +00:00
JRRudy1 d2dca2169c
Added `as_super` methods to `PyRef` and `PyRefMut`. (#4219)
* Added `PyRef::as_super` and `PyRefMut::as_super` methods, including docstrings and tests. The implementation of these methods also required adding `#[repr(transparent)]` to the `PyRef` and `PyRefMut` structs.

* Added newsfragment entry.

* Changed the `AsRef<U>`/`AsMut<U>` impls for `PyRef` and `PyRefMut` to use the new `as_super` methods. Added the `PyRefMut::downgrade` associated function for converting `&PyRefMut` to `&PyRef`. Updated tests and docstrings to better demonstrate the new functionality.

* Fixed newsfragment filename.

* Removed unnecessary re-borrows flagged by clippy.

* retrigger checks

* Updated `PyRef::as_super`, `PyRefMut::as_super`, and `PyRefMut::downgrade` to use `.cast()` instead of `as _` pointer casts. Fixed typo.

* Updated `PyRef::as_super` and `PyRefMut::downgrade` to use `ptr_from_ref` for the initial cast to `*const _` instead of `as _` casts.

* Added `pyo3::internal_tricks::ptr_from_mut` function alongside the `ptr_from_ref` added in PR #4240. Updated `PyRefMut::as_super` to use this method instead of `as *mut _`.

* Updated the user guide to recommend `as_super` for accessing the base class instead of `as_ref`, and updated the subsequent example/doctest to demonstrate this functionality.

* Improved tests for the `as_super` methods.

* Updated newsfragment to include additional changes.

* Fixed formatting.

---------

Co-authored-by: jrudolph <jrudolph@anl.gov>
2024-06-09 07:17:23 +00:00