public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
From: Benjamin A. Beasley <code@musicinmybrain.net>
To: git-commits@fedoraproject.org
Subject: [rpms/python-cramjam] f44: Port to PyO3 0.28
Date: Sat, 20 Jun 2026 07:59:14 GMT	[thread overview]
Message-ID: <178194235488.1.11459353636211478078.rpms-python-cramjam-2c25d62710a8@fedoraproject.org> (raw)

            A new commit has been pushed.

            Repo   : rpms/python-cramjam
            Branch : f44
            Commit : 2c25d62710a8f89872678f062bff348f9834e89a
            Author : Benjamin A. Beasley <code@musicinmybrain.net>
            Date   : 2026-06-20T08:44:52+01:00
            Stats  : +378/-2 in 2 file(s)
            URL    : https://src.fedoraproject.org/rpms/python-cramjam/c/2c25d62710a8f89872678f062bff348f9834e89a?branch=f44

            Log:
            Port to PyO3 0.28

- Update `License` expression

---
diff --git a/cramjam-2.11.0-pyo3-0.28.patch b/cramjam-2.11.0-pyo3-0.28.patch
new file mode 100644
index 0000000..8b7d15e
--- /dev/null
+++ b/cramjam-2.11.0-pyo3-0.28.patch
@@ -0,0 +1,368 @@
+diff -Naur cramjam-2.11.0-original/Cargo.toml cramjam-2.11.0/Cargo.toml
+--- cramjam-2.11.0-original/Cargo.toml	1970-01-01 01:00:00.000000000 +0100
++++ cramjam-2.11.0/Cargo.toml	2026-06-19 21:25:39.298774732 +0100
+@@ -71,11 +71,11 @@
+ 
+ 
+ [dependencies]
+-pyo3 = { version = "^0.25", default-features = false, features = ["macros"] }
++pyo3 = { version = "^0.28", default-features = false, features = ["macros"] }
+ libcramjam = { version = "^0.8", default-features = false }
+ 
+ [build-dependencies]
+-pyo3-build-config = "^0.25"
++pyo3-build-config = "^0.28"
+ 
+ [profile.release]
+ strip = true
+diff -Naur cramjam-2.11.0-original/pyproject.toml cramjam-2.11.0/pyproject.toml
+--- cramjam-2.11.0-original/pyproject.toml	2025-07-27 21:42:07.000000000 +0100
++++ cramjam-2.11.0/pyproject.toml	2026-06-19 21:25:56.572961647 +0100
+@@ -2,7 +2,7 @@
+ name = "cramjam"
+ version = "2.11.0"
+ keywords = ["compression", "decompression", "snappy", "zstd", "bz2", "gzip", "lz4", "brotli", "deflate", "blosc2"]
+-requires-python = ">=3.8"
++requires-python = ">=3.11"
+ license = { file = "LICENSE" }
+ 
+ [project.urls]
+diff -Naur cramjam-2.11.0-original/src/blosc2.rs cramjam-2.11.0/src/blosc2.rs
+--- cramjam-2.11.0-original/src/blosc2.rs	2025-07-27 21:42:07.000000000 +0100
++++ cramjam-2.11.0/src/blosc2.rs	2026-06-19 21:25:39.298994605 +0100
+@@ -143,7 +143,7 @@
+     pub fn decompress_chunk(py: Python, data: BytesType, output_len: Option<usize>) -> PyResult<RustyBuffer> {
+         let bytes = data.as_bytes();
+         let buf = py
+-            .allow_threads(|| libcramjam::blosc2::decompress_chunk(bytes))
++            .detach(|| libcramjam::blosc2::decompress_chunk(bytes))
+             .map(RustyBuffer::from)?;
+         Ok(buf)
+     }
+@@ -153,7 +153,7 @@
+     pub fn decompress_chunk_into(py: Python, input: BytesType, mut output: BytesType) -> PyResult<usize> {
+         let bytes = input.as_bytes();
+         let out = output.as_bytes_mut()?;
+-        let nbytes = py.allow_threads(|| libcramjam::blosc2::decompress_chunk_into(bytes, out))?;
++        let nbytes = py.detach(|| libcramjam::blosc2::decompress_chunk_into(bytes, out))?;
+         Ok(nbytes)
+     }
+ 
+@@ -176,7 +176,7 @@
+         codec: Option<PyCodec>,
+     ) -> PyResult<RustyBuffer> {
+         let bytes = data.as_bytes();
+-        py.allow_threads(|| {
++        py.detach(|| {
+             let clevel = clevel.map(Into::into);
+             let filter = filter.map(Into::into);
+             let codec = codec.map(Into::into);
+@@ -200,7 +200,7 @@
+     ) -> PyResult<usize> {
+         let bytes = input.as_bytes();
+         let out = output.as_bytes_mut()?;
+-        py.allow_threads(|| {
++        py.detach(|| {
+             let clevel = clevel.map(Into::into);
+             let filter = filter.map(Into::into);
+             let codec = codec.map(Into::into);
+diff -Naur cramjam-2.11.0-original/src/io.rs cramjam-2.11.0/src/io.rs
+--- cramjam-2.11.0-original/src/io.rs	2025-07-27 21:42:07.000000000 +0100
++++ cramjam-2.11.0/src/io.rs	2026-06-19 21:25:39.299162587 +0100
+@@ -14,7 +14,6 @@
+ use pyo3::ffi;
+ use pyo3::prelude::*;
+ use pyo3::types::PyBytes;
+-use pyo3::IntoPyObjectExt;
+ use std::path::PathBuf;
+ 
+ pub(crate) trait AsBytes {
+@@ -210,7 +209,7 @@
+     pub fn as_slice_mut(&mut self) -> PyResult<&mut [u8]> {
+         #[cfg(any(PyPy, Py_GIL_DISABLED))]
+         {
+-            Python::with_gil(|py| {
++            Python::attach(|py| {
+                 let is_memoryview = unsafe { ffi::PyMemoryView_Check(self.owner.as_ptr()) } == 1;
+                 if is_memoryview || self.owner.bind(py).is_instance_of::<PyBytes>() {
+                     #[cfg(PyPy)]
+@@ -260,13 +259,14 @@
+ 
+ impl Drop for PythonBuffer {
+     fn drop(&mut self) {
+-        Python::with_gil(|_| unsafe { ffi::PyBuffer_Release(&mut *self.inner) })
++        Python::attach(|_| unsafe { ffi::PyBuffer_Release(&mut *self.inner) })
+     }
+ }
+ 
+-impl<'py> FromPyObject<'py> for PythonBuffer {
+-    fn extract_bound(obj: &Bound<'py, PyAny>) -> PyResult<Self> {
+-        Self::try_from(obj)
++impl<'a, 'py> FromPyObject<'a, 'py> for PythonBuffer {
++    type Error = PyErr;
++    fn extract(obj: Borrowed<'a, 'py, PyAny>) -> PyResult<Self> {
++        Self::try_from(&*obj)
+     }
+ }
+ 
+@@ -285,7 +285,7 @@
+             inner: std::pin::Pin::from(buf),
+             pos: 0,
+             #[cfg(any(PyPy, Py_GIL_DISABLED))]
+-            owner: Python::with_gil(|py| obj.into_py_any(py).unwrap()),
++            owner: obj.clone().unbind(),
+         };
+         // sanity checks
+         if buf.inner.shape.is_null() {
+@@ -629,7 +629,7 @@
+     }
+     fn __contains__(&self, py: Python, x: BytesType) -> bool {
+         let bytes = x.as_bytes();
+-        py.allow_threads(|| self.inner.get_ref().windows(bytes.len()).any(|w| w == bytes))
++        py.detach(|| self.inner.get_ref().windows(bytes.len()).any(|w| w == bytes))
+     }
+     fn __repr__(&mut self, py: Python) -> PyResult<String> {
+         Ok(format!("cramjam.Buffer<len={:?}>", self.len(py)?))
+diff -Naur cramjam-2.11.0-original/src/lib.rs cramjam-2.11.0/src/lib.rs
+--- cramjam-2.11.0-original/src/lib.rs	2025-07-27 21:42:07.000000000 +0100
++++ cramjam-2.11.0/src/lib.rs	2026-06-19 21:25:39.299321450 +0100
+@@ -222,13 +222,13 @@
+                 BytesType::RustyFile(f) => {
+                     let borrowed = f.borrow();
+                     let file = &borrowed.inner;
+-                    $py.allow_threads(|| {
++                    $py.detach(|| {
+                         $op(file, &mut Cursor::new(&mut output) $(, $args)* )
+                     })
+                 },
+                 _ => {
+                     let bytes = $input.as_bytes();
+-                    $py.allow_threads(|| {
++                    $py.detach(|| {
+                         $op(bytes, &mut Cursor::new(&mut output) $(, $args)* )
+                     })
+                 }
+@@ -246,20 +246,20 @@
+                         BytesType::RustyFile(f) => {
+                             let mut borrowed = f.borrow_mut();
+                             let mut f_out = &mut borrowed.inner;
+-                            $py.allow_threads(|| {
++                            $py.detach(|| {
+                                 $op(f_in, &mut f_out $(, $args)* )
+                             })
+                         },
+                         BytesType::RustyBuffer(buffer) => {
+                             let mut borrowed = buffer.borrow_mut();
+                             let mut buf_out = &mut borrowed.inner;
+-                            $py.allow_threads(|| {
++                            $py.detach(|| {
+                                 $op(f_in, &mut buf_out $(, $args)* )
+                             })
+                         },
+                         _ => {
+                             let bytes_out = $output.as_bytes_mut()?;
+-                            $py.allow_threads(|| {
++                            $py.detach(|| {
+                                 $op(f_in, &mut Cursor::new(bytes_out) $(, $args)* )
+                             })
+                         }
+@@ -271,20 +271,20 @@
+                         BytesType::RustyFile(f) => {
+                             let mut borrowed = f.borrow_mut();
+                             let mut f_out = &mut borrowed.inner;
+-                            $py.allow_threads(|| {
++                            $py.detach(|| {
+                                 $op(bytes_in, &mut f_out $(, $args)* )
+                             })
+                         },
+                         BytesType::RustyBuffer(buffer) => {
+                             let mut borrowed = buffer.borrow_mut();
+                             let mut buf_out = &mut borrowed.inner;
+-                            $py.allow_threads(|| {
++                            $py.detach(|| {
+                                 $op(bytes_in, &mut buf_out $(, $args)* )
+                             })
+                         },
+                         _ => {
+                             let bytes_out = $output.as_bytes_mut()?;
+-                            $py.allow_threads(|| {
++                            $py.detach(|| {
+                                 $op(bytes_in, &mut Cursor::new(bytes_out) $(, $args)*)
+                             })
+                         }
+@@ -331,11 +331,11 @@
+                         BytesType::RustyFile(f) => {
+                             let mut borrowed = f.borrow_mut();
+                             let f_in = &mut borrowed.inner;
+-                            py.allow_threads(|| libcramjam::$codec::decompress(f_in, inner).map_err(Into::into))
++                            py.detach(|| libcramjam::$codec::decompress(f_in, inner).map_err(Into::into))
+                         }
+                         _ => {
+                             let bytes = input.as_bytes();
+-                            py.allow_threads(|| {
++                            py.detach(|| {
+                                 libcramjam::$codec::decompress(&mut Cursor::new(bytes), inner).map_err(Into::into)
+                             })
+                         }
+@@ -377,7 +377,7 @@
+             }
+             fn __contains__(&self, py: Python, x: BytesType) -> bool {
+                 let bytes = x.as_bytes();
+-                py.allow_threads(|| {
++                py.detach(|| {
+                     self.inner
+                         .as_ref()
+                         .map(|c| c.get_ref().windows(bytes.len()).any(|w| w == bytes))
+diff -Naur cramjam-2.11.0-original/src/lz4.rs cramjam-2.11.0/src/lz4.rs
+--- cramjam-2.11.0-original/src/lz4.rs	2025-07-27 21:42:07.000000000 +0100
++++ cramjam-2.11.0/src/lz4.rs	2026-06-19 21:25:39.299458812 +0100
+@@ -81,7 +81,7 @@
+     pub fn decompress_block(py: Python, data: BytesType, output_len: Option<usize>) -> PyResult<RustyBuffer> {
+         let bytes = data.as_bytes();
+ 
+-        py.allow_threads(|| {
++        py.detach(|| {
+             match output_len {
+                 Some(n) => {
+                     let mut buf = vec![0u8; n];
+@@ -123,7 +123,7 @@
+         store_size: Option<bool>,
+     ) -> PyResult<RustyBuffer> {
+         let bytes = data.as_bytes();
+-        py.allow_threads(|| {
++        py.detach(|| {
+             libcramjam::lz4::block::compress_vec(bytes, compression.map(|v| v as _), acceleration, store_size)
+         })
+         .map_err(CompressionError::from_err)
+@@ -160,7 +160,7 @@
+         }
+ 
+         let out_bytes = output.as_bytes_mut()?;
+-        py.allow_threads(
++        py.detach(
+             || match libcramjam::lz4::block::decompress_into(bytes, out_bytes, Some(size_stored)) {
+                 Ok(r) => Ok(r),
+                 // Fallback and try negation of stored size, incase we/they got it wrong;
+@@ -202,7 +202,7 @@
+     ) -> PyResult<usize> {
+         let bytes = data.as_bytes();
+         let out_bytes = output.as_bytes_mut()?;
+-        py.allow_threads(|| {
++        py.detach(|| {
+             libcramjam::lz4::block::compress_into(
+                 bytes,
+                 out_bytes,
+diff -Naur cramjam-2.11.0-original/src/snappy.rs cramjam-2.11.0/src/snappy.rs
+--- cramjam-2.11.0-original/src/snappy.rs	2025-07-27 21:42:07.000000000 +0100
++++ cramjam-2.11.0/src/snappy.rs	2026-06-19 21:25:39.299551963 +0100
+@@ -54,7 +54,7 @@
+     #[pyo3(signature = (data, output_len=None))]
+     pub fn decompress_raw(py: Python, data: BytesType, output_len: Option<usize>) -> PyResult<RustyBuffer> {
+         let bytes = data.as_bytes();
+-        py.allow_threads(|| libcramjam::snappy::raw::decompress_vec(bytes))
++        py.detach(|| libcramjam::snappy::raw::decompress_vec(bytes))
+             .map_err(DecompressionError::from_err)
+             .map(From::from)
+     }
+@@ -72,7 +72,7 @@
+     #[pyo3(signature = (data, output_len=None))]
+     pub fn compress_raw(py: Python, data: BytesType, output_len: Option<usize>) -> PyResult<RustyBuffer> {
+         let bytes = data.as_bytes();
+-        py.allow_threads(|| libcramjam::snappy::raw::compress_vec(bytes))
++        py.detach(|| libcramjam::snappy::raw::compress_vec(bytes))
+             .map_err(CompressionError::from_err)
+             .map(From::from)
+     }
+@@ -94,7 +94,7 @@
+     pub fn compress_raw_into(py: Python, input: BytesType, mut output: BytesType) -> PyResult<usize> {
+         let bytes_in = input.as_bytes();
+         let bytes_out = output.as_bytes_mut()?;
+-        py.allow_threads(|| libcramjam::snappy::raw::compress(bytes_in, bytes_out))
++        py.detach(|| libcramjam::snappy::raw::compress(bytes_in, bytes_out))
+             .map_err(CompressionError::from_err)
+     }
+ 
+@@ -103,7 +103,7 @@
+     pub fn decompress_raw_into(py: Python, input: BytesType, mut output: BytesType) -> PyResult<usize> {
+         let bytes_in = input.as_bytes();
+         let bytes_out = output.as_bytes_mut()?;
+-        py.allow_threads(|| libcramjam::snappy::raw::decompress(bytes_in, bytes_out))
++        py.detach(|| libcramjam::snappy::raw::decompress(bytes_in, bytes_out))
+             .map_err(DecompressionError::from_err)
+     }
+ 
+diff -Naur cramjam-2.11.0-original/src/xz.rs cramjam-2.11.0/src/xz.rs
+--- cramjam-2.11.0-original/src/xz.rs	2025-07-27 21:42:07.000000000 +0100
++++ cramjam-2.11.0/src/xz.rs	2026-06-19 21:25:39.299630265 +0100
+@@ -130,7 +130,7 @@
+ 
+     /// Available Filter IDs
+     #[derive(Clone, Debug, PartialEq)]
+-    #[pyclass(eq, eq_int)]
++    #[pyclass(eq, eq_int, from_py_object)]
+     #[allow(missing_docs)]
+     pub enum Filter {
+         Arm,
+@@ -150,7 +150,7 @@
+ 
+     /// MatchFinder, used with Options.mf attribute
+     #[derive(Clone, Debug, PartialEq)]
+-    #[pyclass(eq, eq_int)]
++    #[pyclass(eq, eq_int, from_py_object)]
+     #[allow(missing_docs)]
+     pub enum MatchFinder {
+         HashChain3,
+@@ -174,7 +174,7 @@
+ 
+     /// MatchFinder, used with Options.mode attribute
+     #[derive(Clone, Debug, PartialEq)]
+-    #[pyclass(eq, eq_int)]
++    #[pyclass(eq, eq_int, from_py_object)]
+     #[allow(missing_docs)]
+     pub enum Mode {
+         Fast,
+@@ -192,7 +192,7 @@
+     /// FilterChain, similar to the default Python XZ filter chain which is a list of
+     /// dicts.
+     #[derive(Debug, Clone)]
+-    #[pyclass]
++    #[pyclass(from_py_object)]
+     pub struct FilterChain(Vec<FilterChainItem>);
+ 
+     #[pymethods]
+@@ -229,7 +229,7 @@
+     /// FilterChainItem. In Python's lzma module, this represents a single dict in the
+     /// filter chain list. To be added to the `FilterChain`
+     #[derive(Clone, Debug, Default)]
+-    #[pyclass]
++    #[pyclass(from_py_object)]
+     pub struct FilterChainItem {
+         filter: Filter,
+         options: Options,
+@@ -250,7 +250,7 @@
+ 
+     ///
+     #[derive(Clone, Debug, Default)]
+-    #[pyclass]
++    #[pyclass(from_py_object)]
+     pub struct Options {
+         preset: Option<u32>,
+         dict_size: Option<u32>,
+@@ -331,7 +331,7 @@
+ 
+     /// Possible formats
+     #[derive(Clone, Debug, PartialEq)]
+-    #[pyclass(eq, eq_int)]
++    #[pyclass(eq, eq_int, from_py_object)]
+     pub enum Format {
+         /// Auto select the format, for compression this is XZ,
+         /// for decompression it will be determined by the compressed input.
+@@ -362,7 +362,7 @@
+ 
+     /// Possible Check configurations
+     #[derive(Debug, Clone, PartialEq)]
+-    #[pyclass(eq, eq_int)]
++    #[pyclass(eq, eq_int, from_py_object)]
+     #[allow(missing_docs)]
+     pub enum Check {
+         Crc64,

diff --git a/python-cramjam.spec b/python-cramjam.spec
index f8a30fb..b1cfbd3 100644
--- a/python-cramjam.spec
+++ b/python-cramjam.spec
@@ -33,6 +33,12 @@ Source1:        get_source
 
 %endif
 
+# Bump pyo3 to 0.28
+# https://github.com/milesgranger/cramjam/pull/240
+# Rebased on 2.11.0. Without changes to Cargo.lock and
+# .github/workflows/CI.yml, which are not relevant downstream.
+Patch:          cramjam-2.11.0-pyo3-0.28.patch
+
 BuildSystem:    pyproject
 BuildOption(install): --assert-license cramjam
 
@@ -62,11 +68,13 @@ Summary:        %{summary}
 # MIT
 # MIT OR Apache-2.0
 # MIT OR Zlib OR Apache-2.0
+# bzip2-1.0.6
 License:        %{shrink:
-    (0BSD OR MIT OR Apache-2.0) AND
+    MIT AND
     Apache-2.0 AND
     BSD-3-Clause AND
-    MIT AND
+    bzip2-1.0.6 AND
+    (0BSD OR MIT OR Apache-2.0) AND
     (MIT OR Zlib OR Apache-2.0)
     }
 # LICENSE.dependencies contains a full license breakdown

                 reply	other threads:[~2026-06-20  7:59 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=178194235488.1.11459353636211478078.rpms-python-cramjam-2c25d62710a8@fedoraproject.org \
    --to=code@musicinmybrain.net \
    --cc=git-commits@fedoraproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox