Skip to content

Commit 8394bf0

Browse files
authored
Merge pull request #48 from enviodev/claude/upgrade-python-dependencies-RsQ45
Upgrade pyo3 to 0.23 and update Python API usage
2 parents 88faa15 + d3c37ff commit 8394bf0

6 files changed

Lines changed: 85 additions & 37 deletions

File tree

‎.github/workflows/publish.yml‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# This file is autogenerated by maturin v1.7.1
1+
# This file is autogenerated by maturin v1.7.1 and then manually modified
22
# To update, run
33
#
44
# maturin generate-ci --zig github
@@ -33,7 +33,7 @@ jobs:
3333
- runner: ubuntu-latest
3434
target: aarch64
3535
python-architecture: arm64
36-
python-version: ["3.9", "3.10", "3.11", "3.12"]
36+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
3737
steps:
3838
- uses: actions/checkout@v4
3939
- uses: actions/setup-python@v5
@@ -62,7 +62,7 @@ jobs:
6262
target: x64
6363
- runner: windows-latest
6464
target: x86
65-
python-version: ["3.9", "3.10", "3.11", "3.12"]
65+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
6666
steps:
6767
- uses: actions/checkout@v4
6868
- uses: actions/setup-python@v5
@@ -93,7 +93,7 @@ jobs:
9393
- runner: macos-14
9494
target: aarch64
9595
python-architecture: arm64
96-
python-version: ["3.9", "3.10", "3.11", "3.12"]
96+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
9797
steps:
9898
- uses: actions/checkout@v4
9999
- uses: actions/setup-python@v5

‎Cargo.lock‎

Lines changed: 13 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Cargo.toml‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
[package]
22
name = "hypersync"
3-
version = "0.8.5"
3+
version = "0.9.0"
44
edition = "2021"
55

66
[lib]
77
name = "hypersync"
88
crate-type = ["cdylib"]
99

