Skip to content

Commit

Permalink
chore(deps): update pyo3 requirement from 0.21 to 0.22 (#140)
Browse files Browse the repository at this point in the history
Updates the requirements on [pyo3](https://github.com/pyo3/pyo3) to
permit the latest version.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/pyo3/pyo3/releases">pyo3's
releases</a>.</em></p>
<blockquote>
<h2>PyO3 0.22.0</h2>
<p>This release introduces support for Python 3.13. Please note that
Python 3.13 is still in beta, and while breaking changes are not
expected it is very possible that code compiled against Python 3.13 beta
versions will be incompatible with the final 3.13 release later in the
year.</p>
<p>The minimum supported Rust version has been increased to Rust
1.63.</p>
<p>PyO3's deferred reference counting used to implement <code>Clone for
Py&lt;T&gt;</code> without the global interpreter lock has been
demonstrated to be impossible to implement safely in the general case
and has consequently been changed to panic instead of deferring when
cloning <code>Py&lt;T&gt;</code> without the GIL being held. Given the
nature of panics inside <code>Clone</code> operations being a potential
footgun, this implementation has been moved behind the opt-in
<code>py-clone</code> feature.</p>
<p>Other particularly notable changes include:</p>
<ul>
<li>The <code>#[pyclass]</code> macro now has additional options
<code>#[pyclass(eq, ord, hash)]</code> to automatically generate Python
implementations for equality, ordering and hashing based upon the Rust
<code>PartialEq</code>, <code>PartialOrd</code> and <code>Hash</code>
traits. This can ensure consistency and reduce boilerplate compared to
implementing <code>__eq__</code>, <code>__hash__</code> and so on
manually.</li>
<li>The <code>experimental-declarative-modules</code> feature to support
<code>#[pymodule]</code> on Rust <code>mod</code> items has been
stabilised (and the feature flag removed). The existing implementation
of <code>#[pymodule]</code> on <code>fn</code> items is still present
but soft-deprecated; in the future new features will likely be added
only to declarative modules, and the <code>fn</code> modules may
eventually be deprecated and removed.</li>
<li>The GIL Refs API deprecation started in PyO3 0.21 continues with all
related APIs now being gated behind the <code>gil-refs</code> feature,
and unconditionally deprecated. In PyO3 0.23 these APIs are expected to
be removed.</li>
</ul>
<p>There have been numerous other smaller improvements, changes and
fixes. For full details see the <a
href="https://pyo3.rs/v0.22.0/changelog.html">CHANGELOG</a>.</p>
<p>Please consult the <a
href="https://pyo3.rs/v0.22.0/migration.html">migration guide</a> for
help upgrading.</p>
<p>Thank you to everyone who contributed code, documentation, design
ideas, bug reports, and feedback. The following contributors' commits
are included in this release:</p>
<p><a
href="https://github.com/adamreichold"><code>@​adamreichold</code></a>
<a href="https://github.com/alex"><code>@​alex</code></a>
<a href="https://github.com/aneeshusa"><code>@​aneeshusa</code></a>
<a href="https://github.com/birkenfeld"><code>@​birkenfeld</code></a>
<a href="https://github.com/blmarket"><code>@​blmarket</code></a>
<a href="https://github.com/Cheukting"><code>@​Cheukting</code></a>
<a href="https://github.com/cmpute"><code>@​cmpute</code></a>
<a href="https://github.com/codeguru42"><code>@​codeguru42</code></a>
<a href="https://github.com/Databean"><code>@​Databean</code></a>
<a
href="https://github.com/davidbrochart"><code>@​davidbrochart</code></a>
<a href="https://github.com/davidhewitt"><code>@​davidhewitt</code></a>
<a href="https://github.com/deedy5"><code>@​deedy5</code></a>
<a href="https://github.com/dmatos2012"><code>@​dmatos2012</code></a>
<a href="https://github.com/Icxolu"><code>@​Icxolu</code></a>
<a href="https://github.com/JRRudy1"><code>@​JRRudy1</code></a>
<a href="https://github.com/lfn3"><code>@​lfn3</code></a>
<a href="https://github.com/liammcinroy"><code>@​liammcinroy</code></a>
<a href="https://github.com/linhr"><code>@​linhr</code></a>
<a href="https://github.com/mejrs"><code>@​mejrs</code></a>
<a href="https://github.com/messense"><code>@​messense</code></a>
<a href="https://github.com/newcomertv"><code>@​newcomertv</code></a>
<a href="https://github.com/reswqa"><code>@​reswqa</code></a>
<a href="https://github.com/sk1p"><code>@​sk1p</code></a>
<a
href="https://github.com/SuperJappie08"><code>@​SuperJappie08</code></a>
<a href="https://github.com/Tpt"><code>@​Tpt</code></a>
<a href="https://github.com/wyfo"><code>@​wyfo</code></a>
<a href="https://github.com/xen0n"><code>@​xen0n</code></a>
<a href="https://github.com/Zyell"><code>@​Zyell</code></a></p>
</blockquote>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/PyO3/pyo3/blob/main/CHANGELOG.md">pyo3's
changelog</a>.</em></p>
<blockquote>
<h2>[0.22.0] - 2024-06-24</h2>
<h3>Packaging</h3>
<ul>
<li>Update <code>heck</code> dependency to 0.5. <a
href="https://github.com/PyO3/pyo3/pull/3966">#3966</a></li>
<li>Extend range of supported versions of <code>chrono-tz</code>
optional dependency to include version 0.10. <a
href="https://github.com/PyO3/pyo3/pull/4061">#4061</a></li>
<li>Update MSRV to 1.63. <a
href="https://github.com/PyO3/pyo3/pull/4129">#4129</a></li>
<li>Add optional <code>num-rational</code> feature to add conversions
with Python's <code>fractions.Fraction</code>. <a
href="https://github.com/PyO3/pyo3/pull/4148">#4148</a></li>
<li>Support Python 3.13. <a
href="https://github.com/PyO3/pyo3/pull/4184">#4184</a></li>
</ul>
<h3>Added</h3>
<ul>
<li>Add <code>PyWeakref</code>, <code>PyWeakrefReference</code> and
<code>PyWeakrefProxy</code>. <a
href="https://github.com/PyO3/pyo3/pull/3835">#3835</a></li>
<li>Support <code>#[pyclass]</code> on enums that have tuple variants.
<a href="https://github.com/PyO3/pyo3/pull/4072">#4072</a></li>
<li>Add support for scientific notation in <code>Decimal</code>
conversion. <a
href="https://github.com/PyO3/pyo3/pull/4079">#4079</a></li>
<li>Add <code>pyo3_disable_reference_pool</code> conditional compilation
flag to avoid the overhead of the global reference pool at the cost of
known limitations as explained in the performance section of the guide.
<a href="https://github.com/PyO3/pyo3/pull/4095">#4095</a></li>
<li>Add <code>#[pyo3(constructor = (...))]</code> to customize the
generated constructors for complex enum variants. <a
href="https://github.com/PyO3/pyo3/pull/4158">#4158</a></li>
<li>Add <code>PyType::module</code>, which always matches Python
<code>__module__</code>. <a
href="https://github.com/PyO3/pyo3/pull/4196">#4196</a></li>
<li>Add <code>PyType::fully_qualified_name</code> which matches the
&quot;fully qualified name&quot; defined in <a
href="https://peps.python.org/pep-0737">PEP 737</a>. <a
href="https://github.com/PyO3/pyo3/pull/4196">#4196</a></li>
<li>Add <code>PyTypeMethods::mro</code> and
<code>PyTypeMethods::bases</code>. <a
href="https://github.com/PyO3/pyo3/pull/4197">#4197</a></li>
<li>Add <code>#[pyclass(ord)]</code> to implement ordering based on
<code>PartialOrd</code>. <a
href="https://github.com/PyO3/pyo3/pull/4202">#4202</a></li>
<li>Implement <code>ToPyObject</code> and
<code>IntoPy&lt;PyObject&gt;</code> for <code>PyBackedStr</code> and
<code>PyBackedBytes</code>. <a
href="https://github.com/PyO3/pyo3/pull/4205">#4205</a></li>
<li>Add <code>#[pyclass(hash)]</code> option to implement
<code>__hash__</code> in terms of the <code>Hash</code> implementation
<a href="https://github.com/PyO3/pyo3/pull/4206">#4206</a></li>
<li>Add <code>#[pyclass(eq)]</code> option to generate
<code>__eq__</code> based on <code>PartialEq</code>, and
<code>#[pyclass(eq_int)]</code> for simple enums to implement equality
based on their discriminants. <a
href="https://github.com/PyO3/pyo3/pull/4210">#4210</a></li>
<li>Implement <code>From&lt;Bound&lt;'py, T&gt;&gt;</code> for
<code>PyClassInitializer&lt;T&gt;</code>. <a
href="https://github.com/PyO3/pyo3/pull/4214">#4214</a></li>
<li>Add <code>as_super</code> methods to <code>PyRef</code> and
<code>PyRefMut</code> for accesing the base class by reference. <a
href="https://github.com/PyO3/pyo3/pull/4219">#4219</a></li>
<li>Implement <code>PartialEq&lt;str&gt;</code> for <code>Bound&lt;'py,
PyString&gt;</code>. <a
href="https://github.com/PyO3/pyo3/pull/4245">#4245</a></li>
<li>Implement <code>PyModuleMethods::filename</code> on PyPy. <a
href="https://github.com/PyO3/pyo3/pull/4249">#4249</a></li>
<li>Implement <code>PartialEq&lt;[u8]&gt;</code> for <code>Bound&lt;'py,
PyBytes&gt;</code>. <a
href="https://github.com/PyO3/pyo3/pull/4250">#4250</a></li>
<li>Add <code>pyo3_ffi::c_str</code> macro to create <code>&amp;'static
CStr</code> on Rust versions which don't have 1.77's
<code>c&quot;&quot;</code> literals. <a
href="https://github.com/PyO3/pyo3/pull/4255">#4255</a></li>
<li>Support <code>bool</code> conversion with <code>numpy</code> 2.0's
<code>numpy.bool</code> type <a
href="https://github.com/PyO3/pyo3/pull/4258">#4258</a></li>
<li>Add <code>PyAnyMethods::{bitnot, matmul, floor_div, rem,
divmod}</code>. <a
href="https://github.com/PyO3/pyo3/pull/4264">#4264</a></li>
</ul>
<h3>Changed</h3>
<ul>
<li>Change the type of <code>PySliceIndices::slicelength</code> and the
<code>length</code> parameter of <code>PySlice::indices()</code>. <a
href="https://github.com/PyO3/pyo3/pull/3761">#3761</a></li>
<li>Deprecate implicit default for trailing optional arguments <a
href="https://github.com/PyO3/pyo3/pull/4078">#4078</a></li>
<li><code>Clone</code>ing pointers into the Python heap has been moved
behind the <code>py-clone</code> feature, as it must panic without the
GIL being held as a soundness fix. <a
href="https://github.com/PyO3/pyo3/pull/4095">#4095</a></li>
<li>Add <code>#[track_caller]</code> to all <code>Py&lt;T&gt;</code>,
<code>Bound&lt;'py, T&gt;</code> and <code>Borrowed&lt;'a, 'py,
T&gt;</code> methods which can panic. <a
href="https://github.com/PyO3/pyo3/pull/4098">#4098</a></li>
<li>Change <code>PyAnyMethods::dir</code> to be fallible and return
<code>PyResult&lt;Bound&lt;'py, PyList&gt;&gt;</code> (and similar for
<code>PyAny::dir</code>). <a
href="https://github.com/PyO3/pyo3/pull/4100">#4100</a></li>
<li>The global reference pool (to track pending reference count
decrements) is now initialized lazily to avoid the overhead of taking a
mutex upon function entry when the functionality is not actually used.
<a href="https://github.com/PyO3/pyo3/pull/4178">#4178</a></li>
<li>Emit error messages when using <code>weakref</code> or
<code>dict</code> when compiling for <code>abi3</code> for Python older
than 3.9. <a
href="https://github.com/PyO3/pyo3/pull/4194">#4194</a></li>
<li>Change <code>PyType::name</code> to always match Python
<code>__name__</code>. <a
href="https://github.com/PyO3/pyo3/pull/4196">#4196</a></li>
<li>Remove CPython internal ffi call for complex number including: add,
sub, mul, div, neg, abs, pow. Added PyAnyMethods::{abs, pos, neg} <a
href="https://github.com/PyO3/pyo3/pull/4201">#4201</a></li>
<li>Deprecate implicit integer comparision for simple enums in favor of
<code>#[pyclass(eq_int)]</code>. <a
href="https://github.com/PyO3/pyo3/pull/4210">#4210</a></li>
<li>Set the <code>module=</code> attribute of declarative modules' child
<code>#[pymodule]</code>s and <code>#[pyclass]</code>es. <a
href="https://github.com/PyO3/pyo3/pull/4213">#4213</a></li>
<li>Set the <code>module</code> option for complex enum variants from
the value set on the complex enum <code>module</code>. <a
href="https://github.com/PyO3/pyo3/pull/4228">#4228</a></li>
<li>Respect the Python &quot;limited API&quot; when building for the
<code>abi3</code> feature on PyPy or GraalPy. <a
href="https://github.com/PyO3/pyo3/pull/4237">#4237</a></li>
<li>Optimize code generated by <code>#[pyo3(get)]</code> on
<code>#[pyclass]</code> fields. <a
href="https://github.com/PyO3/pyo3/pull/4254">#4254</a></li>
<li><code>PyCFunction::new</code>,
<code>PyCFunction::new_with_keywords</code> and
<code>PyCFunction::new_closure</code> now take <code>&amp;'static
CStr</code> name and doc arguments (previously was <code>&amp;'static
str</code>). <a
href="https://github.com/PyO3/pyo3/pull/4255">#4255</a></li>
</ul>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/PyO3/pyo3/commit/2e2d4404a682ce87e0b0fe254816457872acf5b2"><code>2e2d440</code></a>
release: 0.22.0 (<a
href="https://github.com/pyo3/pyo3/issues/4266">#4266</a>)</li>
<li><a
href="https://github.com/PyO3/pyo3/commit/91d8683814afbff4aef50d65fc912f73f9273e1a"><code>91d8683</code></a>
improve deprecation message on implicit trailing optionals (<a
href="https://github.com/pyo3/pyo3/issues/4282">#4282</a>)</li>
<li><a
href="https://github.com/PyO3/pyo3/commit/6a0221ba2c59fe2c498899868a745cc19ec96cdb"><code>6a0221b</code></a>
document FnType and refactor FnType::self_arg (<a
href="https://github.com/pyo3/pyo3/issues/4276">#4276</a>)</li>
<li><a
href="https://github.com/PyO3/pyo3/commit/c67625d683cbd5aaaa90607b55b588b2176a9f1a"><code>c67625d</code></a>
Revamp PyType name functions to match PEP 737 (<a
href="https://github.com/pyo3/pyo3/issues/4196">#4196</a>)</li>
<li><a
href="https://github.com/PyO3/pyo3/commit/a2f9399906274ecec61e70bda185aa12e6c564b6"><code>a2f9399</code></a>
make datetime from timestamp tests compare against Python result (<a
href="https://github.com/pyo3/pyo3/issues/4275">#4275</a>)</li>
<li><a
href="https://github.com/PyO3/pyo3/commit/908ef6ad84af31802e80d616576f59de4a6807a0"><code>908ef6a</code></a>
Implement PartialEq for PyBytes and [u8] (<a
href="https://github.com/pyo3/pyo3/issues/4259">#4259</a>)</li>
<li><a
href="https://github.com/PyO3/pyo3/commit/c4d18e5ee3791b5a4ac9e24ee5370de436e40550"><code>c4d18e5</code></a>
Change <code>search_lib_dir</code>'s return type to Result (<a
href="https://github.com/pyo3/pyo3/issues/4043">#4043</a>)</li>
<li><a
href="https://github.com/PyO3/pyo3/commit/0b967d427a20122fef138a0daa49eb52946a6933"><code>0b967d4</code></a>
use <code>ffi::MemberGef</code> for <code>#[pyo3(get)]</code> fields of
<code>Py\&lt;T&gt;</code> (<a
href="https://github.com/pyo3/pyo3/issues/4254">#4254</a>)</li>
<li><a
href="https://github.com/PyO3/pyo3/commit/41fb9572b6001fe99fcb6dc910303a997b76d5a7"><code>41fb957</code></a>
docs: update docstring on <code>Python</code> for <code>Bound</code> API
(<a
href="https://github.com/pyo3/pyo3/issues/4274">#4274</a>)</li>
<li><a
href="https://github.com/PyO3/pyo3/commit/9ff3d237c147ba772dd65b3fc6c0d13c3ee026d5"><code>9ff3d23</code></a>
Update dependencies to reflect minimal versions (<a
href="https://github.com/pyo3/pyo3/issues/4272">#4272</a>)</li>
<li>Additional commits viewable in <a
href="https://github.com/pyo3/pyo3/compare/v0.21.0...v0.22.0">compare
view</a></li>
</ul>
</details>
<br />


Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Agustin Borgna <agustin.borgna@quantinuum.com>
  • Loading branch information
dependabot[bot] and aborgna-q authored Jul 2, 2024
1 parent b3c8142 commit 88b7af9
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ path = "src/lib.rs"

[dependencies]
thiserror = "1.0.28"
pyo3 = { version = "0.21", optional = true, features = ["multiple-pymethods"] }
pyo3 = { version = "0.22", optional = true, features = ["multiple-pymethods"] }
bitvec = "1.0.1"
serde = { version = "1.0.152", features = ["derive"], optional = true }
proptest = { version = "1.1.0", optional = true }
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ pub use crate::view::{LinkMut, LinkView, MultiMut, MultiView, PortMut, PortView}
pub use crate::weights::Weights;

/// Direction of a port.
#[cfg_attr(feature = "pyo3", pyclass)]
#[cfg_attr(feature = "pyo3", pyclass(eq, eq_int))]
#[derive(Clone, Copy, Debug, PartialEq, PartialOrd, Eq, Ord, Hash, Default)]
pub enum Direction {
/// Input to a node.
Expand Down
21 changes: 16 additions & 5 deletions src/py_graph.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
//! Python bindings for the crate's types.
use pyo3::{types::PyInt, IntoPy, PyErr, PyObject, Python};
use pyo3::prelude::PyAnyMethods;
use pyo3::{Bound, FromPyObject, PyAny, PyResult};
use pyo3::{IntoPy, PyErr, PyObject, Python};

use crate::{LinkError, NodeIndex, PortIndex};

impl From<PyInt> for NodeIndex {
fn from(x: PyInt) -> Self {
Self::new(x.extract().unwrap())
impl<'py> FromPyObject<'py> for NodeIndex {
fn extract_bound(x: &Bound<'py, PyAny>) -> PyResult<Self> {
let index: usize = x.extract()?;
Ok(Self::new(index))
}
}

impl<'py> FromPyObject<'py> for PortIndex {
fn extract_bound(x: &Bound<'py, PyAny>) -> PyResult<Self> {
let index: usize = x.extract()?;
Ok(Self::new(index))
}
}

impl IntoPy<PyObject> for NodeIndex {
fn into_py(self, py: Python<'_>) -> PyObject {
self.index().into_py(py)
Expand All @@ -21,7 +32,7 @@ impl IntoPy<PyObject> for PortIndex {
}
}

impl std::convert::From<LinkError> for PyErr {
impl From<LinkError> for PyErr {
fn from(s: LinkError) -> Self {
pyo3::exceptions::PyRuntimeError::new_err(s.to_string())
}
Expand Down

0 comments on commit 88b7af9

Please sign in to comment.