Skip to content

Commit 1d7b64e

Browse files
authored
Merge branch 'main' into pre-commit-ci-update-config
2 parents 44aa398 + cf03730 commit 1d7b64e

File tree

10 files changed

+185
-739
lines changed

10 files changed

+185
-739
lines changed

.github/workflows/ci-i386.yml

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,34 +27,45 @@ jobs:
2727
arch: x86
2828
packages: >
2929
build-base
30-
python3
31-
python3-dev
30+
cargo
31+
cmake
32+
cython
3233
git
33-
py3-pip
34-
py3-pytest
35-
uv
3634
meson
3735
pkgconf
36+
rust
37+
sed
38+
sudo
39+
uv
40+
zstd
41+
python3
42+
python3-dev
3843
py3-numpy
3944
py3-numpy-dev
40-
zstd
45+
py3-pip
46+
py3-pytest
4147
42-
- name: Install numcodecs
48+
- name: Install zfp
4349
run: |
44-
export DISABLE_NUMCODECS_AVX2=""
4550
uv venv
46-
uv pip install -v -e .[test,test_extras,msgpack,crc32c]
51+
PYTHON_INCLUDE=$(uv run python -c 'from sysconfig import get_paths; print(get_paths()["include"])');
52+
PYTHON_LIB=$(uv run python -c 'import sysconfig; print(sysconfig.get_config_var("LIBDIR"))');
53+
git clone https://github.com/LLNL/zfp
54+
sed -i "s/distutils.sysconfig/sysconfig/g" zfp/python/scikit-build-cmake/FindPythonExtensions.cmake
55+
mkdir zfp/build;
56+
uv run cmake zfp -B zfp/build -DBUILD_ZFPY=ON -DBUILD_TESTING=OFF -DPYTHON_LIBRARY=$PYTHON_LIB -DPYTHON_INCLUDE_DIR=$PYTHON_INCLUDE
57+
uv run make -j -C zfp/build
58+
uv run sudo make -C zfp/build install
59+
uv add "zfpy @ ./zfp"
4760
shell: alpine.sh {0}
4861

49-
50-
- name: Install zarr-python
51-
# Since zarr v3 requires numpy >= 1.25, on Python 3.11 leave it out
52-
# so we can have some tests of our minimum version of numpy (1.24)
53-
if: matrix.python-version != '3.11'
54-
run: uv add zarr>=3
62+
- name: Install numcodecs
63+
run: |
64+
export DISABLE_NUMCODECS_AVX2=""
65+
uv venv
66+
uv pip install -v -e .[test,test_extras,msgpack,crc32c,pcodec,zfpy]
5567
shell: alpine.sh {0}
5668

57-
5869
- name: List installed packages
5970
run: uv pip list
6071
shell: alpine.sh {0}

.github/workflows/ci.yaml

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,6 @@ jobs:
5252
export DISABLE_NUMCODECS_AVX2=""
5353
python -m pip install -v -e .[test,test_extras,msgpack,crc32c,pcodec,zfpy]
5454
55-
- name: Install zarr-python
56-
# Since zarr v3 requires numpy >= 1.25, on Python 3.11 leave it out
57-
# so we can have some tests of our minimum version of numpy (1.24)
58-
if: matrix.python-version != '3.11'
59-
run: python -m pip install zarr>=3
60-
6155
- name: List installed packages
6256
run: python -m pip list
6357

@@ -75,6 +69,8 @@ jobs:
7569
runs-on: ubuntu-latest
7670
strategy:
7771
fail-fast: false
72+
matrix:
73+
zarr-version: ["312", "313"]
7874

7975
defaults:
8076
run:
@@ -93,10 +89,10 @@ jobs:
9389
pixi-version: v0.49.0
9490
cache: false
9591

96-
- name: List deps
92+
- name: List installed packages
9793
shell: "bash -l {0}"
98-
run: pixi run -e default hatch run test:list-deps
94+
run: pixi run ls-deps-${{matrix.zarr-version}}
9995

100-
- name: Run tests
96+
- name: Run tests with Zarr ${{ matrix.zarr-version }}
10197
shell: "bash -l {0}"
102-
run: pixi run -e default hatch run test:test-zarr
98+
run: pixi run test-zarr-${{ matrix.zarr-version }}

