Sync from SUSE:ALP:Source:Standard:1.0 python-numcodecs revision 755e4dda643d95f723d966ef7404d273

This commit is contained in:
Adrian Schröter 2024-01-05 10:02:32 +01:00
commit f5d904f396
7 changed files with 537 additions and 0 deletions

23
.gitattributes vendored Normal file
View File

@ -0,0 +1,23 @@
## Default LFS
*.7z filter=lfs diff=lfs merge=lfs -text
*.bsp filter=lfs diff=lfs merge=lfs -text
*.bz2 filter=lfs diff=lfs merge=lfs -text
*.gem filter=lfs diff=lfs merge=lfs -text
*.gz filter=lfs diff=lfs merge=lfs -text
*.jar filter=lfs diff=lfs merge=lfs -text
*.lz filter=lfs diff=lfs merge=lfs -text
*.lzma filter=lfs diff=lfs merge=lfs -text
*.obscpio filter=lfs diff=lfs merge=lfs -text
*.oxt filter=lfs diff=lfs merge=lfs -text
*.pdf filter=lfs diff=lfs merge=lfs -text
*.png filter=lfs diff=lfs merge=lfs -text
*.rpm filter=lfs diff=lfs merge=lfs -text
*.tbz filter=lfs diff=lfs merge=lfs -text
*.tbz2 filter=lfs diff=lfs merge=lfs -text
*.tgz filter=lfs diff=lfs merge=lfs -text
*.ttf filter=lfs diff=lfs merge=lfs -text
*.txz filter=lfs diff=lfs merge=lfs -text
*.whl filter=lfs diff=lfs merge=lfs -text
*.xz filter=lfs diff=lfs merge=lfs -text
*.zip filter=lfs diff=lfs merge=lfs -text
*.zst filter=lfs diff=lfs merge=lfs -text

View File

@ -0,0 +1,95 @@
From af20af8210384371f91f30251fc78a35ffd0c072 Mon Sep 17 00:00:00 2001
From: Steve Kowalik <steven@wedontsleep.org>
Date: Wed, 9 Aug 2023 15:15:52 +1000
Subject: [PATCH] Remove use of entrypoints
Since Python 3.8, the standard library has included functionality to
query entry points directly using importlib.metadata. Since the API has
changed for the better with Python 3.10, we need to support both ways of
using it.
---
numcodecs/registry.py | 14 +++++++++-----
numcodecs/tests/test_entrypoints.py | 2 --
pyproject.toml | 7 ++++++-
3 files changed, 15 insertions(+), 8 deletions(-)
diff --git a/numcodecs/registry.py b/numcodecs/registry.py
index 532e9967..a4dff6d7 100644
--- a/numcodecs/registry.py
+++ b/numcodecs/registry.py
@@ -1,7 +1,7 @@
"""The registry module provides some simple convenience functions to enable
applications to dynamically register and look-up codec classes."""
+from importlib.metadata import entry_points
import logging
-from contextlib import suppress
logger = logging.getLogger("numcodecs")
codec_registry = {}
@@ -9,13 +9,17 @@
def run_entrypoints():
- import entrypoints
entries.clear()
- entries.update(entrypoints.get_group_named("numcodecs.codecs"))
+ eps = entry_points()
+ if hasattr(eps, 'select'):
+ # If entry_points() has a select method, use that. Python 3.10+
+ entries.update(eps.select(group="numcodecs.codecs"))
+ else:
+ # Otherwise, fallback to using get
+ entries.update(eps.get("numcodecs.codecs", []))
-with suppress(ImportError):
- run_entrypoints()
+run_entrypoints()
def get_codec(config):
diff --git a/numcodecs/tests/test_entrypoints.py b/numcodecs/tests/test_entrypoints.py
index 81af635d..0d017f2d 100644
--- a/numcodecs/tests/test_entrypoints.py
+++ b/numcodecs/tests/test_entrypoints.py
@@ -7,7 +7,6 @@
here = os.path.abspath(os.path.dirname(__file__))
-pytest.importorskip("entrypoints")
@pytest.fixture()
@@ -20,7 +19,6 @@ def set_path():
numcodecs.registry.codec_registry.pop("test")
-@pytest.mark.xfail(reason="FIXME: not working in wheels build")
def test_entrypoint_codec(set_path):
cls = numcodecs.registry.get_codec({"id": "test"})
assert cls.codec_id == "test"
diff --git a/pyproject.toml b/pyproject.toml
index a2b50e32..147f9b54 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -15,7 +15,6 @@ in data storage and communication applications.
"""
readme = "README.rst"
dependencies = [
- "entrypoints",
"numpy>=1.7",
]
requires-python = ">=3.8"
@@ -71,6 +70,12 @@ package-dir = {"" = "."}
packages = ["numcodecs", "numcodecs.tests"]
zip-safe = false
+[tool.setuptools.package-data]
+numcodecs = [
+ "tests/package_with_entrypoint/__init__.py",
+ "tests/package_with_entrypoint-0.1.dist-info/entry_points.txt"
+]
+
[tool.setuptools_scm]
version_scheme = "guess-next-dev"
local_scheme = "dirty-tag"

BIN
numcodecs-0.11.0.tar.gz (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -0,0 +1,151 @@
diff --git a/numcodecs/json.py b/numcodecs/json.py
index 670f223..b803a77 100644
--- a/numcodecs/json.py
+++ b/numcodecs/json.py
@@ -54,7 +54,10 @@ class JSON(Codec):
self._decoder = _json.JSONDecoder(**self._decoder_config)
def encode(self, buf):
- buf = np.asarray(buf)
+ try:
+ buf = np.asarray(buf)
+ except ValueError:
+ buf = np.asarray(buf, dtype=object)
items = buf.tolist()
items.extend((buf.dtype.str, buf.shape))
return self._encoder.encode(items).encode(self._text_encoding)
diff --git a/numcodecs/msgpacks.py b/numcodecs/msgpacks.py
index 026f583..6556498 100644
--- a/numcodecs/msgpacks.py
+++ b/numcodecs/msgpacks.py
@@ -52,7 +52,10 @@ class MsgPack(Codec):
self.raw = raw
def encode(self, buf):
- buf = np.asarray(buf)
+ try:
+ buf = np.asarray(buf)
+ except ValueError:
+ buf = np.asarray(buf, dtype=object)
items = buf.tolist()
items.extend((buf.dtype.str, buf.shape))
return msgpack.packb(items, use_bin_type=self.use_bin_type,
diff --git a/numcodecs/tests/test_json.py b/numcodecs/tests/test_json.py
index 7e8fcd6..8dac2b4 100644
--- a/numcodecs/tests/test_json.py
+++ b/numcodecs/tests/test_json.py
@@ -2,7 +2,7 @@ import itertools
import numpy as np
-
+import pytest
from numcodecs.json import JSON
from numcodecs.tests.common import (check_config, check_repr, check_encode_decode_array,
@@ -53,21 +53,23 @@ def test_backwards_compatibility():
check_backwards_compatibility(JSON.codec_id, arrays, codecs)
-def test_non_numpy_inputs():
+@pytest.mark.parametrize(
+ "input_data, dtype",
+ [
+ ([0, 1], None),
+ ([[0, 1], [2, 3]], None),
+ ([[0], [1], [2, 3]], object),
+ ([[[0, 0]], [[1, 1]], [[2, 3]]], None),
+ (["1"], None),
+ (["11", "11"], None),
+ (["11", "1", "1"], None),
+ ([{}], None),
+ ([{"key": "value"}, ["list", "of", "strings"]], object),
+ ]
+)
+def test_non_numpy_inputs(input_data, dtype):
# numpy will infer a range of different shapes and dtypes for these inputs.
# Make sure that round-tripping through encode preserves this.
- data = [
- [0, 1],
- [[0, 1], [2, 3]],
- [[0], [1], [2, 3]],
- [[[0, 0]], [[1, 1]], [[2, 3]]],
- ["1"],
- ["11", "11"],
- ["11", "1", "1"],
- [{}],
- [{"key": "value"}, ["list", "of", "strings"]],
- ]
- for input_data in data:
- for codec in codecs:
- output_data = codec.decode(codec.encode(input_data))
- assert np.array_equal(np.array(input_data), output_data)
+ for codec in codecs:
+ output_data = codec.decode(codec.encode(input_data))
+ assert np.array_equal(np.array(input_data, dtype=dtype), output_data)
diff --git a/numcodecs/tests/test_msgpacks.py b/numcodecs/tests/test_msgpacks.py
index 6aeadcf..d76aa12 100644
--- a/numcodecs/tests/test_msgpacks.py
+++ b/numcodecs/tests/test_msgpacks.py
@@ -2,6 +2,7 @@ import unittest
import numpy as np
+import pytest
try:
@@ -52,30 +53,32 @@ def test_backwards_compatibility():
check_backwards_compatibility(codec.codec_id, arrays, [codec])
-def test_non_numpy_inputs():
+@pytest.mark.parametrize(
+ "input_data, dtype",
+ [
+ ([0, 1], None),
+ ([[0, 1], [2, 3]], None),
+ ([[0], [1], [2, 3]], object),
+ ([[[0, 0]], [[1, 1]], [[2, 3]]], None),
+ (["1"], None),
+ (["11", "11"], None),
+ (["11", "1", "1"], None),
+ ([{}], None),
+ ([{"key": "value"}, ["list", "of", "strings"]], object),
+ ([b"1"], None),
+ ([b"11", b"11"], None),
+ ([b"11", b"1", b"1"], None),
+ ([{b"key": b"value"}, [b"list", b"of", b"strings"]], object),
+ ]
+)
+def test_non_numpy_inputs(input_data, dtype):
codec = MsgPack()
# numpy will infer a range of different shapes and dtypes for these inputs.
# Make sure that round-tripping through encode preserves this.
- data = [
- [0, 1],
- [[0, 1], [2, 3]],
- [[0], [1], [2, 3]],
- [[[0, 0]], [[1, 1]], [[2, 3]]],
- ["1"],
- ["11", "11"],
- ["11", "1", "1"],
- [{}],
- [{"key": "value"}, ["list", "of", "strings"]],
- [b"1"],
- [b"11", b"11"],
- [b"11", b"1", b"1"],
- [{b"key": b"value"}, [b"list", b"of", b"strings"]],
- ]
- for input_data in data:
- actual = codec.decode(codec.encode(input_data))
- expect = np.array(input_data)
- assert expect.shape == actual.shape
- assert np.array_equal(expect, actual)
+ actual = codec.decode(codec.encode(input_data))
+ expect = np.array(input_data, dtype=dtype)
+ assert expect.shape == actual.shape
+ assert np.array_equal(expect, actual)
def test_encode_decode_shape_dtype_preserved():

131
python-numcodecs.changes Normal file
View File

@ -0,0 +1,131 @@
-------------------------------------------------------------------
Mon Aug 28 02:21:23 UTC 2023 - Steve Kowalik <steven.kowalik@suse.com>
- Add patch move-from-entrypoints.patch:
* Drop requirements on entrypoints, use importlib.metadata.
-------------------------------------------------------------------
Thu Jan 12 16:00:40 UTC 2023 - Ben Greiner <code@bnavigator.de>
- Update to 0.11.0
* Speed up isinstance checks of
numcodecs.ndarray_like.NDArrayLike,
numcodecs.ndarray_like.DType and
numcodecs.ndarray_like.FlagsObj. By Andreas Poehlmann, #379.
* Remove unnecessary None argument to .get(), it is the default
value. By Dimitri Papadopoulos Orfanos, #395.
* Apply refurb suggestions. By Dimitri Papadopoulos Orfanos,
#372.
* Migrate codespell configuration to pyproject.toml and get rid
of setup.cfg. By Dimitri Papadopoulos Orfanos #374.
* Unvendor cpuinfo. By Dimitri Papadopoulos Orfanos #373.
* Drop headers. By John Kirkham, #375.
* Remove Python 2 code. By Dimitri Papadopoulos Orfanos #368,
#387.
* Support Python 3.11. By Dimitri Papadopoulos Orfanos, #369.
* Drop Python 3.7. By John Kirkham,, #405 #406.
* Test with zfpy 1.0.0. By John Kirkham, #385.
* Remove vendored C files and re-generate them on the fly using
Cython. Add a pyproject.toml file to define Cython as a build
dependency. By Dimitri Papadopoulos Orfanos, #369.
* Add tests for all registry classes. By Josh Moore, #349.
* Finish pyproject.toml migration. By John Kirkham #382.
- Add numcodecs-pr417-raggednumpy.patch
* gh#zarr-developers/numcodecs#417
- Refresh unbundle-libs.patch for system blosc supporting snappy
* gh#zarr-developers/numcodecs#264
-------------------------------------------------------------------
Sun Sep 25 20:23:44 UTC 2022 - Arun Persaud <arun@gmx.de>
- specfile:
* update copyright year
* require python >= 3.7
- update to version 0.10.2:
* Fix
+ Add BitRound (0.10.0) to registry. By Josh Moore, #342.
- changes from version 0.10.1:
* Maintenance
+ Add entrypoints to setup.py. By Josh Moore, #332.
+ Fix spelling. By Dimitri Papadopoulos Orfanos, #336.
+ Drop Python 3.6 from tests By Dimitri Papadopoulos Orfanos,
#338, #339.
+ Remove trailing spaces and empty lines. By Dimitri Papadopoulos
Orfanos, #341.
+ Add LGTM.com configuration file By Dimitri Papadopoulos Orfanos,
#337.
- changes from version 0.10.0:
* Enhancements
+ Add support of alternative array classes (other than NumPy
arrays) By Mads R. B. Kristensen, #305.
+ Add ability to find codecs via entrypoint numcodecs.codecs. By
Martin Durant, #290.
+ Add bitround codec By Ryan Abernathy and Martin Durant, #298.
+ Introduce a flat option to ensure_contiguous_ndarray to switch
off flatten for ZFPY codec By Haiying Xu, #307.
* Bug fixes
+ Fix a flatten array error for ZFPY, ZFPY codec is supported on
Python 3.9 and 3.10 on Linux and MacOS, the docs about ZFPY is
also available. By Haiying Xu, John Kirkham, Ryan Abernathey
#303.
+ Codex: make encode and decode @abstractmethods By Mads
R. B. Kristensen, #306.
+ Fix expected result test for Shuffle. By Elliott Sales de
Andrade, #282.
* Maintenance
+ Multiple code linting fixes. By Dimitri Papadopoulos Orfanos,
#295, #294, #293, and #292.
+ Drop Python 3.6 By Josh Moore, #318.
+ Fix macOS Python 3.10 By John Kirkham, #311.
+ chore: bump cibuildwheel version, use action By Henry Schreiner,
#309.
+ Specify language as en instead of None. By John Kirkham, #329.
+ Move master to main. By John Kirkham, #322.
+ Drop fastparquet benchmark. By John Kirkham, #321.
+ Trim wheel builds. By John Kirkham, #320.
- changes from version 0.9.1:
* Fix inaccurate docstrings for Blosc. By James Webber, #287.
- changes from version 0.9.0:
* c-blosc upgrade 1.18.1 -> 1.21.0. Warning: this temporarily
removes support for snappy compression! By kindjacket, #283.
* Fix an ImportError with Blosc on Android. By Daniel Jewell, #284.
- changes from version 0.8.1:
* Fix an ImportError with Blosc on Android. By Daniel Jewell, #284.
- changes from version 0.8.0:
* The numcodecs.zfpy.ZFPY codec is now supported on Python 3.8 if
zfpy==0.5.5 is installed. By haiying xu, #229.
* Add support for byte Shuffle filter By Paul Branson and Martin
Durant #273.
* Update Windows + Mac CI to run all tests. By Jackson Maxfield
Brown, #276. Help from Oleg Höfling, #273.
* Update cpuinfo to 8.0.0. By Florian Jetter, #280.
* Drop out-of-date manual release docs. By John Kirkham, #272.
* Add support for Python 3.9 and Update GitHub Actions.
-------------------------------------------------------------------
Mon Apr 25 11:13:12 UTC 2022 - Bernhard Wiedemann <bwiedemann@suse.com>
- Disable AVX2 to make package build reproducible (boo#1198818)
-------------------------------------------------------------------
Sat Apr 17 14:41:47 UTC 2021 - Ben Greiner <code@bnavigator.de>
- Update to v0.7.3
* Add support for Python 3.9
- Disable python36 build (NumPy not available, NEP 29)
-------------------------------------------------------------------
Mon Dec 28 12:24:07 UTC 2020 - Benjamin Greiner <code@bnavigator.de>
- initial specfile for v0.7.2
- use and link against system provided blosc, zstd, lz4
* unbundle-libs.patch
* gh#zarr-developers/numcodecs#264
- required by zarr, which is required by dask

86
python-numcodecs.spec Normal file
View File

@ -0,0 +1,86 @@
#
# spec file for package python-numcodecs
#
# Copyright (c) 2023 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
Name: python-numcodecs
Version: 0.11.0
Release: 0
Summary: Buffer compression and transformation codecs
License: MIT
URL: https://github.com/zarr-developers/numcodecs
Source: https://files.pythonhosted.org/packages/source/n/numcodecs/numcodecs-%{version}.tar.gz
# PATCH-FEATURE-UPSTREAM unbundle-libs.patch -- unbundle system libs gh#zarr-developers/numcodecs#264
Patch0: unbundle-libs.patch
# PATCH-FIX-UPSTREAM numcodecs-pr417-raggednumpy.patch gh#zarr-developers/numcodecs#417
Patch1: numcodecs-pr417-raggednumpy.patch
# PATCH-FIX-UPSTREAM gh#zarr-developers/numcodecs#442
Patch2: move-from-entrypoints.patch
BuildRequires: %{python_module Cython}
BuildRequires: %{python_module base >= 3.8}
BuildRequires: %{python_module pip}
BuildRequires: %{python_module py-cpuinfo}
BuildRequires: %{python_module setuptools > 64}
BuildRequires: %{python_module setuptools_scm > 6.2}
BuildRequires: %{python_module wheel}
BuildRequires: blosc-devel
BuildRequires: cmake
BuildRequires: fdupes
BuildRequires: gcc-c++
BuildRequires: pkgconfig
BuildRequires: python-rpm-macros
BuildRequires: pkgconfig(liblz4)
BuildRequires: pkgconfig(libzstd)
BuildRequires: pkgconfig(zlib)
Requires: python-numpy >= 1.7
Suggests: python-msgpack
Suggests: python-zfpy >= 1
# SECTION test requirements
BuildRequires: %{python_module numpy >= 1.7}
BuildRequires: %{python_module msgpack}
BuildRequires: %{python_module pytest}
# /SECTION
%python_subpackages
%description
A Python package providing buffer compression and transformation codecs for use
in data storage and communication applications.
%prep
%autosetup -p1 -n numcodecs-%{version}
# use system libraries instead of bundled ones
rm -r c-blosc
sed -i 's/--cov=numcodecs --cov-report xml//' pyproject.toml
%build
export CFLAGS="%{optflags}"
export DISABLE_NUMCODECS_AVX2=1
%pyproject_wheel
%install
%pyproject_install
%python_expand %fdupes %{buildroot}%{$python_sitearch}
%check
%pytest_arch --pyargs numcodecs -rsfE
%files %{python_files}
%doc README.rst
%license LICENSE.txt
%{python_sitearch}/numcodecs
%{python_sitearch}/numcodecs-%{version}*-info
%changelog

48
unbundle-libs.patch Normal file
View File

@ -0,0 +1,48 @@
Index: numcodecs-0.11.0/setup.py
===================================================================
--- numcodecs-0.11.0.orig/setup.py
+++ numcodecs-0.11.0/setup.py
@@ -104,6 +104,7 @@ def blosc_extension():
Extension('numcodecs.blosc',
sources=sources + blosc_sources,
include_dirs=include_dirs,
+ libraries=[] if blosc_sources else ['blosc'],
define_macros=define_macros,
extra_compile_args=extra_compile_args,
),
@@ -138,6 +139,7 @@ def zstd_extension():
Extension('numcodecs.zstd',
sources=sources + zstd_sources,
include_dirs=include_dirs,
+ libraries=[] if zstd_sources else ['zstd'],
define_macros=define_macros,
extra_compile_args=extra_compile_args,
),
@@ -165,6 +167,7 @@ def lz4_extension():
Extension('numcodecs.lz4',
sources=sources + lz4_sources,
include_dirs=include_dirs,
+ libraries=[] if lz4_sources else ['lz4'],
define_macros=define_macros,
extra_compile_args=extra_compile_args,
),
Index: numcodecs-0.11.0/numcodecs/tests/test_blosc.py
===================================================================
--- numcodecs-0.11.0.orig/numcodecs/tests/test_blosc.py
+++ numcodecs-0.11.0/numcodecs/tests/test_blosc.py
@@ -155,10 +155,11 @@ def test_compress_complib(use_threads):
}
blosc.use_threads = use_threads
for cname in blosc.list_compressors():
- enc = blosc.compress(arr, cname.encode(), 1, Blosc.NOSHUFFLE)
- complib = blosc.cbuffer_complib(enc)
- expected_complib = expected_complibs[cname]
- assert complib == expected_complib
+ if cname in expected_complibs:
+ enc = blosc.compress(arr, cname.encode(), 1, Blosc.NOSHUFFLE)
+ complib = blosc.cbuffer_complib(enc)
+ expected_complib = expected_complibs[cname]
+ assert complib == expected_complib
with pytest.raises(ValueError):
# capitalized cname
blosc.compress(arr, b'LZ4', 1)