diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3c83da8 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/zarr-2.2.0.tar.gz diff --git a/0001-DOC-Use-unittest.mock-on-Python-3.patch b/0001-DOC-Use-unittest.mock-on-Python-3.patch new file mode 100644 index 0000000..c91469a --- /dev/null +++ b/0001-DOC-Use-unittest.mock-on-Python-3.patch @@ -0,0 +1,34 @@ +From 76d8339954ce793d7cdbad3ab06bf2df4a8fc81a Mon Sep 17 00:00:00 2001 +From: Elliott Sales de Andrade +Date: Sat, 16 Mar 2019 01:48:27 -0400 +Subject: [PATCH 1/3] DOC: Use unittest.mock on Python 3. + +Signed-off-by: Elliott Sales de Andrade +--- + docs/conf.py | 7 +++++-- + 1 file changed, 5 insertions(+), 2 deletions(-) + +diff --git a/docs/conf.py b/docs/conf.py +index 5947013..905f497 100644 +--- a/docs/conf.py ++++ b/docs/conf.py +@@ -16,11 +16,14 @@ + + import sys + import os +-from mock import Mock as MagicMock +- + + PY2 = sys.version_info[0] == 2 + ++if PY2: ++ from mock import Mock as MagicMock ++else: ++ from unittest.mock import Mock as MagicMock ++ + + class Mock(MagicMock): + @classmethod +-- +2.20.1 + diff --git a/0002-fix-failing-pickle-tests.patch b/0002-fix-failing-pickle-tests.patch new file mode 100644 index 0000000..d98073b --- /dev/null +++ b/0002-fix-failing-pickle-tests.patch @@ -0,0 +1,178 @@ +From 7599eed8358ddb38b07979556ac314f71bbb009f Mon Sep 17 00:00:00 2001 +From: Alistair Miles +Date: Thu, 18 Oct 2018 14:39:17 +0100 +Subject: [PATCH 2/3] fix failing pickle tests + +Signed-off-by: Elliott Sales de Andrade +--- + zarr/storage.py | 6 +++++- + zarr/tests/test_core.py | 40 +++++++++++++++++++++++++++--------- + zarr/tests/test_hierarchy.py | 36 +++++++++++++++++++------------- + zarr/tests/test_storage.py | 20 +++++++++++++++--- + 4 files changed, 74 insertions(+), 28 deletions(-) + +diff --git a/zarr/storage.py b/zarr/storage.py +index 7a5273c..52d372b 100644 +--- a/zarr/storage.py ++++ b/zarr/storage.py +@@ -1440,7 +1440,11 @@ class DBMStore(MutableMapping): + self.open_kwargs = open_kwargs + + def __getstate__(self): +- self.flush() # needed for py2 and ndbm ++ try: ++ self.flush() # needed for py2 and ndbm ++ except Exception: ++ # flush may fail if db has already been closed ++ pass + return (self.path, self.flag, self.mode, self.open, self.write_lock, + self.open_kwargs) + +diff --git a/zarr/tests/test_core.py b/zarr/tests/test_core.py +index 390f888..bc95703 100644 +--- a/zarr/tests/test_core.py ++++ b/zarr/tests/test_core.py +@@ -656,19 +656,39 @@ class TestArray(unittest.TestCase): + + def test_pickle(self): + ++ # setup array + z = self.create_array(shape=1000, chunks=100, dtype=int, cache_metadata=False, + cache_attrs=False) +- z[:] = np.random.randint(0, 1000, 1000) +- z2 = pickle.loads(pickle.dumps(z)) +- assert z.shape == z2.shape +- assert z.chunks == z2.chunks +- assert z.dtype == z2.dtype ++ shape = z.shape ++ chunks = z.chunks ++ dtype = z.dtype ++ compressor_config = None + if z.compressor: +- assert z.compressor.get_config() == z2.compressor.get_config() +- assert z.fill_value == z2.fill_value +- assert z._cache_metadata == z2._cache_metadata +- assert z.attrs.cache == z2.attrs.cache +- assert_array_equal(z[:], z2[:]) ++ compressor_config = z.compressor.get_config() ++ fill_value = z.fill_value ++ cache_metadata = z._cache_metadata ++ attrs_cache = z.attrs.cache ++ a = np.random.randint(0, 1000, 1000) ++ z[:] = a ++ ++ # round trip through pickle ++ dump = pickle.dumps(z) ++ # some stores cannot be opened twice at the same time, need to close first ++ # store before can round-trip through pickle ++ if hasattr(z.store, 'close'): ++ z.store.close() ++ z2 = pickle.loads(dump) ++ ++ # verify ++ assert shape == z2.shape ++ assert chunks == z2.chunks ++ assert dtype == z2.dtype ++ if z2.compressor: ++ assert compressor_config == z2.compressor.get_config() ++ assert fill_value == z2.fill_value ++ assert cache_metadata == z2._cache_metadata ++ assert attrs_cache == z2.attrs.cache ++ assert_array_equal(a, z2[:]) + + def test_np_ufuncs(self): + z = self.create_array(shape=(100, 100), chunks=(10, 10)) +diff --git a/zarr/tests/test_hierarchy.py b/zarr/tests/test_hierarchy.py +index f47012c..7820441 100644 +--- a/zarr/tests/test_hierarchy.py ++++ b/zarr/tests/test_hierarchy.py +@@ -820,23 +820,31 @@ class TestGroup(unittest.TestCase): + g1['foo/../bar'] + + def test_pickle(self): +- # setup ++ ++ # setup group + g = self.create_group() + d = g.create_dataset('foo/bar', shape=100, chunks=10) + d[:] = np.arange(100) +- +- # needed for zip store +- if hasattr(g.store, 'flush'): +- g.store.flush() +- +- # pickle round trip +- g2 = pickle.loads(pickle.dumps(g)) +- assert g.path == g2.path +- assert g.name == g2.name +- assert len(g) == len(g2) +- assert list(g) == list(g2) +- assert g['foo'] == g2['foo'] +- assert g['foo/bar'] == g2['foo/bar'] ++ path = g.path ++ name = g.name ++ n = len(g) ++ keys = list(g) ++ ++ # round-trip through pickle ++ dump = pickle.dumps(g) ++ # some stores cannot be opened twice at the same time, need to close first ++ # store before can round-trip through pickle ++ if hasattr(g.store, 'close'): ++ g.store.close() ++ g2 = pickle.loads(dump) ++ ++ # verify ++ assert path == g2.path ++ assert name == g2.name ++ assert n == len(g2) ++ assert keys == list(g2) ++ assert isinstance(g2['foo'], Group) ++ assert isinstance(g2['foo/bar'], Array) + + + class TestGroupWithDictStore(TestGroup): +diff --git a/zarr/tests/test_storage.py b/zarr/tests/test_storage.py +index f68f8a6..10e615b 100644 +--- a/zarr/tests/test_storage.py ++++ b/zarr/tests/test_storage.py +@@ -128,12 +128,25 @@ class StoreTests(object): + set(store.items())) + + def test_pickle(self): ++ ++ # setup store + store = self.create_store() + store['foo'] = b'bar' + store['baz'] = b'quux' +- store2 = pickle.loads(pickle.dumps(store)) +- assert len(store) == len(store2) +- assert sorted(store.keys()) == sorted(store2.keys()) ++ n = len(store) ++ keys = sorted(store.keys()) ++ ++ # round-trip through pickle ++ dump = pickle.dumps(store) ++ # some stores cannot be opened twice at the same time, need to close first ++ # store before can round-trip through pickle ++ if hasattr(store, 'close'): ++ store.close() ++ store2 = pickle.loads(dump) ++ ++ # verify ++ assert n == len(store2) ++ assert keys == sorted(store2.keys()) + assert b'bar' == store2['foo'] + assert b'quux' == store2['baz'] + +@@ -745,6 +758,7 @@ class TestDBMStore(StoreTests, unittest.TestCase): + def create_store(self): + path = tempfile.mktemp(suffix='.anydbm') + atexit.register(atexit_rmglob, path + '*') ++ # create store using default dbm implementation + store = DBMStore(path, flag='n') + return store + +-- +2.20.1 + diff --git a/0003-Assert-MsgPack-round-trips-bytes-objects-correctly.patch b/0003-Assert-MsgPack-round-trips-bytes-objects-correctly.patch new file mode 100644 index 0000000..12a4122 --- /dev/null +++ b/0003-Assert-MsgPack-round-trips-bytes-objects-correctly.patch @@ -0,0 +1,31 @@ +From 0b651a1ce7f791328803edf12f90c988fc907780 Mon Sep 17 00:00:00 2001 +From: John Kirkham +Date: Fri, 30 Nov 2018 13:06:29 -0500 +Subject: [PATCH 3/3] Assert MsgPack round-trips bytes objects correctly + +Previously MsgPack was turning bytes objects to unicode objects when +round-tripping them. However this has been fixed in the latest version +of Numcodecs. So correct this test now that MsgPack is working +correctly. + +Signed-off-by: Elliott Sales de Andrade +--- + zarr/tests/test_core.py | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/zarr/tests/test_core.py b/zarr/tests/test_core.py +index bc95703..5056454 100644 +--- a/zarr/tests/test_core.py ++++ b/zarr/tests/test_core.py +@@ -926,7 +926,7 @@ class TestArray(unittest.TestCase): + z[0] = 'foo' + assert z[0] == 'foo' + z[1] = b'bar' +- assert z[1] == 'bar' # msgpack gets this wrong ++ assert z[1] == b'bar' + z[2] = 1 + assert z[2] == 1 + z[3] = [2, 4, 6, 'baz'] +-- +2.20.1 + diff --git a/python-zarr.spec b/python-zarr.spec new file mode 100644 index 0000000..695e421 --- /dev/null +++ b/python-zarr.spec @@ -0,0 +1,101 @@ +%global srcname zarr + +Name: python-%{srcname} +Version: 2.2.0 +Release: 2%{?dist} +Summary: An implementation of chunked, compressed, N-dimensional arrays for Python + +License: MIT +URL: https://github.com/zarr-developers/zarr +Source0: %{pypi_source} +Patch0001: 0001-DOC-Use-unittest.mock-on-Python-3.patch +# https://github.com/zarr-developers/zarr/pull/308 +Patch0002: 0002-fix-failing-pickle-tests.patch +# https://github.com/zarr-developers/zarr/pull/352 +Patch0003: 0003-Assert-MsgPack-round-trips-bytes-objects-correctly.patch + +BuildArch: noarch + +BuildRequires: python3-devel +BuildRequires: python3dist(asciitree) +BuildRequires: python3dist(bsddb3) +BuildRequires: python3dist(fasteners) +BuildRequires: python3dist(h5py) +BuildRequires: python3dist(lmdb) +BuildRequires: python3dist(msgpack) +BuildRequires: python3dist(numcodecs) >= 0.5.3 +BuildRequires: python3dist(numpy) >= 1.7 +BuildRequires: python3dist(pytest) +BuildRequires: python3dist(setuptools) +BuildRequires: python3dist(setuptools) > 18.0 +BuildRequires: python3dist(setuptools-scm) > 1.5.4 + +%description +Zarr is a Python package providing an implementation of compressed, chunked, +N-dimensional arrays, designed for use in parallel computing. + + +%package -n python3-%{srcname} +Summary: %{summary} +%{?python_provide:%python_provide python3-%{srcname}} + +%description -n python3-%{srcname} +Zarr is a Python package providing an implementation of compressed, chunked, +N-dimensional arrays, designed for use in parallel computing. + + +%package -n python-%{srcname}-doc +Summary: zarr documentation + +BuildArch: noarch + +BuildRequires: python3dist(numpydoc) +BuildRequires: python3dist(sphinx) +BuildRequires: python3dist(sphinx-issues) + +%description -n python-%{srcname}-doc +Documentation for zarr + + +%prep +%autosetup -n %{srcname}-%{version} -p1 + +# Remove bundled egg-info +rm -rf %{srcname}.egg-info + + +%build +%py3_build + +# generate html docs +PYTHONPATH=${PWD} sphinx-build-3 docs html +# remove the sphinx-build leftovers +rm -rf html/.{doctrees,buildinfo} + + +%install +%py3_install + + +%check +%{__python3} -m pytest + + +%files -n python3-%{srcname} +%license LICENSE +%doc README.rst +%{python3_sitelib}/%{srcname} +%{python3_sitelib}/%{srcname}-%{version}-py?.?.egg-info + +%files -n python-%{srcname}-doc +%doc html +%license LICENSE + + +%changelog +* Mon Mar 18 2019 Elliott Sales de Andrade - 2.2.0-2 +- Fix test running +- Make doc subpackage noarch + +* Sat Mar 16 2019 Elliott Sales de Andrade - 2.2.0-1 +- Initial package. diff --git a/sources b/sources new file mode 100644 index 0000000..52e0b61 --- /dev/null +++ b/sources @@ -0,0 +1 @@ +SHA512 (zarr-2.2.0.tar.gz) = 8ae8b04107e7846ff66df35aebfb50aae19317128d536ec842423347244af668d9ffb91dccba0b6fcd6d266015fc68fac349495ef855fbc61e237924a9cdff6f