Commit Graph

300 Commits

Author SHA1 Message Date
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