Commit Graph

397 Commits

Author SHA1 Message Date
Adam Reichold edf50eec17 Bump proptest which is possible after the MSRV bump. 2023-06-05 15:10:00 +02:00
Adam Reichold eb292711a7 Drop test indirection required only until Rust 1.54. 2023-06-05 12:43:15 +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 f0b7399705 Add benchmark showing that extract::<i64> is costly due to PyNumber_Index trying hard. 2023-05-26 07:47:45 +02:00
Adam Reichold c34870cb73 Remove compiler UI tests from package distribution since they only work reliably using the current stable version Rust, e.g. in our CI. 2023-05-25 21:37:05 +02:00
est31 6fcc790f8b Update memoffset to 0.9 2023-05-21 09:56:55 +02:00
David Hewitt 941ee18d22 add benchmark for isinstance chain 2023-05-18 22:10:45 +01:00
David Hewitt dd24c9ea71 remove `Python::acquire_gil` 2023-05-09 09:39:23 +02: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
David Hewitt bfcc1f8c27 update release notes for 0.18.3 2023-04-13 22:47:55 +01:00
David Hewitt e7e58ba51e update release notes for 0.18.2 2023-03-24 20:40:06 +00:00
messense 2ac6006ec8
Disable default features of `chrono`
To avoid bringing `time` v0.1.x into dependency graph, see https://github.com/time-rs/time/issues/293
2023-02-09 21:27:31 +08:00
David Hewitt 92cca896de release notes for 0.18.1 2023-02-07 21:38:07 +00:00
David Hewitt 224a4160b4 release: 0.18.0 2023-01-17 19:04:30 +00:00
David Hewitt 20ca3be659 inspect: gate behind `experimental-inspect` feature 2023-01-15 12:41:23 +00:00
messense 15b1ff6c9a
Relax hashbrown version constraint to allow 0.13.x 2023-01-11 23:13:24 +08:00
messense cb969b7ea0
Update send_wrapper to 0.6 2023-01-11 23:10:11 +08:00
messense d6b15af0ff
Update memoffset to 0.8 2023-01-11 23:09:51 +08:00
Gilad Naaman 3e4cf7843a Relax indexmap dependency 2023-01-02 09:28:27 +02:00
David Hewitt f2608a923c remove functionality deprecated in 0.16 2022-12-28 12:23:53 +00:00
David Hewitt 87b6a9bd92 ci: run pyo3-ffi-check using nox 2022-12-26 08:50:33 +00:00
David Hewitt 97487ffbb5 add abi3-py311 feature 2022-11-23 08:08:12 +00:00
Joel Natividad 91adca3b04 bump memoffset from 0.6.5 to 0.7 2022-11-20 20:23:11 -05:00
David Hewitt 548e90fcec release: 0.17.3 2022-11-01 20:47:46 +00:00
Bruno Kolenbrander 4a04603c2c
Don't use intocallback in method macros (#2664)
* Don't use intocallback in method macros

Co-authored-by: mejrs <>
2022-10-16 10:35:58 +01:00
David Hewitt bd40011e93 release: 0.17.2 2022-10-04 08:13:53 +01: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
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 0391b3b0c1 inventory: update to 0.3 2022-07-03 15:22:25 +01:00
mejrs 2d94cb4a2d use memoffset instead 2022-06-12 18:28:21 +02:00
David Hewitt 3dcbcb7a95 update main to reflect 0.16.5 release 2022-05-15 20:31:00 +01:00
David Hewitt 8636db67f5 add regression test for PEP 587 2022-05-15 16:08:21 +01:00
messense c477718fe7
Add support for generating non-abi3 python import libraries for Windows
targets
2022-05-12 14:32:20 +08:00
mejrs f1e5d4c9a1 Un-ignore and expand on doc examples 2022-05-03 00:47:09 +02:00
cuishuang 19e32a0621 fix some typos
Signed-off-by: cuishuang <imcusg@gmail.com>
2022-04-24 22:06:32 +08:00
David Hewitt 0787b670e8 pyproto: make deprecated feature opt-in 2022-04-21 20:19:14 +01:00
messense 97a9121025
pyo3-ffi: forward `extension-module` feature to `pyo3-build-config` 2022-04-19 13:17:47 +08:00
messense 1276068891
Add `generate-abi3-import-lib` feature to `pyo3-ffi` 2022-04-19 13:17:43 +08:00
Adam Reichold d2caa056e9 release: 0.16.4 2022-04-14 07:56:42 +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
Sergey Kvachonok 479fe6781f pyo3-build-config: Add `python3-dll-a` crate support
Automatically generate `python3.dll` import libraries for Windows
compile targets in the build script.