1010
[dependencies]
11-
pyo3 = { version = "0.22", features = [
11+
pyo3 = { version = "0.23", features = [
1212
"extension-module",
1313
"anyhow",
1414
"num-bigint",
1515
] }
16-
pyo3-async-runtimes = { version = "0.22", features = ["tokio-runtime"] }
16+
pyo3-async-runtimes = { version = "0.23", features = ["tokio-runtime"] }
1717
tokio = "1"
1818
serde_json = "1"
1919
serde = { version = "1", features = ["derive"] }

‎pyproject.toml‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,17 @@ build-backend = "maturin"
55
[project]
66
name = "hypersync"
77
requires-python = ">=3.9"
8-
dependencies = ["strenum>=0.4.15,<0.4.16"]
8+
dependencies = ["strenum>=0.4.15"]
99
classifiers = [
1010
"Programming Language :: Rust",
1111
"Programming Language :: Python :: Implementation :: CPython",
1212
"Programming Language :: Python :: Implementation :: PyPy",
13+
"Programming Language :: Python :: 3",
14+
"Programming Language :: Python :: 3.9",
15+
"Programming Language :: Python :: 3.10",
16+
"Programming Language :: Python :: 3.11",
17+
"Programming Language :: Python :: 3.12",
18+
"Programming Language :: Python :: 3.13",
1319
"Development Status :: 3 - Alpha",
1420
"Topic :: Database :: Front-Ends",
1521
"Topic :: Software Development :: Libraries",

‎src/arrow_ffi.rs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use polars_arrow::{
88
use pyo3::{
99
ffi::Py_uintptr_t,
1010
types::{PyAnyMethods, PyModule},
11-
PyErr, PyObject, Python, ToPyObject,
11+
PyErr, PyObject, Python,
1212
};
1313

1414
use crate::{
@@ -18,7 +18,7 @@ use crate::{
1818

1919
pub fn response_to_pyarrow(response: hypersync_client::ArrowResponse) -> Result<ArrowResponse> {
2020
let data = Python::with_gil(|py| {
21-
let pyarrow = py.import_bound("pyarrow")?;
21+
let pyarrow = py.import("pyarrow")?;
2222
Ok::<_, PyErr>(ArrowResponseData {
2323
blocks: convert_batches_to_pyarrow_table(py, &pyarrow, response.data.blocks)?,
2424
transactions: convert_batches_to_pyarrow_table(
@@ -79,5 +79,5 @@ fn convert_batches_to_pyarrow_table<'py>(
7979
.call_method1("from_batches", (py_stream,))
8080
.context("call pyarrow::Table::from_batches")?;
8181

82-
Ok(table.to_object(py))
82+
Ok(table.unbind())
8383
}

‎src/types.rs‎

Lines changed: 55 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use alloy_primitives::{Signed, U256};
55
use anyhow::{Context, Result};
66
use hypersync_client::{format, format::Hex, net_types, simple_types};
77
use num_bigint::{BigInt, BigUint};
8-
use pyo3::{pyclass, IntoPy, PyObject, Python};
8+
use pyo3::{pyclass, IntoPyObject, PyObject, Python};
99
use serde::{Deserialize, Serialize};
1010

1111
/// Data relating to a single event (log)
@@ -222,35 +222,77 @@ impl Clone for DecodedSolValue {
222222
impl DecodedSolValue {
223223
pub fn new(py: Python, val: DynSolValue, checksummed_addresses: bool) -> Self {
224224
let val = match val {
225-
DynSolValue::Bool(b) => b.into_py(py),
226-
DynSolValue::Int(v, _) => convert_bigint_signed(v).into_py(py),
227-
DynSolValue::Uint(v, _) => convert_bigint_unsigned(v).into_py(py),
228-
DynSolValue::FixedBytes(bytes, _) => encode_prefix_hex(bytes.as_slice()).into_py(py),
225+
DynSolValue::Bool(b) => b
226+
.into_pyobject(py)
227+
.unwrap()
228+
.to_owned()
229+
.into_any()
230+
.unbind(),
231+
DynSolValue::Int(v, _) => convert_bigint_signed(v)
232+
.into_pyobject(py)
233+
.unwrap()
234+
.into_any()
235+
.unbind(),
236+
DynSolValue::Uint(v, _) => convert_bigint_unsigned(v)
237+
.into_pyobject(py)
238+
.unwrap()
239+
.into_any()
240+
.unbind(),
241+
DynSolValue::FixedBytes(bytes, _) => encode_prefix_hex(bytes.as_slice())
242+
.into_pyobject(py)
243+
.unwrap()
244+
.into_any()
245+
.unbind(),
229246
DynSolValue::Address(addr) => {
230247
if !checksummed_addresses {
231-
encode_prefix_hex(addr.as_slice()).into_py(py)
248+
encode_prefix_hex(addr.as_slice())
249+
.into_pyobject(py)
250+
.unwrap()
251+
.into_any()
252+
.unbind()
232253
} else {
233-
addr.to_checksum(None).into_py(py)
254+
addr.to_checksum(None)
255+
.into_pyobject(py)
256+
.unwrap()
257+
.into_any()
258+
.unbind()
234259
}
235260
}
236-
DynSolValue::Function(bytes) => encode_prefix_hex(bytes.as_slice()).into_py(py),
237-
DynSolValue::Bytes(bytes) => encode_prefix_hex(bytes.as_slice()).into_py(py),
238-
DynSolValue::String(s) => s.into_py(py),
261+
DynSolValue::Function(bytes) => encode_prefix_hex(bytes.as_slice())
262+
.into_pyobject(py)
263+
.unwrap()
264+
.into_any()
265+
.unbind(),
266+
DynSolValue::Bytes(bytes) => encode_prefix_hex(bytes.as_slice())
267+
.into_pyobject(py)
268+
.unwrap()
269+
.into_any()
270+
.unbind(),
271+
DynSolValue::String(s) => s.into_pyobject(py).unwrap().into_any().unbind(),
239272
DynSolValue::Array(vals) => vals
240273
.into_iter()
241274
.map(|v| DecodedSolValue::new(py, v, checksummed_addresses))
242275
.collect::<Vec<_>>()
243-
.into_py(py),
276+
.into_pyobject(py)
277+
.unwrap()
278+
.into_any()
279+
.unbind(),
244280
DynSolValue::FixedArray(vals) => vals
245281
.into_iter()
246282
.map(|v| DecodedSolValue::new(py, v, checksummed_addresses))
247283
.collect::<Vec<_>>()
248-
.into_py(py),
284+
.into_pyobject(py)
285+
.unwrap()
286+
.into_any()
287+
.unbind(),
249288
DynSolValue::Tuple(vals) => vals
250289
.into_iter()
251290
.map(|v| DecodedSolValue::new(py, v, checksummed_addresses))
252291
.collect::<Vec<_>>()
253-
.into_py(py),
292+
.into_pyobject(py)
293+
.unwrap()
294+
.into_any()
295+
.unbind(),
254296
};
255297

256298
Self { val }

0 commit comments

Comments
 (0)