Commit graph

5124 commits

Author SHA1 Message Date
bors[bot] 02fa6b85ba
Merge #2864
2864: Add a section on memory management for `extension` r=davidhewitt a=haixuanTao

Adding a special case of memory management when writing an extension.

This is a documentation of: https://github.com/PyO3/pyo3/issues/1056 and https://github.com/PyO3/pyo3/issues/2853


Co-authored-by: Haixuan Xavier Tao <tao.xavier@outlook.com>
Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2023-01-10 07:44:27 +00:00
David Hewitt eea2a31bd3 adjust location and wording for extension module memory management 2023-01-10 07:42:39 +00:00
Haixuan Xavier Tao 8af9d2a19a Add a section on memory management for extension
Adding a special case of memory management when writing an extension.

This is a documentation of: https://github.com/PyO3/pyo3/issues/1056 and https://github.com/PyO3/pyo3/issues/2853
2023-01-10 07:37:21 +00:00
bors[bot] 34b9445faf
Merge #2869
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>
2023-01-08 20:54:43 +00:00
bors[bot] bbf972f144
Merge #2868
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>
2023-01-08 20:04:21 +00:00
David Hewitt 70c3260262 remove fallback redirect for netlify -> gh-pages 2023-01-08 19:58:56 +00:00
David Hewitt b6c71a8525 change latest URL from netlify proxy to redirect 2023-01-08 19:55:24 +00:00
bors[bot] 94c568d746
Merge #2678
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>
2023-01-06 08:53:36 +00:00
David Hewitt 8651d3b0e8 address feedback in review #2678 2023-01-06 08:53:00 +00:00
James Welchman e52dbc907d GH-2649 example for inserting moulde in sys.dict 2023-01-05 21:26:47 +00:00
bors[bot] c09d24e64d
Merge #2859
2859: Remove `libpython.so` from cross compile error message r=davidhewitt a=messense

See https://github.com/PyO3/pyo3/discussions/2858.

Same as https://github.com/PyO3/maturin/pull/1389

Co-authored-by: messense <messense@icloud.com>
2023-01-05 10:17:09 +00:00
messense 7e89456c77
Remove libpython.so from cross compile error message 2023-01-05 17:07:21 +08:00
bors[bot] 09470eb42c
Merge #2852
2852: Fix links in `logging.md` r=adamreichold a=messense

It's broken: https://pyo3.rs/main/ecosystem/logging

After: https://deploy-preview-2852--pyo3.netlify.app/main/ecosystem/logging

Co-authored-by: messense <messense@icloud.com>
2023-01-03 12:23:09 +00:00
messense c722402e46
Fix links in logging.md 2023-01-03 20:03:51 +08:00
bors[bot] 6da1fc7191
Merge #2835
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>
2023-01-03 10:24:11 +00:00
Dylan Storey fefd224e4a Update logging.md for logging->rust
Demonstrates how to register a rust log consumer with a pythong logging instance.
2023-01-03 10:22:54 +00:00
bors[bot] b1104d9aab
Merge #2757
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>
2023-01-02 21:08:08 +00:00
Santo K Thomas 2400d11b24 Updated README.md to add installation instruction for Python shared library on Fedora 2023-01-02 21:06:44 +00:00
bors[bot] 57d188bd56
Merge #2849
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>
2023-01-02 11:53:15 +00:00
Gilad Naaman 3e4cf7843a Relax indexmap dependency 2023-01-02 09:28:27 +02:00
bors[bot] 8af48bbb53
Merge #2796
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 <>
2022-12-29 16:28:26 +00:00
mejrs 530c5b3193 Fix changelog 2022-12-29 15:13:38 +01:00
mejrs 8f51142013 Add changelog 2022-12-28 23:13:55 +01:00
mejrs 5198722dd9 Add test 2022-12-28 23:11:39 +01:00
bors[bot] 688c7dcebd
Merge #2844
2844: update URL in comment to point at correct place r=adamreichold a=alex



Co-authored-by: Alex Gaynor <alex.gaynor@gmail.com>
2022-12-28 19:49:00 +00:00
Alex Gaynor 4875e4b6bf update URL in comment to point at correct place
The branch has drifted and those line ranges are no longer accurate.
2022-12-28 20:48:11 +01:00
bors[bot] cedb5aecb2
Merge #2843
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>
2022-12-28 12:24:59 +00:00
David Hewitt f2608a923c remove functionality deprecated in 0.16 2022-12-28 12:23:53 +00:00
bors[bot] c2adf14f69
Merge #2842
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>
2022-12-28 08:13:58 +00:00
David Hewitt 1e8206c0b8 Stop leaking in new_closure 2022-12-28 07:51:50 +00:00
bors[bot] 31c42cc2c8
Merge #2838
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>
2022-12-27 21:40:57 +00:00
bors[bot] 8c8a576b2d
Merge #2841
2841: correct changelog for 2772 r=mejrs a=davidhewitt

`@mejrs` how's this?

Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2022-12-27 20:21:52 +00:00
David Hewitt f24b1370b6
correct changelog for 2772 2022-12-27 20:14:21 +00:00
bors[bot] 1598991a05
Merge #2772
2772: fix PyUnicodeDecodeError_Create r=davidhewitt a=mejrs

Fixes https://github.com/PyO3/pyo3/issues/2770

Co-authored-by: mejrs <>
Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2022-12-27 16:22:58 +00:00
David Hewitt 5fcc8741e0 add changelog for 2772 2022-12-27 16:19:18 +00:00
mejrs faa578a7c5 fix PyUnicodeDecodeError_Create 2022-12-27 16:13:32 +00:00
David Hewitt 24032fe110 pypy: re-enable PyFunction on 3.8+ 2022-12-27 14:32:43 +00:00
bors[bot] 14d61e6c3e
Merge #2837
2837: netlify: fix examples option on latest nightly r=davidhewitt a=davidhewitt

Looks like `-Zrustdoc-scrape-examples` no longer needs `=examples` value.

Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2022-12-27 13:22:05 +00:00
David Hewitt 850c21ab39 netlify: fix examples option on latest nightly 2022-12-27 13:07:03 +00:00
bors[bot] af2ad45c73
Merge #2833
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>
2022-12-27 00:17:43 +00:00
David Hewitt 30c66fdb8b ci: fix flaky test_pyobject_drop_without_gil_doesnt_decrease_refcnt 2022-12-27 00:49:54 +01:00
bors[bot] 75ca1b2823
Merge #2398
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>
2022-12-26 21:18:23 +00:00
David Hewitt a47079d858 move GILOnceCell initialization detail to the type-level docs 2022-12-26 20:38:25 +00:00
Benoît du Garreau 01fcfedbe5 Add GILOnceCell::get_or_try_init 2022-12-26 20:28:18 +00:00
bors[bot] 2430556235
Merge #2832
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>
2022-12-26 20:27:39 +00:00
David Hewitt 75a120ced6 newsfragments: remove incorrect fragment 2022-12-26 20:26:06 +00:00
bors[bot] 96dd88b4b1
Merge #2831
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>
2022-12-26 12:55:11 +00:00
David Hewitt 20a7087ee0 add gh-pages content directly in netlify site 2022-12-26 12:47:57 +00:00
bors[bot] 097af010e2
Merge #2813
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>
2022-12-26 10:02:54 +00:00
David Hewitt 87b6a9bd92 ci: run pyo3-ffi-check using nox 2022-12-26 08:50:33 +00:00