diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3bd6226922..e09975e444 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -43,3 +43,30 @@ jobs: - name: Run Tests run: | hatch env run --env test.py${{ matrix.python-version }}-${{ matrix.numpy-version }}-${{ matrix.dependency-set }} run + + upstream: + name: py=${{ matrix.python-version }}-upstream + + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ['3.13'] + + steps: + - uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + cache: 'pip' + - name: Install Hatch + run: | + python -m pip install --upgrade pip + pip install hatch + - name: Set Up Hatch Env + run: | + hatch env create upstream + hatch env run -e upstream list-env + - name: Run Tests + run: | + hatch env run --env upstream run diff --git a/pyproject.toml b/pyproject.toml index 84ec8b9a5d..e3d8a310b1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -183,6 +183,35 @@ features = ['docs'] build = "cd docs && make html" serve = "sphinx-autobuild docs docs/_build --host 0.0.0.0" +[tool.hatch.envs.upstream] +dependencies = [ + 'numpy', # from scientific-python-nightly-wheels + 'numcodecs @ git+https://github.com/zarr-developers/numcodecs', + 'fsspec @ git+https://github.com/fsspec/filesystem_spec', + 's3fs @ git+https://github.com/fsspec/s3fs', + 'universal_pathlib @ git+https://github.com/fsspec/universal_pathlib', + 'crc32c @ git+https://github.com/ICRAR/crc32c', + 'typing_extensions @ git+https://github.com/python/typing_extensions', + 'donfig @ git+https://github.com/pytroll/donfig', + # test deps + 'hypothesis', + 'pytest', + 'pytest-cov', + 'pytest-asyncio', + 'moto[s3]', +] + +[tool.hatch.envs.upstream.env-vars] +PIP_INDEX_URL = "https://pypi.anaconda.org/scientific-python-nightly-wheels/simple/" +PIP_EXTRA_INDEX_URL = "https://pypi.org/simple/" +PIP_PRE = "1" + +[tool.hatch.envs.upstream.scripts] +run = "pytest --verbose" +run-mypy = "mypy src" +run-hypothesis = "pytest --hypothesis-profile ci tests/test_properties.py tests/test_store/test_stateful*" +list-env = "pip list" + [tool.ruff] line-length = 100 force-exclude = true diff --git a/src/zarr/codecs/zstd.py b/src/zarr/codecs/zstd.py index 949f762b20..b4a4a13c29 100644 --- a/src/zarr/codecs/zstd.py +++ b/src/zarr/codecs/zstd.py @@ -3,10 +3,11 @@ import asyncio from dataclasses import dataclass from functools import cached_property -from importlib.metadata import version from typing import TYPE_CHECKING +import numcodecs from numcodecs.zstd import Zstd +from packaging.version import Version from zarr.abc.codec import BytesBytesCodec from zarr.core.buffer.cpu import as_numpy_array_wrapper @@ -43,8 +44,8 @@ class ZstdCodec(BytesBytesCodec): def __init__(self, *, level: int = 0, checksum: bool = False) -> None: # numcodecs 0.13.0 introduces the checksum attribute for the zstd codec - _numcodecs_version = tuple(map(int, version("numcodecs").split("."))) - if _numcodecs_version < (0, 13, 0): # pragma: no cover + _numcodecs_version = Version(numcodecs.__version__) + if _numcodecs_version < Version("0.13.0"): raise RuntimeError( "numcodecs version >= 0.13.0 is required to use the zstd codec. " f"Version {_numcodecs_version} is currently installed."