.github/workflows/wheel.yaml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ jobs:
2323
os: [ubuntu-latest, ubuntu-22.04-arm, windows-latest, macos-13, macos-14]
2424
env:
2525
CIBW_TEST_COMMAND: python -c "import numcodecs"
26-
CIBW_BUILD: "cp311-* cp312-* cp313-*"
27-
CIBW_SKIP: "pp* *-musllinux_* *win32 *_i686 *_s390x"
26+
CIBW_BUILD: "cp311-* cp312-* cp313-* cp314-*"
27+
CIBW_SKIP: "*-musllinux_* *win32 *_i686 *_s390x"
2828
# note: CIBW_ENVIRONMENT is now set in pyproject.toml
2929

3030
steps:
@@ -33,7 +33,7 @@ jobs:
3333
submodules: true
3434
fetch-depth: 0 # required for version resolution for nightly wheels
3535

36-
- uses: pypa/cibuildwheel@v2.23.2
36+
- uses: pypa/cibuildwheel@v3.1.0
3737

3838
- uses: actions/upload-artifact@v4
3939
with:
@@ -69,11 +69,11 @@ jobs:
6969
needs: [build_wheels, build_sdist]
7070
runs-on: ubuntu-latest
7171
steps:
72-
- uses: actions/download-artifact@v4
72+
- uses: actions/download-artifact@v6
7373
with:
7474
name: sdist
7575
path: dist
76-
- uses: actions/download-artifact@v4
76+
- uses: actions/download-artifact@v6
7777
with:
7878
pattern: wheels-*
7979
path: dist
@@ -89,11 +89,11 @@ jobs:
8989
runs-on: ubuntu-latest
9090
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v')
9191
steps:
92-
- uses: actions/download-artifact@v4
92+
- uses: actions/download-artifact@v6
9393
with:
9494
name: sdist
9595
path: dist
96-
- uses: actions/download-artifact@v4
96+
- uses: actions/download-artifact@v6
9797
with:
9898
pattern: wheels-*
9999
path: dist
@@ -110,7 +110,7 @@ jobs:
110110
runs-on: ubuntu-latest
111111
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
112112
steps:
113-
- uses: actions/download-artifact@v4
113+
- uses: actions/download-artifact@v6
114114
with:
115115
pattern: wheels-*
116116
path: dist

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ repos:
3030
hooks:
3131
- id: mypy
3232
args: [--config-file, pyproject.toml]
33-
additional_dependencies: [numpy, pytest, crc32c, zfpy, 'zarr>=3']
33+
additional_dependencies: [numpy, pytest, google-crc32c, crc32c, zfpy, 'zarr>=3.1.3']

numcodecs/checksum32.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
_crc32c: ModuleType | None = None
1616
with suppress(ImportError):
17-
import crc32c as _crc32c # type: ignore[no-redef, unused-ignore]
17+
import google_crc32c as _crc32c # type: ignore[no-redef, unused-ignore]
1818

1919
CHECKSUM_LOCATION = Literal['start', 'end']
2020

@@ -179,5 +179,11 @@ class CRC32C(Checksum32):
179179
"""
180180

181181
codec_id = 'crc32c'
182-
checksum = _crc32c.crc32c # type: ignore[union-attr]
183182
location = 'end'
183+
184+
@staticmethod
185+
def checksum(data: Buffer, value: int = 0) -> int:
186+
if value == 0:
187+
return _crc32c.value(data) # type: ignore[union-attr]
188+
else:
189+
return _crc32c.extend(value, data) # type: ignore[union-attr]

numcodecs/tests/test_checksum32.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,25 @@ def test_crc32c_checksum():
145145
assert np.frombuffer(buf, dtype="<u4", offset=(len(buf) - 4))[0] == np.uint32(4218238699)
146146

147147

148+
@pytest.mark.skipif(not has_crc32c, reason="Needs `crc32c` installed")
149+
def test_crc32c_incremental():
150+
"""Test that CRC32C.checksum supports incremental calculation via value parameter."""
151+
# Test incremental checksum calculation (for API compatibility)
152+
data1 = np.frombuffer(b"hello", dtype='uint8')
153+
data2 = np.frombuffer(b" world", dtype='uint8')
154+
full_data = np.frombuffer(b"hello world", dtype='uint8')
155+
156+
# Calculate checksum in one go
157+
checksum_full = CRC32C.checksum(full_data)
158+
159+
# Calculate incrementally using the value parameter
160+
checksum_part1 = CRC32C.checksum(data1, 0)
161+
checksum_part2 = CRC32C.checksum(data2, checksum_part1)
162+
163+
# Both methods should produce the same result
164+
assert checksum_full == checksum_part2
165+
166+
148167
@pytest.mark.parametrize("codec", codecs)
149168
def test_err_checksum(codec):
150169
arr = np.arange(0, 64, dtype="uint8")

0 commit comments

Comments
 (0)