Skip to content
Closed
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
14 changes: 9 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ jobs:
- '3.11'
- '3.12'
- '3.13'
- '3.14.0-rc.2'
- '3.13t'
- '3.14'
- '3.14t'
arch:
- 'arm64'
- 'x86'
Expand Down Expand Up @@ -77,9 +79,10 @@ jobs:
with:
python-version: ${{ matrix.py }}
architecture: ${{ matrix.arch }}
allow-prereleases: true

- name: Install Rust
if: matrix.arch != 'x86' && matrix.py != '3.14.0-rc.2'
if: matrix.arch != 'x86' && (matrix.py != '3.14' || matrix.py != '3.14t')
uses: dtolnay/rust-toolchain@b3b07ba8b418998c39fb20f53e8b695cdcc8de1b # v1
with:
toolchain: stable
Expand All @@ -96,14 +99,14 @@ jobs:
python -m pip install --require-hashes -r ci/requirements.txt

- name: Build (Rust)
if: matrix.arch != 'x86' && matrix.py != '3.14.0-rc.2'
if: matrix.arch != 'x86' && (matrix.py != '3.14' || matrix.py != '3.14t')
env:
PIP_CONSTRAINT: 'ci/constraints.txt'
run: |
python -m pip -v install --config-settings='--build-option=--rust-backend' -e .

- name: Build (No Rust)
if: matrix.arch == 'x86' || matrix.py == '3.14.0-rc.2'
if: matrix.arch == 'x86' || matrix.py == '3.14' || matrix.py == '3.14t'
env:
PIP_CONSTRAINT: 'ci/constraints.txt'
run: |
Expand All @@ -114,13 +117,14 @@ jobs:
pytest --numprocesses=auto --hypothesis-profile=${HYPOTHESIS_PROFILE} -v tests/

- name: Test CFFI Backend
if: matrix.py != '3.13t'
env:
PYTHON_ZSTANDARD_IMPORT_POLICY: 'cffi'
run: |
pytest --numprocesses=auto --hypothesis-profile=${HYPOTHESIS_PROFILE} -v tests/

- name: Test Rust Backend
if: matrix.arch != 'x86' && matrix.py != '3.14.0-rc.2'
if: matrix.arch != 'x86' && (matrix.py != '3.14' || matrix.py != '3.14t' )
# Rust backend is currently experimental. So ignore failures in it.
continue-on-error: true
env:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/typing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ jobs:
- '3.11'
- '3.12'
- '3.13'
- '3.13t'
- '3.14'
- '3.14t'
runs-on: 'ubuntu-24.04'
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
Expand Down
11 changes: 10 additions & 1 deletion .github/workflows/wheel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ jobs:
- 'cp311-cp311'
- 'cp312-cp312'
- 'cp313-cp313'
- 'cp313-cp313t'
- 'cp314-cp314'
- 'cp314-cp314t'
exclude:
- image: 'musllinux_1_1_aarch64'
py: 'cp314-cp314'
Expand Down Expand Up @@ -65,7 +67,9 @@ jobs:
- 'cp311'
- 'cp312'
- 'cp313'
- 'cp313t'
- 'cp314'
- 'cp314t'
arch:
- 'arm64'
- 'x86_64'
Expand All @@ -74,7 +78,9 @@ jobs:
CIBW_ARCHS: ${{ matrix.arch }}
CIBW_BUILD: ${{ matrix.py }}-*
CIBW_BUILD_VERBOSITY: '1'
CIBW_ENABLE: cpython-prerelease cpython-freethreading
ZSTD_WARNINGS_AS_ERRORS: '1'

steps:
- name: Set up Python
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
Expand Down Expand Up @@ -109,7 +115,9 @@ jobs:
- '3.11'
- '3.12'
- '3.13'
- '3.14.0-rc.2'
- '3.13t'
- '3.14'
- '3.14t'
arch:
- 'x86'
- 'x64'
Expand All @@ -130,6 +138,7 @@ jobs:
with:
python-version: ${{ matrix.py }}
architecture: ${{ matrix.arch }}
allow-prereleases: true

- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
Expand Down
23 changes: 11 additions & 12 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.24.2"
version = "0.25.1"
features = ["extension-module"]
2 changes: 1 addition & 1 deletion c-ext/backend_c.c
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ size_t roundpow2(size_t i) {
int safe_pybytes_resize(PyObject **obj, Py_ssize_t size) {
PyObject *tmp;

if ((*obj)->ob_refcnt == 1) {
if (Py_REFCNT(*obj) == 1) {
return _PyBytes_Resize(obj, size);
}

Expand Down
9 changes: 7 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,17 @@ classifiers = [
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Programming Language :: Python :: Free Threading :: 1 - Unstable",
"Programming Language :: Python :: Free Threading",

]
keywords = ["zstandard", "zstd", "compression"]
dependencies = []

[project.optional-dependencies]
cffi = [
'cffi>=1.17 ; python_version >= "3.13" and platform_python_implementation != "PyPy"',
"cffi~=1.17; platform_python_implementation != 'PyPy' and python_version < '3.14'",
"cffi>=2.0.0b; platform_python_implementation != 'PyPy' and python_version >= '3.14'",
]

[project.urls]
Expand All @@ -34,7 +38,8 @@ Documentation = "https://python-zstandard.readthedocs.io/en/latest/"

[build-system]
requires = [
"cffi>=1.17.0 ; platform_python_implementation != 'PyPy'",
"cffi~=1.17; platform_python_implementation != 'PyPy' and python_version < '3.14'",
"cffi>=2.0.0b; platform_python_implementation != 'PyPy' and python_version >= '3.14'",
"packaging",
"setuptools",
]
Expand Down
6 changes: 3 additions & 3 deletions rust-ext/src/buffers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use {
exceptions::{PyIndexError, PyTypeError, PyValueError},
ffi::Py_buffer,
prelude::*,
types::{PyBytes, PyTuple},
types::{PyBytes, PyTuple}, IntoPyObjectExt,
},
};

Expand Down Expand Up @@ -242,7 +242,7 @@ impl ZstdBufferWithSegments {
}

Ok(Self {
source: data.into_py(py),
source: data.into_py_any(py).unwrap(),
buffer: data_buffer,
segments,
})
Expand Down Expand Up @@ -344,7 +344,7 @@ impl ZstdBufferWithSegmentsCollection {

offset += segment.segments.len();

buffers.push(item.to_object(py));
buffers.push(item.into_py_any(py).unwrap());
first_elements.push(offset);
}

Expand Down
6 changes: 3 additions & 3 deletions rust-ext/src/compression_chunker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use {
stream::{make_in_buffer_source, InBufferSource},
zstd_safe::CCtx,
},
pyo3::{prelude::*, types::PyBytes},
pyo3::{prelude::*, types::PyBytes, IntoPyObjectExt},
std::sync::Arc,
};

Expand Down Expand Up @@ -225,7 +225,7 @@ impl ZstdCompressionChunkerIterator {
let chunk = PyBytes::new(py, &slf.dest_buffer);
slf.dest_buffer.clear();

return Ok(Some(chunk.into_py(py)));
return Ok(Some(chunk.into_py_any(py).unwrap()));
}

// Else continue to compress available input data.
Expand Down Expand Up @@ -278,6 +278,6 @@ impl ZstdCompressionChunkerIterator {
let chunk = PyBytes::new(py, &slf.dest_buffer);
slf.dest_buffer.clear();

Ok(Some(chunk.into_py(py)))
Ok(Some(chunk.into_py_any(py).unwrap()))
}
}
4 changes: 2 additions & 2 deletions rust-ext/src/compression_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use {
buffer::PyBuffer,
exceptions::{PyNotImplementedError, PyOSError, PyValueError},
prelude::*,
types::PyBytes,
types::PyBytes, IntoPyObjectExt,
},
std::sync::Arc,
};
Expand Down Expand Up @@ -48,7 +48,7 @@ impl ZstdCompressionWriter {

Ok(Self {
cctx,
writer: writer.into_py(py),
writer: writer.into_py_any(py).unwrap(),
write_return_read,
closefd,
entered: false,
Expand Down
6 changes: 3 additions & 3 deletions rust-ext/src/compressor_iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use {
stream::{make_in_buffer_source, InBufferSource},
zstd_safe::CCtx,
},
pyo3::{prelude::*, types::PyBytes},
pyo3::{prelude::*, types::PyBytes, IntoPyObjectExt},
std::sync::Arc,
};

Expand Down Expand Up @@ -60,7 +60,7 @@ impl ZstdCompressorIterator {
// TODO avoid buffer copy
let chunk = PyBytes::new(py, &dest_buffer);

return Ok(Some(chunk.into_py(py)));
return Ok(Some(chunk.into_py_any(py).unwrap()));
}

// Else read another chunk in hopes of producing output data.
Expand Down Expand Up @@ -94,7 +94,7 @@ impl ZstdCompressorIterator {
// TODO avoid buffer copy.
let chunk = PyBytes::new(py, &dest_buffer);

return Ok(Some(chunk.into_py(py)));
return Ok(Some(chunk.into_py_any(py).unwrap()));
}

Ok(None)
Expand Down
4 changes: 2 additions & 2 deletions rust-ext/src/decompression_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use {
buffer::PyBuffer,
exceptions::{PyOSError, PyValueError},
prelude::*,
types::PyBytes,
types::PyBytes, IntoPyObjectExt,
},
std::sync::Arc,
};
Expand Down Expand Up @@ -40,7 +40,7 @@ impl ZstdDecompressionWriter {
) -> PyResult<Self> {
Ok(Self {
dctx,
writer: writer.into_py(py),
writer: writer.into_py_any(py).unwrap(),
write_size,
write_return_read,
closefd,
Expand Down
6 changes: 3 additions & 3 deletions rust-ext/src/decompressor_iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use {
stream::{make_in_buffer_source, InBufferSource},
zstd_safe::DCtx,
},
pyo3::{exceptions::PyValueError, prelude::*, types::PyBytes},
pyo3::{exceptions::PyValueError, prelude::*, types::PyBytes, IntoPyObjectExt},
std::{cmp::min, sync::Arc},
};

Expand Down Expand Up @@ -60,7 +60,7 @@ impl ZstdDecompressorIterator {
if !dest_buffer.is_empty() {
// TODO avoid buffer copy.
let chunk = PyBytes::new(py, &dest_buffer);
return Ok(Some(chunk.into_py(py)));
return Ok(Some(chunk.into_py_any(py).unwrap()));
}

// Repeat loop to collect more input data.
Expand All @@ -71,7 +71,7 @@ impl ZstdDecompressorIterator {
if !dest_buffer.is_empty() {
// TODO avoid buffer copy.
let chunk = PyBytes::new(py, &dest_buffer);
Ok(Some(chunk.into_py(py)))
Ok(Some(chunk.into_py_any(py).unwrap()))
} else {
Ok(None)
}
Expand Down
Loading