Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update rust backend to pyo3 0.22.6 #257

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,8 @@ jobs:
run: |
python -m pip install --require-hashes -r ci/requirements.txt

# TODO enable once PyO3 supports 3.13.
- name: Build (Rust)
if: matrix.arch == 'x64' && matrix.py != '3.13'
if: matrix.arch == 'x64'
env:
PIP_CONSTRAINT: 'ci/constraints.txt'
run: |
Expand Down
152 changes: 14 additions & 138 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ version = "2.0.10+zstd.1.5.6"
features = ["experimental", "legacy", "zstdmt"]

[dependencies.pyo3]
version = "0.21.2"
version = "0.22.6"
features = ["extension-module"]
18 changes: 9 additions & 9 deletions rust-ext/src/compression_chunker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ impl ZstdCompressionChunker {

let source = make_in_buffer_source(py, data, zstd_safe::CCtx::in_size())?;

let it = Py::new(
let it = Bound::new(
py,
ZstdCompressionChunkerIterator {
cctx: self.cctx.clone(),
Expand All @@ -96,9 +96,9 @@ impl ZstdCompressionChunker {
},
)?;

self.iterator = Some(it.clone());
self.iterator = Some(it.clone().unbind());

Ok(it)
Ok(it.unbind())
}

fn flush<'p>(&mut self, py: Python<'p>) -> PyResult<Py<ZstdCompressionChunkerIterator>> {
Expand All @@ -119,7 +119,7 @@ impl ZstdCompressionChunker {
let source =
make_in_buffer_source(py, &PyBytes::new_bound(py, &[]), zstd_safe::CCtx::in_size())?;

let it = Py::new(
let it = Bound::new(
py,
ZstdCompressionChunkerIterator {
cctx: self.cctx.clone(),
Expand All @@ -130,9 +130,9 @@ impl ZstdCompressionChunker {
},
)?;

self.iterator = Some(it.clone());
self.iterator = Some(it.clone().unbind());

Ok(it)
Ok(it.unbind())
}

fn finish<'p>(&mut self, py: Python<'p>) -> PyResult<Py<ZstdCompressionChunkerIterator>> {
Expand All @@ -153,7 +153,7 @@ impl ZstdCompressionChunker {
let source =
make_in_buffer_source(py, &PyBytes::new_bound(py, &[]), zstd_safe::CCtx::in_size())?;

let it = Py::new(
let it = Bound::new(
py,
ZstdCompressionChunkerIterator {
cctx: self.cctx.clone(),
Expand All @@ -164,9 +164,9 @@ impl ZstdCompressionChunker {
},
)?;

self.iterator = Some(it.clone());
self.iterator = Some(it.clone().unbind());

Ok(it)
Ok(it.unbind())
}
}

Expand Down
1 change: 1 addition & 0 deletions rust-ext/src/compression_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ impl ZstdCompressionWriter {
false
}

#[pyo3(signature = (size=None))]
#[allow(unused_variables)]
fn truncate(&self, py: Python, size: Option<&Bound<'_, PyAny>>) -> PyResult<()> {
let io = py.import_bound("io")?;
Expand Down
1 change: 1 addition & 0 deletions rust-ext/src/compressionobj.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ impl ZstdCompressionObj {
Ok(PyBytes::new_bound(py, &compressed))
}

#[pyo3(signature = (flush_mode=None))]
fn flush<'p>(
&mut self,
py: Python<'p>,
Expand Down
2 changes: 1 addition & 1 deletion rust-ext/src/compressor_multi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ pub fn multi_compress_to_buffer(
total_source_size += slice.len();
}
}
} else if let Ok(list) = data.extract::<&PyList>() {
} else if let Ok(list) = data.extract::<Bound<'_, PyList>>() {
sources.reserve_exact(list.len());

for (i, item) in list.iter().enumerate() {
Expand Down
1 change: 1 addition & 0 deletions rust-ext/src/decompressionobj.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ impl ZstdDecompressionObj {
empty.call_method1("join", (chunks,))
}

#[pyo3(signature = (length=None))]
#[allow(unused_variables)]
fn flush<'p>(&self, py: Python<'p>, length: Option<usize>) -> PyResult<Bound<'p, PyBytes>> {
Ok(PyBytes::new_bound(py, &[]))
Expand Down
2 changes: 1 addition & 1 deletion rust-ext/src/decompressor_multi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ pub fn multi_decompress_to_buffer(
offset += 1;
}
}
} else if let Ok(list) = frames.extract::<&PyList>() {
} else if let Ok(list) = frames.extract::<Bound<'_, PyList>>() {
if decompressed_sizes.is_some() && frame_sizes.len() != list.len() {
return Err(PyValueError::new_err(format!(
"decompressed_sizes size mismatch; expected {}; got {}",
Expand Down
Loading