2869: change latest URL from netlify proxy to redirect r=davidhewitt a=davidhewitt
Now that we serve all gh-pages content in netlify, it's nicer to have this as a proper redirect rather than a rewrite. Then the user can see what version of the docs they have landed on.
Closes#2867
Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2868: remove fallback rewrite for netlify -> gh-pages r=davidhewitt a=davidhewitt
Instead of having a rewrite to serve all content in gh-pages but not in netlify, instead I've added a webhook so that netlify will pull and rebuild when there is a push to gh-pages.
Fixes#2850
Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2678: github pages example for sys.dict modules r=davidhewitt a=flickpp
Add an example into `python_from_rust.md` for creating a module and inserting it into the `sys.modules` dictionary.
As discussed here:
GH-2649 example for inserting moulde in sys.dict
Co-authored-by: James Welchman <jamesw@plantpot.ai>
Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2835: Update logging.md for logging->rust r=davidhewitt a=dylanbstorey
Demonstrates how to register a rust log consumer with a pythong logging instance.
Thank you for contributing to pyo3!
Please consider adding the following to your pull request:
- an entry for this PR in newsfragments - see [https://pyo3.rs/main/contributing.html#documenting-changes]
- docs to all new functions and / or detail in the guide
- tests for all new or changed functions
PyO3's CI pipeline will check your pull request. To run its tests
locally, you can run ```cargo xtask ci```. See its documentation
[here](https://github.com/PyO3/pyo3/tree/main/xtask#readme).
Co-authored-by: Dylan Storey <dylanbstorey@users.noreply.github.com>
2757: Updated README.md to add installation instruction for Python shared l… r=davidhewitt a=santokalayil
…ibrary on Fedora
Thank you for contributing to pyo3!
Please consider adding the following to your pull request:
- an entry for this PR in newsfragments - see [https://pyo3.rs/main/contributing.html#documenting-changes]
- docs to all new functions and / or detail in the guide
- tests for all new or changed functions
PyO3's CI pipeline will check your pull request. To run its tests
locally, you can run ```cargo xtask ci```. See its documentation
[here](https://github.com/PyO3/pyo3/tree/main/xtask#readme).
Co-authored-by: Santo K Thomas <santokalayil@gmail.com>
2849: Relax indexmap dependency r=adamreichold a=gnaaman-dn
Halloo,
Noticed some version resolve errors when trying to use the `indexmap` features.
```bash
❯ cargo add pyo3 --features indexmap
❯ cargo add serde_yaml
Updating crates.io index
Adding serde_yaml v0.9.16 to dependencies.
error: failed to select a version for `indexmap`.
... required by package `pyo3 v0.17.3`
... which satisfies dependency `pyo3 = "^0.17.3"` of package `pyo3-indexmap v0.1.0 (/home/dn/repos/pyo3-indexmap)`
versions that meet the requirements `>=1.6, <1.8` are: 1.7.0, 1.6.2, 1.6.1, 1.6.0
all possible versions conflict with previously selected packages.
previously selected package `indexmap v1.9.0`
... which satisfies dependency `indexmap = "^1.9"` of package `serde_yaml v0.9.16`
... which satisfies dependency `serde_yaml = "^0.9.16"` of package `pyo3-indexmap v0.1.0 (/home/dn/repos/pyo3-indexmap)`
failed to select a version for `indexmap` which could resolve this conflict
```
Couldn't find a specific reason for this limitation so I tried upgrading the dependency and running the tests.
Ran the tests locally with `indexmap==v1.9.2`:
```
❯ cargo test --features indexmap conversions::indexmap
...
running 4 tests
test conversions::indexmap::test_indexmap::test_indexmap_indexmap_insertion_order_round_trip ... ok
test conversions::indexmap::test_indexmap::test_indexmap_indexmap_to_python ... ok
test conversions::indexmap::test_indexmap::test_indexmap_indexmap_into_python ... ok
test conversions::indexmap::test_indexmap::test_indexmap_indexmap_into_dict ... ok
test result: ok. 4 passed; 0 failed; 0 ignored; 0 measured; 536 filtered out; finished in 0.03s
```
(Tried running `cargo xtask ci` but it failed on some warnings in the generated FFI code)
This relaxes the restrictions on `indexmap` so that the latest version is also supported,
hope that's okay.
Cheers,
Gilad
Co-authored-by: Gilad Naaman <gnaaman@drivenets.com>
2796: Forward cfgs on pyclass fields to the method defs r=davidhewitt a=mejrs
With this and the cfg_attr PR, I don't need cfg_eval at all anymore :)
- [x] needs some more tests
Co-authored-by: mejrs <>
2843: remove functionality deprecated in 0.16 r=davidhewitt a=davidhewitt
Simple cleanup to remove all functionality marked deprecated in the 0.16 releases.
Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2842: Stop leaking in `new_closure` r=adamreichold a=davidhewitt
This is a rebase of #2690 which simplifies the `MaybeLeaked` abstraction from that PR with just `Cow<'static, CStr>`.
This enabled me to annotate with `FIXME` all the places where we still leak; I wonder if we could potentially use `GILOnceCell` in future and statics to avoid those. As those callsities are in `#[pyclass]` and `#[pyfunction]` these are effectively in statics anyway, but it would be nice to tidy up.
Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2838: pypy: re-enable PyFunction on 3.8+ r=davidhewitt a=davidhewitt
PyPy [fixed the crashes associated with `PyFunction](https://foss.heptapod.net/pypy/pypy/-/issues/3776#note_191626) in PyPy 7.3.10 (for 3.8+) - which I think is to be released shortly. So I think we should re-enable this API and treat it as a PyPy bug which users can mitigate by updating their PyPy.
Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2833: ci: fix flaky test_pyobject_drop_without_gil_doesnt_decrease_refcnt r=adamreichold a=davidhewitt
Closes#2723
I think `@adamreichold` is correct in what causes the flakiness, and the solution in this case seems straightforward enough - just pass `reference` off to another thread to drop it (as that thread won't have the GIL), no events needed.
Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2398: Add `GILOnceCell::get_or_try_init` r=mejrs a=a1phyr
This is similar to [`OnceCell::get_or_try_init`](https://docs.rs/once_cell/latest/once_cell/sync/struct.OnceCell.html#method.get_or_try_init) and is very useful for fallible initialization.
Co-authored-by: Benoît du Garreau <bdgdlm@outlook.com>
Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2832: newsfragments: remove incorrect fragment r=davidhewitt a=davidhewitt
Accidentally left this entry in #2826 after splitting out #2827.
Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2831: add gh-pages content directly in netlify site r=davidhewitt a=davidhewitt
Last attempt to find a solution for #2819.
By adding the GitHub pages content directly to the netlify site during build, netlify should be able to make better URL redirects.
Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2813: ci: run pyo3-ffi-check using nox r=davidhewitt a=davidhewitt
Makes it easier to run pyo3-ffi-check locally :)
Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2826: ci: run checks for all platforms on PR r=adamreichold a=davidhewitt
I've been struggling a little to merge PRs with the new bors workflow; overall I think the lighter PR workflow is better but the number of combinations of older pythons / platforms not covered makes it easy for the bors step to fail.
This PR tries to improve the situation by merging the `clippy` and `check-target` job and running it for all supported platforms on PR. Hopefully if these are green, then there's high likelihood that tests will build and should pass unless there's logic errors.
While creating this I found a build error on PyPy which made me notice we can support `PyList::get_item_unchecked` for PyPy, so I added it.
Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2784: Automatically generate `__text_signature__` for all functions r=davidhewitt a=davidhewitt
This PR makes it so that PyO3 generates `__text_signature__` by default for all functions. It also introduces `#[pyo3(text_signature = false)]` to disable the built-in generation.
There are a few limitations which we can improve later:
- All default values are currently set to `...`. I think this is ok because `.pyi` files often do the same. Maybe for numbers, strings, `None` and `True`/`False` we could render these in a future PR.
- No support for `#[new]` yet.
Alternative design ideas:
- Only autogenerate for methods with `#[pyo3(signature = (...))]` annotation. I started with this, and then decided it made sense to do it for everything.
- Opt-out with `#[pyo3(text_signature = None)]`. This is slightly harder to parse in the macro, but matches the final result in Python better, so if this looks preferable to others, I can change from `text_signature = false` to `text_signature = None`.
There's some small tidying up / refactoring to do before this merges (happy to take suggestions on this), however the general logic, design and docs are ready for review.
2827: pypy: enable `PyList::get_item_unchecked` r=adamreichold a=davidhewitt
Split out from #2826. Approved previously as part of that review.
Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>