Skip to content

Commit c367483

Browse files
authored
Merge branch 'main' into feature/store_erase_prefix
2 parents 858d4fb + a9d6d74 commit c367483

File tree

4 files changed

+109
-12
lines changed

4 files changed

+109
-12
lines changed

.github/workflows/test.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,35 @@ 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+
test-upstream-and-min-deps:
48+
name: py=${{ matrix.python-version }}-${{ matrix.dependency-set }}
49+
50+
runs-on: ubuntu-latest
51+
strategy:
52+
matrix:
53+
python-version: ['3.11', "3.13"]
54+
dependency-set: ["upstream", "min_deps"]
55+
exclude:
56+
- python-version: "3.13"
57+
dependency-set: min_deps
58+
- python-version: "3.11"
59+
dependency-set: upstream
60+
steps:
61+
- uses: actions/checkout@v4
62+
- name: Set up Python
63+
uses: actions/setup-python@v5
64+
with:
65+
python-version: ${{ matrix.python-version }}
66+
cache: 'pip'
67+
- name: Install Hatch
68+
run: |
69+
python -m pip install --upgrade pip
70+
pip install hatch
71+
- name: Set Up Hatch Env
72+
run: |
73+
hatch env create ${{ matrix.dependency-set }}
74+
hatch env run -e ${{ matrix.dependency-set }} list-env
75+
- name: Run Tests
76+
run: |
77+
hatch env run --env ${{ matrix.dependency-set }} run

pyproject.toml

Lines changed: 66 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,13 @@ requires-python = ">=3.11"
2828
dependencies = [
2929
'asciitree',
3030
'numpy>=1.25',
31-
'numcodecs>=0.10.2',
32-
'fsspec>2024',
33-
'crc32c',
34-
'typing_extensions',
35-
'donfig',
31+
'numcodecs>=0.13',
32+
'fsspec>=2022.10.0',
33+
'crc32c>=2.3',
34+
'typing_extensions>=4.6',
35+
'donfig>=0.8',
3636
]
37+
3738
dynamic = [
3839
"version",
3940
]
@@ -98,7 +99,7 @@ extra = [
9899
]
99100
optional = [
100101
'lmdb',
101-
'universal-pathlib',
102+
'universal-pathlib>=0.0.22',
102103
]
103104

104105
[project.urls]
@@ -183,6 +184,65 @@ features = ['docs']
183184
build = "cd docs && make html"
184185
serve = "sphinx-autobuild docs docs/_build --host 0.0.0.0"
185186

187+
[tool.hatch.envs.upstream]
188+
python = "3.13"
189+
dependencies = [
190+
'numpy', # from scientific-python-nightly-wheels
191+
'numcodecs @ git+https://github.com/zarr-developers/numcodecs',
192+
'fsspec @ git+https://github.com/fsspec/filesystem_spec',
193+
's3fs @ git+https://github.com/fsspec/s3fs',
194+
'universal_pathlib @ git+https://github.com/fsspec/universal_pathlib',
195+
'crc32c @ git+https://github.com/ICRAR/crc32c',
196+
'typing_extensions @ git+https://github.com/python/typing_extensions',
197+
'donfig @ git+https://github.com/pytroll/donfig',
198+
# test deps
199+
'hypothesis',
200+
'pytest',
201+
'pytest-cov',
202+
'pytest-asyncio',
203+
'moto[s3]',
204+
]
205+
206+
[tool.hatch.envs.upstream.env-vars]
207+
PIP_INDEX_URL = "https://pypi.anaconda.org/scientific-python-nightly-wheels/simple/"
208+
PIP_EXTRA_INDEX_URL = "https://pypi.org/simple/"
209+
PIP_PRE = "1"
210+
211+
[tool.hatch.envs.upstream.scripts]
212+
run = "pytest --verbose"
213+
run-mypy = "mypy src"
214+
run-hypothesis = "pytest --hypothesis-profile ci tests/test_properties.py tests/test_store/test_stateful*"
215+
list-env = "pip list"
216+
217+
[tool.hatch.envs.min_deps]
218+
description = """Test environment for minimum supported dependencies
219+
220+
See Spec 0000 for details and drop schedule: https://scientific-python.org/specs/spec-0000/
221+
"""
222+
python = "3.11"
223+
dependencies = [
224+
'numpy==1.25.*',
225+
'numcodecs==0.13.*', # 0.13 needed for? (should be 0.11)
226+
'fsspec==2022.10.0',
227+
's3fs==2022.10.0',
228+
'universal_pathlib==0.0.22',
229+
'crc32c==2.3.*',
230+
'typing_extensions==4.6.*', # 4.5 needed for @deprecated, 4.6 for Buffer
231+
'donfig==0.8.*',
232+
# test deps
233+
'hypothesis',
234+
'pytest',
235+
'pytest-cov',
236+
'pytest-asyncio',
237+
'moto[s3]',
238+
]
239+
240+
[tool.hatch.envs.min_deps.scripts]
241+
run = "pytest --verbose"
242+
run-hypothesis = "pytest --hypothesis-profile ci tests/test_properties.py tests/test_store/test_stateful*"
243+
list-env = "pip list"
244+
245+
186246
[tool.ruff]
187247
line-length = 100
188248
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."

src/zarr/storage/remote.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
from typing import TYPE_CHECKING, Any, Self
44

5-
import fsspec
6-
75
from zarr.abc.store import ByteRangeRequest, Store
86
from zarr.storage.common import _dereference_path
97

@@ -130,7 +128,13 @@ def from_url(
130128
-------
131129
RemoteStore
132130
"""
133-
fs, path = fsspec.url_to_fs(url, **storage_options)
131+
try:
132+
from fsspec import url_to_fs
133+
except ImportError:
134+
# before fsspec==2024.3.1
135+
from fsspec.core import url_to_fs
136+
137+
fs, path = url_to_fs(url, **storage_options)
134138
return cls(fs=fs, path=path, mode=mode, allowed_exceptions=allowed_exceptions)
135139

136140
async def clear(self) -> None:

0 commit comments

Comments
 (0)