Adds a new PyO3 crate feature `generate-abi3-import-lib` enabling
automatic import library generation.

Closes #2231
2022-04-10 16:45:32 +03:00
David Hewitt 1ae0971a09 release: 0.16.3 2022-04-05 04:05:57 +01:00
Adam Reichold db109867d3 Add intern! macro which can be used to amortize the cost of creating Python objects by storing them inside a GILOnceCell. 2022-04-03 21:16:42 +02:00
David Hewitt 2813c87eaf
Merge pull request #2092 from aganders3/export-conf
Add export-config feature to pyo3-build-config
2022-03-23 11:16:04 +00:00
Sergey Kvachonok 7a44aa1070 pyo3-macros-backend: Replace `pyo3-build-config` with `abi3` feature
Python 3.6 and older are not supported by the current PyO3 version,
so the removed interpreter version check was a no-op.

`pyo3_build_config::get()` attempts to read a config file from disk
when PyO3 is cross-compiling, which is probably bad for rust-analyzer
and other IDEs that attempt to sandbox the proc macro code.
2022-03-23 09:48:15 +03:00
Ashley Anderson 272d2bc0e6
Merge branch 'main' into export-conf 2022-03-22 12:59:54 -04:00
zhangjingqiang 847ffe563c
allow to compile with parking_lot 0.12 2022-03-22 13:50:25 +08:00
Ashley Anderson bbe7a493d6 Refactor to serialize the whole InterpreterConfig into DEP_PYTHON_PYO3_CONFIG 2022-03-17 12:10:38 -04:00
Ashley Anderson bc356f23e0 Fix coverage for pyo3-build-config CI ("full" feature) 2022-03-17 11:20:37 -04:00
Adam Reichold 922bbfc92d release: 0.16.2 2022-03-15 19:20:00 +01:00
Adam Reichold 1e7275c924 Move links key from pyo3 to pyo3-ffi
Instead of a fake build dependency, move the links key from pyo3 to pyo3-ffi
which according to [1] is a prerequisite for build scripts to emit meta-data
that can be used by other build scripts which would incidentally ensure the
ordering between the build script of pyo3 and pyo3-ffi that we need.

