Skip to content

Commit 1e8c0a8

Browse files
authored
test(ci): add test environment for upstream dependencies (zarr-developers#2418)
1 parent 37fde7d commit 1e8c0a8

File tree

3 files changed

+60
-3
lines changed

3 files changed

+60
-3
lines changed

.github/workflows/test.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,30 @@ jobs:
4343
- name: Run Tests
4444
run: |
4545
hatch env run --env test.py${{ matrix.python-version }}-${{ matrix.numpy-version }}-${{ matrix.dependency-set }} run
46+
47+
upstream:
48+
name: py=${{ matrix.python-version }}-upstream
49+
50+
runs-on: ubuntu-latest
51+
strategy:
52+
matrix:
53+
python-version: ['3.13']
54+
55+
steps:
56+
- uses: actions/checkout@v4
57+
- name: Set up Python
58+
uses: actions/setup-python@v5
59+
with:
60+
python-version: ${{ matrix.python-version }}
61+
cache: 'pip'
62+
- name: Install Hatch
63+
run: |
64+
python -m pip install --upgrade pip
65+
pip install hatch
66+
- name: Set Up Hatch Env
67+
run: |
68+
hatch env create upstream
69+
hatch env run -e upstream list-env
70+
- name: Run Tests
71+
run: |
72+
hatch env run --env upstream run

pyproject.toml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,35 @@ features = ['docs']
183183
build = "cd docs && make html"
184184
serve = "sphinx-autobuild docs docs/_build --host 0.0.0.0"
185185

186+
[tool.hatch.envs.upstream]
187+
dependencies = [
188+
'numpy', # from scientific-python-nightly-wheels
189+
'numcodecs @ git+https://github.com/zarr-developers/numcodecs',
190+
'fsspec @ git+https://github.com/fsspec/filesystem_spec',
191+
's3fs @ git+https://github.com/fsspec/s3fs',
192+
'universal_pathlib @ git+https://github.com/fsspec/universal_pathlib',
193+
'crc32c @ git+https://github.com/ICRAR/crc32c',
194+
'typing_extensions @ git+https://github.com/python/typing_extensions',
195+
'donfig @ git+https://github.com/pytroll/donfig',
196+
# test deps
197+
'hypothesis',
198+
'pytest',
199+
'pytest-cov',
200+
'pytest-asyncio',
201+
'moto[s3]',
202+
]
203+
204+
[tool.hatch.envs.upstream.env-vars]
205+
PIP_INDEX_URL = "https://pypi.anaconda.org/scientific-python-nightly-wheels/simple/"
206+
PIP_EXTRA_INDEX_URL = "https://pypi.org/simple/"
207+
PIP_PRE = "1"
208+
209+
[tool.hatch.envs.upstream.scripts]
210+
run = "pytest --verbose"
211+
run-mypy = "mypy src"
212+
run-hypothesis = "pytest --hypothesis-profile ci tests/test_properties.py tests/test_store/test_stateful*"
213+
list-env = "pip list"
214+
186215
[tool.ruff]
187216
line-length = 100
188217
force-exclude = true

src/zarr/codecs/zstd.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
import asyncio
44
from dataclasses import dataclass
55
from functools import cached_property
6-
from importlib.metadata import version
76
from typing import TYPE_CHECKING
87

8+
import numcodecs
99
from numcodecs.zstd import Zstd
10+
from packaging.version import Version
1011

1112
from zarr.abc.codec import BytesBytesCodec
1213
from zarr.core.buffer.cpu import as_numpy_array_wrapper
@@ -43,8 +44,8 @@ class ZstdCodec(BytesBytesCodec):
4344

4445
def __init__(self, *, level: int = 0, checksum: bool = False) -> None:
4546
# numcodecs 0.13.0 introduces the checksum attribute for the zstd codec
46-
_numcodecs_version = tuple(map(int, version("numcodecs").split(".")))
47-
if _numcodecs_version < (0, 13, 0): # pragma: no cover
47+
_numcodecs_version = Version(numcodecs.__version__)
48+
if _numcodecs_version < Version("0.13.0"):
4849
raise RuntimeError(
4950
"numcodecs version >= 0.13.0 is required to use the zstd codec. "
5051
f"Version {_numcodecs_version} is currently installed."

0 commit comments

Comments
 (0)