Skip to content

Commit f4e0d3c

Browse files
committed
crc32c as optional dep
1 parent 237eb72 commit f4e0d3c

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ jobs:
6161
conda activate env
6262
export DISABLE_NUMCODECS_AVX2=""
6363
# TODO: put back zfpy import when it supports numpy 2.0
64-
python -m pip install -v -e .[test,test_extras,msgpack]
64+
python -m pip install -v -e .[test,test_extras,msgpack,crc32c]
6565
6666
- name: Install pcodec
6767
if: matrix.python-version != '3.13.0'

numcodecs/checksum32.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from typing import Literal
44

55
import numpy as np
6-
from crc32c import crc32c as crc32c_
76

87
from .abc import Codec
98
from .compat import ensure_contiguous_ndarray, ndarray_copy
@@ -83,7 +82,15 @@ class CRC32C(Checksum32):
8382
"""
8483

8584
codec_id = 'crc32c'
86-
checksum = crc32c_
85+
86+
def checksum(self, buf):
87+
try:
88+
from crc32c import crc32c as crc32c_
89+
90+
return crc32c_(buf)
91+
except ImportError:
92+
raise ImportError("crc32c must be installed to use the CRC32C checksum codec.")
93+
8794
location = 'end'
8895

8996

pyproject.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ for use in data storage and communication applications."""
1616
readme = "README.rst"
1717
dependencies = [
1818
"numpy>=1.7",
19-
"crc32c>=2.7",
2019
]
2120
requires-python = ">=3.10"
2221
dynamic = [
@@ -71,6 +70,9 @@ zfpy = [
7170
pcodec = [
7271
"pcodec>=0.2.0",
7372
]
73+
crc32c = [
74+
"crc32c>=2.7",
75+
]
7476

7577
[tool.setuptools]
7678
license-files = ["LICENSE.txt"]

0 commit comments

Comments
 (0)