Skip to content

Commit d96a12b

Browse files
committed
update pyo3
1 parent 4eb9fdb commit d96a12b

35 files changed

Lines changed: 246 additions & 334 deletions

Cargo.lock

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

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ itertools = "0.10.3"
5252
memoffset = "0.6.5"
5353
ndarray = { version = "0.15.4", features = ["serde"] }
5454
path_macro = "1.0.0"
55-
pyo3 = { version = "0.18", features = ["extension-module"], optional = true }
55+
pyo3 = { version = "0.29", features = ["extension-module"], optional = true }
5656
rayon = "1.5.3"
5757
regex = "1.5.5"
5858
serde = { version = "1.0.136", features = ["derive"] }

osrs_py/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ crate-type = ["lib", "cdylib"]
99

1010
[dependencies]
1111
rs3cache = { path = "..", version = "0.1.0", features=["osrs", "pyo3"] }
12-
pyo3 = { version = "0.18", features = ["extension-module"]}
12+
pyo3 = { version = "0.29", features = ["extension-module"]}

osrs_py/osrs/osrs.pdb

2.27 MB
Binary file not shown.

osrs_py/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use pyo3::prelude::*;
22

33
#[pymodule]
4-
fn osrs(py: Python, m: &PyModule) -> PyResult<()> {
4+
fn osrs(py: Python, m: &Bound<'_, PyModule>) -> PyResult<()> {
55
rs3cache::ffi::python::initializer(py, m)?;
66
Ok(())
77
}

rs3_py/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ crate-type = ["cdylib"]
99

1010
[dependencies]
1111
rs3cache = { path = "..", version = "0.1.0", features=["rs3", "pyo3"] }
12-
pyo3 = { version = "0.18", features = ["extension-module"]}
12+
pyo3 = { version = "0.29", features = ["extension-module"]}

rs3_py/rs3/rs3.pdb

2.71 MB
Binary file not shown.

rs3_py/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use pyo3::prelude::*;
22

33
#[pymodule]
4-
fn rs3(py: Python, m: &PyModule) -> PyResult<()> {
4+
fn rs3(py: Python<'_>, m: &Bound<'_, PyModule>) -> PyResult<()> {
55
rs3cache::ffi::python::initializer(py, m)?;
66
Ok(())
77
}

rs3cache_backend/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ itertools = "0.10.3"
1616
libflate = "1.1.2"
1717
memchr = "2.4.1"
1818
path_macro = "1.0.0"
19-
pyo3 = { version = "0.18", optional = true }
19+
pyo3 = { version = "0.29", optional = true }
2020
serde = { version = "1.0.136", features = ["derive"] }
2121
serde_json = "1.0.79"
2222
serde_with = "1.12.0"

rs3cache_backend/src/arc.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use std::collections::BTreeMap;
1212

1313
use bytes::{Buf, Bytes};
1414
#[cfg(feature = "pyo3")]
15-
use pyo3::{exceptions::PyKeyError, prelude::*, types::PyBytes};
15+
use pyo3::{exceptions::PyKeyError, prelude::*, types::PyBytes, Bound};
1616
#[cfg(feature = "dat")]
1717
use {
1818
crate::buf::BufExtra,
@@ -22,7 +22,7 @@ use {
2222

2323
use crate::meta::Metadata;
2424
/// A collection of files.
25-
#[cfg_attr(feature = "pyo3", pyclass(frozen))]
25+
#[cfg_attr(feature = "pyo3", pyclass(frozen, from_py_object))]
2626
#[derive(Clone, Default)]
2727
pub struct Archive {
2828
pub(crate) index_id: u32,
@@ -174,9 +174,9 @@ impl Archive {
174174
compressed.extend(buffer.split_to(header.compressed_len as usize));
175175

176176
use pyo3::prelude::*;
177-
pyo3::prepare_freethreaded_python();
177+
Python::initialize();
178178

179-
let res = Python::with_gil(|py| {
179+
let res = Python::attach(|py| {
180180
let zlib = PyModule::import(py, "bz2")?;
181181
let decompress = zlib.getattr("decompress")?;
182182
let bytes = PyBytes::new(py, &compressed);
@@ -222,7 +222,7 @@ impl Archive {
222222
#[pymethods]
223223
impl Archive {
224224
#[pyo3(name = "file")]
225-
fn py_file<'p>(&self, py: Python<'p>, file_id: u32) -> PyResult<&'p PyBytes> {
225+
fn py_file<'p>(&self, py: Python<'p>, file_id: u32) -> PyResult<Bound<'p, PyBytes>> {
226226
if let Some(file) = self.files.get(&file_id) {
227227
Ok(PyBytes::new(py, file))
228228
} else {
@@ -231,7 +231,7 @@ impl Archive {
231231
}
232232

233233
#[pyo3(name = "files")]
234-
fn py_files<'p>(&self, py: Python<'p>) -> PyResult<BTreeMap<u32, &'p PyBytes>> {
234+
fn py_files<'p>(&self, py: Python<'p>) -> PyResult<BTreeMap<u32, Bound<'p, PyBytes>>> {
235235
Ok(self.files.iter().map(|(&id, file)| (id, PyBytes::new(py, file))).collect())
236236
}
237237

0 commit comments

Comments
 (0)