From 7b84806aa645a130efbae486b2ed2d58fa86f7ad Mon Sep 17 00:00:00 2001 From: Joseph Hamman Date: Sat, 19 Oct 2024 21:14:56 -0700 Subject: [PATCH 1/2] test(ci): add test environment for upstream dependencies --- .github/workflows/test.yml | 27 +++++++++++++++++++++++++++ pyproject.toml | 29 +++++++++++++++++++++++++++++ src/zarr/codecs/zstd.py | 7 ++++--- 3 files changed, 60 insertions(+), 3 deletions(-) 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 574b09b076..9268a873f4 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>=2.2.0.dev0', + '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]', +] + +# help! this is not working for numpy :( +[tool.hatch.envs.upstream.env-vars] +PIP_EXTRA_INDEX_URL = "https://pypi.anaconda.org/scientific-python-nightly-wheels/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." From 4c9619b29a95adf5fafcfefcaa8d48cb11ddf267 Mon Sep 17 00:00:00 2001 From: Joseph Hamman Date: Sun, 20 Oct 2024 08:24:37 -0700 Subject: [PATCH 2/2] try PIP_INDEX_URL again --- pyproject.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 9268a873f4..b143812178 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -185,7 +185,7 @@ serve = "sphinx-autobuild docs docs/_build --host 0.0.0.0" [tool.hatch.envs.upstream] dependencies = [ - 'numpy>=2.2.0.dev0', + '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', @@ -201,9 +201,9 @@ dependencies = [ 'moto[s3]', ] -# help! this is not working for numpy :( [tool.hatch.envs.upstream.env-vars] -PIP_EXTRA_INDEX_URL = "https://pypi.anaconda.org/scientific-python-nightly-wheels/simple" +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]