[1] https://doc.rust-lang.org/cargo/reference/build-script-examples.html#using-another-sys-crate
2022-03-15 12:42:54 +01:00
Adam Reichold 0c7a13fbe1 Make pyo3-ffi a build dependency of pyo3 to ensure that its build script has finished before pyo3's build script starts. 2022-03-15 12:19:13 +01:00
David Hewitt 7056bae21f release: 0.16.1 2022-03-05 16:21:44 +00:00
David Hewitt 2bd64c4962 guide: tidy up doctests 2022-03-04 22:50:12 +00:00
Adam Reichold 2fa91ada40 Extend optional dependency supported versions to include 0.12. 2022-03-04 08:30:15 +01:00
David Hewitt 4c434a21bd release: 0.16.0 2022-02-27 20:28:51 +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 558549e1c2 pyproto: split into new feature 2022-02-05 16:51:31 +00:00
David Hewitt 8b47f4f120 pytests: merge benchmark and test crates 2022-02-05 10:16:46 +00:00
DSPOM 6a9a9ba38a
move ffi module to separate crate 2022-01-31 13:27:16 +01:00
David Hewitt 0991aa9f37 ci: add coverage for pytests 2022-01-22 20:06:57 +00:00
messense ce80b7e0f3 Switch from tox to nox 2022-01-17 00:24:33 +08:00
David Hewitt ff37f24625 macros: accept paths in wrap_x macros 2021-12-30 12:46:57 +00:00
Bruno Kolenbrander ac66392068
Merge branch 'PyO3:main' into aliases 2021-12-28 04:50:03 +01:00
David Hewitt 19ecd177c3
Merge pull request #2067 from davidhewitt/xtask-coverage
xtask: add coverage command
2021-12-27 09:48:54 +00:00
Bruno Kolenbrander 4d1d859a64
Merge branch 'main' into aliases 2021-12-24 22:28:22 +01:00
Bruno Kolenbrander ff202f4660
Apply suggestions from code review
Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2021-12-24 08:12:04 +01:00
mejrs 6afd80a26f Create full feature and change doc rendering 2021-12-22 12:09:16 +01:00
David Hewitt 492b7e4c0f macros: optimize generated code for #[derive(FromPyObject)] 2021-12-22 08:34:05 +00:00
David Hewitt ff6fb5dcc2 benches: add bench_frompyobject 2021-12-22 00:27:13 +00:00
David Hewitt d520961b3f xtask: add coverage command 2021-12-21 22:28:36 +00: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
David Hewitt 6433d884fc dev: remove self dev dependency 2021-12-08 07:48:58 +00:00
David Hewitt f17e0d35cd inventory: update to 0.2 2021-11-22 22:57:58 +00:00
David Hewitt 70030f130d python: drop support for 3.6 2021-11-20 13:02:42 +00:00
David Hewitt 6a65f98bd2 msrv: bump to 1.48 2021-11-19 10:10:59 +00:00
David Hewitt eb5059acc7 release: 0.15.1 2021-11-18 07:34:22 +00:00
David Hewitt 47747444c7 release: 0.15.0 2021-11-03 23:00:38 +00:00
Georg Brandl 4bbfee831f Cargo.toml: sort dependencies by type
In particular, distinguish optional crates between those
that are necessary for some named feature (e.g. macros),
and those that can be activated as their own feature
(e.g. anyhow).
2021-10-30 10:07:22 +02:00
David Hewitt 9bbc49875d deps: loosen trybuild requirement to allow versions newer than 1.0.49 2021-10-19 23:25:04 +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
mejrs d3771e5973 Pin transitive dependencies to msrv 2021-10-15 03:07:24 +02: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
Bruno Kolenbrander 49570db3fc
chore: pin trybuild version (#1906)
chore: pin trybuild version to 1.0.49
2021-10-10 17:22:29 +02:00
David Hewitt a5d0aa777c py310: add abi3-py310 feature 2021-09-26 16:21:35 +01:00
David Hewitt dca02a92ce changelog: updates for 0.14.5 backports 2021-09-05 15:19:36 +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
Gregory Szorc 82d9b44f5e cargo: add `links = "python"`
PyOxidizer has crates depending on `pyo3` that would like to access
the `pyo3` crate configuration. (This use case isn't unique to
PyOxidizer.)

Cargo has a facility for enabling the build scripts of dependent
crates to access _exported_ variables via `DEP_` environment
variables. However, this only works if the exporting crate defines a
`links` key in its Cargo manifest. See
https://doc.rust-lang.org/cargo/reference/build-scripts.html#the-links-manifest-key.

While `pyo3`'s build script doesn't yet export the variables that
PyOxidizer will need, a prerequisite to making this work is adding
the `links` key. Since this change could introduce unintended
side-effects, it warrants being made in its own commit, which is
why we're making this change outside of #1793.

I _think_ this change should be mostly safe: the `links` key is
effectively metadata advertising that a crate links against a named
library. The only side-effects setting it has is to enable the
aforementioned `DEP_` environment variables in build scripts and
enforcing a limitation that only a single crate may link against the
same native library. I believe the only potential for this change
to cause problems is if there are multiple crates with `links =
"python"` entries. I'm not aware of any other crates that advertise
`links = "python"`: even `python3-sys` / `cpython` use `links =
"python3"` so this change should not prevent dual use of `pyo3` and
`cpython` in the same build.
2021-08-30 09:47:54 -07:00
David Hewitt 5119bad580 changelog: updates for 0.14.4 2021-08-29 08:07:44 +01:00
David Hewitt bc1a983371 changelog: update for 0.14.3 release 2021-08-22 01:25:29 +01:00
mejrs e753d77e4a deduplicate documentation 2021-08-19 22:55:39 +02:00
Matthew Treinish d575c30eb6
Update Cargo.toml
Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2021-08-16 18:22:46 -04:00
Matthew Treinish 60db3a45b3
Expand supported num-complex versions
When building an extension with rust-numpy and ndarray on the MSRV of
1.41 with complex numbers. The num-complex crate version needs to be
0.2 which was the pinned version as of ndarray 0.13.1 which was the last
release of ndarray that supported building with rust 1.41. However, the
pyo3 pinned version of 0.4 is incompatible with this and will cause an
error when building because of the version mismatch. To fix this This
commit expands the supported versions for num-complex to match what
rust-numpy uses [1] so that we can build pyo3, numpy, ndarray, and
num-complex in an extension with rust 1.41.

Fixes #1798

[1] https://github.com/PyO3/rust-numpy/blob/v0.14.1/Cargo.toml#L19
2021-08-16 14:43:07 -04:00
David Hewitt b1abe03984 ci: update cargo-llvm-cov 2021-08-15 23:54:43 +01:00
David Hewitt c59f518f76 ci: downgrade trybuild to 1.0.43 2021-08-11 08:39:37 +01:00