Skip to content
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
20 changes: 0 additions & 20 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ jobs:
fail-fast: ${{ !( startsWith(github.ref, 'refs/heads/master') || startsWith(github.ref, 'refs/tags/') ) }}
matrix:
python-version:
- '3.10'
- '3.11'
- '3.12'
- '3.13'
Expand Down Expand Up @@ -99,45 +98,28 @@ jobs:

- { os: windows-11-arm, target: aarch64, target-triple: aarch64-pc-windows-msvc, python-architecture: arm64 }

# Python 3.10 has no native ARM64 Windows installer
exclude:
- python-version: '3.10'
conf: { os: windows-11-arm }

include:
# Windows x86_64 pypy
- conf: { os: windows-latest, target: x86_64, target-triple: x86_64-pc-windows-msvc }
python-version: pypy3.10
- conf: { os: windows-latest, target: x86_64, target-triple: x86_64-pc-windows-msvc }
python-version: pypy3.11

# Linux x86_64 pypy
- conf: { os: ubuntu-latest, target: x86_64, target-triple: x86_64-unknown-linux-gnu, manylinux: auto }
python-version: pypy3.10
- conf: { os: ubuntu-latest, target: x86_64, target-triple: x86_64-unknown-linux-gnu, manylinux: auto }
python-version: pypy3.11

# Linux arm pypy
- conf: { os: ubuntu-latest, target: aarch64, target-triple: aarch64-unknown-linux-gnu, manylinux: auto }
python-version: pypy3.10
- conf: { os: ubuntu-latest, target: aarch64, target-triple: aarch64-unknown-linux-gnu, manylinux: auto }
python-version: pypy3.11

# OSX x86_64 pypy
- conf: { os: macos-15, target: x86_64, target-triple: x86_64-apple-darwin }
python-version: pypy3.10
- conf: { os: macos-15, target: x86_64, target-triple: x86_64-apple-darwin }
python-version: pypy3.11

# OSX universal2 pypy
- conf: { os: macos-15, target: universal2, target-triple: x86_64-apple-darwin }
python-version: pypy3.10
- conf: { os: macos-15, target: universal2, target-triple: x86_64-apple-darwin }
python-version: pypy3.11

# OSX arm pypy
- conf: { os: macos-15, target: aarch64, target-triple: aarch64-apple-darwin }
python-version: pypy3.10
- conf: { os: macos-15, target: aarch64, target-triple: aarch64-apple-darwin }
python-version: pypy3.11

Expand Down Expand Up @@ -179,10 +161,8 @@ jobs:
delvewheel repair -v "wheels\$($file.Name)" -w "dist"

- name: Install built wheel and Test (Native)
# TODO: I'm not sure but the actual collection of tests on windows using pypy3.10 takes forever and/or fails
if: |
!startsWith(matrix.conf.manylinux, 'musl') &&
!( matrix.python-version == 'pypy3.10' && runner.os == 'Windows' ) &&
( matrix.conf.target == 'universal2' || (matrix.conf.target == 'aarch64' && runner.os == 'Windows') || (matrix.conf.target == 'x86_64' && runner.os != 'macOS') )
run: |
# Second install guarantees it's going to install from local dir w/ --no-index
Expand Down
55 changes: 15 additions & 40 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,11 @@ wasm32-compat = ["libcramjam/wasm32-compat"]


[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
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "cramjam"
version = "2.12.0-rc1"
keywords = ["compression", "decompression", "snappy", "zstd", "bz2", "gzip", "lz4", "brotli", "deflate", "blosc2"]
requires-python = ">=3.10"
requires-python = ">=3.11"
license = { file = "LICENSE" }

[project.urls]
Expand Down
8 changes: 4 additions & 4 deletions src/blosc2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ pub mod blosc2 {
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)
}
Expand All @@ -153,7 +153,7 @@ pub mod blosc2 {
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)
}

Expand All @@ -176,7 +176,7 @@ pub mod blosc2 {
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);
Expand All @@ -200,7 +200,7 @@ pub mod blosc2 {
) -> 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);
Expand Down
16 changes: 8 additions & 8 deletions src/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ use pyo3::exceptions::{self, PyBufferError};
use pyo3::ffi;
use pyo3::prelude::*;
use pyo3::types::PyBytes;
use pyo3::IntoPyObjectExt;
use std::path::PathBuf;

pub(crate) trait AsBytes {
Expand Down Expand Up @@ -210,7 +209,7 @@ impl PythonBuffer {
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)]
Expand Down Expand Up @@ -260,13 +259,14 @@ impl PythonBuffer {

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)
}
}

Expand All @@ -285,7 +285,7 @@ impl<'a, 'py> TryFrom<&'a Bound<'py, PyAny>> for PythonBuffer {
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() {
Expand Down Expand Up @@ -629,7 +629,7 @@ impl RustyBuffer {
}
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)?))
Expand Down
Loading
Loading