git: f65555c64c16 - main - databases/py-caterva: Fix build with newer caterva

From: Po-Chuan Hsieh <sunpoet_at_FreeBSD.org>
Date: Wed, 31 Aug 2022 11:42:59 UTC
The branch main has been updated by sunpoet:

URL: https://cgit.FreeBSD.org/ports/commit/?id=f65555c64c16c7ef471c24df3a8f4c4ae892741b

commit f65555c64c16c7ef471c24df3a8f4c4ae892741b
Author:     Po-Chuan Hsieh <sunpoet@FreeBSD.org>
AuthorDate: 2022-08-31 11:22:02 +0000
Commit:     Po-Chuan Hsieh <sunpoet@FreeBSD.org>
CommitDate: 2022-08-31 11:40:55 +0000

    databases/py-caterva: Fix build with newer caterva
    
    - Bump PORTREVISION for package change
---
 databases/py-caterva/Makefile                      |  3 +-
 .../py-caterva/files/patch-caterva-caterva_ext.pyx | 73 ++++++++++++++++++++++
 .../py-caterva/files/patch-caterva-constructors.py | 13 ++++
 .../files/patch-tests-test_metalayers.py           | 29 +++++++++
 .../files/patch-tests-test_persistency.py          | 28 +++++++++
 5 files changed, 145 insertions(+), 1 deletion(-)

diff --git a/databases/py-caterva/Makefile b/databases/py-caterva/Makefile
index 02124a3c3582..ba422bc2372c 100644
--- a/databases/py-caterva/Makefile
+++ b/databases/py-caterva/Makefile
@@ -1,5 +1,6 @@
 PORTNAME=	caterva
 PORTVERSION=	0.7.2
+PORTREVISION=	1
 CATEGORIES=	databases python
 MASTER_SITES=	CHEESESHOP
 PKGNAMEPREFIX=	${PYTHON_PKGNAMEPREFIX}
@@ -10,7 +11,7 @@ COMMENT=	Caterva for Python (multidimensional compressed data containers)
 LICENSE=	BSD3CLAUSE
 LICENSE_FILE=	${WRKSRC}/LICENSE
 
-BUILD_DEPENDS=	caterva>=0.5.0_1:databases/caterva \
+BUILD_DEPENDS=	caterva>=0.5.0_2:databases/caterva \
 		cmake:devel/cmake \
 		ninja:devel/ninja \
 		${PYTHON_PKGNAMEPREFIX}scikit-build>=0:devel/py-scikit-build@${PY_FLAVOR}
diff --git a/databases/py-caterva/files/patch-caterva-caterva_ext.pyx b/databases/py-caterva/files/patch-caterva-caterva_ext.pyx
new file mode 100644
index 000000000000..75e6f5a76894
--- /dev/null
+++ b/databases/py-caterva/files/patch-caterva-caterva_ext.pyx
@@ -0,0 +1,73 @@
+Reference:  https://github.com/Blosc/caterva/commit/d34818b6fde503b13edee9654852559932bf0390
+
+--- caterva/caterva_ext.pyx.orig	2022-01-28 12:38:26 UTC
++++ caterva/caterva_ext.pyx
+@@ -48,7 +48,7 @@ cdef extern from "blosc2.h":
+         BLOSC2_MAX_FILTERS
+         BLOSC2_MAX_METALAYERS
+         BLOSC2_MAX_VLMETALAYERS
+-        BLOSC_MAX_OVERHEAD
++        BLOSC2_MAX_OVERHEAD
+         BLOSC_ALWAYS_SPLIT = 1,
+         BLOSC_NEVER_SPLIT = 2,
+         BLOSC_AUTO_SPLIT = 3,
+@@ -130,7 +130,7 @@ cdef extern from "caterva.h":
+     ctypedef struct caterva_storage_t:
+         int32_t chunkshape[CATERVA_MAX_DIM]
+         int32_t blockshape[CATERVA_MAX_DIM]
+-        bool sequencial
++        bool contiguous
+         char* urlpath
+         caterva_metalayer_t metalayers[CATERVA_MAX_METALAYERS]
+         int32_t nmetalayers
+@@ -195,8 +195,8 @@ cdef extern from "caterva.h":
+                                  int64_t *start, int64_t *stop, caterva_array_t *array);
+     int caterva_copy(caterva_ctx_t *ctx, caterva_array_t *src, caterva_storage_t *storage,
+                      caterva_array_t ** array);
+-    int caterva_resize(caterva_array_t *array,
+-                             int64_t *new_shape);
++    int caterva_resize(caterva_ctx_t *ctx, caterva_array_t *array, int64_t *new_shape,
++                       const int64_t *start);
+ 
+ # Defaults for compression params
+ config_dflts = {
+@@ -269,7 +269,7 @@ cdef create_caterva_storage(caterva_storage_t *storage
+     chunks = kwargs.get('chunks', None)
+     blocks = kwargs.get('blocks', None)
+     urlpath = kwargs.get('urlpath', None)
+-    sequential = kwargs.get('sequential', False)
++    contiguous = kwargs.get('contiguous', False)
+     meta = kwargs.get('meta', None)
+ 
+     if not chunks:
+@@ -282,7 +282,7 @@ cdef create_caterva_storage(caterva_storage_t *storage
+         storage.urlpath = urlpath
+     else:
+         storage.urlpath = NULL
+-    storage.sequencial = sequential
++    storage.contiguous = contiguous
+     for i in range(len(chunks)):
+         storage.chunkshape[i] = chunks[i]
+         storage.blockshape[i] = blocks[i]
+@@ -321,7 +321,7 @@ cdef class NDArray:
+     @property
+     def cratio(self):
+         """The compression ratio for this container."""
+-        return self.size / (self.array.sc.cbytes + BLOSC_MAX_OVERHEAD * self.nchunks)
++        return self.size / (self.array.sc.cbytes + BLOSC2_MAX_OVERHEAD * self.nchunks)
+ 
+     @property
+     def clevel(self):
+@@ -517,10 +517,11 @@ def copy(NDArray arr, NDArray src, **kwargs):
+     return arr
+ 
+ def resize(NDArray arr, new_shape):
++    ctx = Context(**arr.kwargs)
+     cdef int64_t new_shape_[CATERVA_MAX_DIM]
+     for i, s in enumerate(new_shape):
+         new_shape_[i] = s
+-    caterva_resize(arr.array, new_shape_)
++    caterva_resize(ctx.context_, arr.array, new_shape_, NULL)
+     return arr
+ 
+ def from_file(NDArray arr, urlpath, **kwargs):
diff --git a/databases/py-caterva/files/patch-caterva-constructors.py b/databases/py-caterva/files/patch-caterva-constructors.py
new file mode 100644
index 000000000000..9ee3fd4b9887
--- /dev/null
+++ b/databases/py-caterva/files/patch-caterva-constructors.py
@@ -0,0 +1,13 @@
+--- caterva/constructors.py.orig	2022-01-28 12:38:26 UTC
++++ caterva/constructors.py
+@@ -34,8 +34,8 @@ def empty(shape, itemsize, **kwargs):
+             urlpath: str or None
+                 The name of the file to store data.  If `None`, data is stored in-memory.
+                 (Default `None`)
+-            sequential: bool or None
+-                Whether the data is stored sequentially or sparsely (one chunk per file).
++            contiguous: bool or None
++                Whether the data is stored contiguously or sparsely (one chunk per file).
+                 If `None`, data is stored sparsely.
+             memframe: bool
+                 If True, the array is backed by a frame in-memory.  Else, by a super-chunk.
diff --git a/databases/py-caterva/files/patch-tests-test_metalayers.py b/databases/py-caterva/files/patch-tests-test_metalayers.py
new file mode 100644
index 000000000000..226a0ed9954a
--- /dev/null
+++ b/databases/py-caterva/files/patch-tests-test_metalayers.py
@@ -0,0 +1,29 @@
+--- tests/test_metalayers.py.orig	2022-01-28 12:38:26 UTC
++++ tests/test_metalayers.py
+@@ -13,7 +13,7 @@ import os
+ from msgpack import packb
+ 
+ 
+-@pytest.mark.parametrize("sequencial",
++@pytest.mark.parametrize("contiguous",
+                          [
+                              True,
+                              False,
+@@ -24,7 +24,7 @@ from msgpack import packb
+                              ([20, 134, 13], [12, 66, 8], [3, 13, 5], "testmeta01.cat", np.int32),
+                              ([12, 13, 14, 15, 16], [8, 9, 4, 12, 9], [2, 6, 4, 5, 4], "testmeta02.cat", np.float32)
+                          ])
+-def test_metalayers(shape, chunks, blocks, urlpath, sequencial, dtype):
++def test_metalayers(shape, chunks, blocks, urlpath, contiguous, dtype):
+     if os.path.exists(urlpath):
+         cat.remove(urlpath)
+ 
+@@ -34,7 +34,7 @@ def test_metalayers(shape, chunks, blocks, urlpath, se
+     # Create an empty caterva array (on disk)
+     itemsize = np.dtype(dtype).itemsize
+     a = cat.empty(shape, itemsize, chunks=chunks, blocks=blocks,
+-                  urlpath=urlpath, sequencial=sequencial,
++                  urlpath=urlpath, contiguous=contiguous,
+                   meta={"numpy": numpy_meta,
+                         "test": test_meta})
+ 
diff --git a/databases/py-caterva/files/patch-tests-test_persistency.py b/databases/py-caterva/files/patch-tests-test_persistency.py
new file mode 100644
index 000000000000..647c43024c79
--- /dev/null
+++ b/databases/py-caterva/files/patch-tests-test_persistency.py
@@ -0,0 +1,28 @@
+--- tests/test_persistency.py.orig	2022-01-28 12:38:26 UTC
++++ tests/test_persistency.py
+@@ -12,7 +12,7 @@ import numpy as np
+ import os
+ 
+ 
+-@pytest.mark.parametrize("sequencial",
++@pytest.mark.parametrize("contiguous",
+                          [
+                              True,
+                              False,
+@@ -23,14 +23,14 @@ import os
+                              ([20, 134, 13], [7, 22, 5], [3, 5, 3], "test01.cat", np.int32),
+                              ([12, 13, 14, 15, 16], [4, 6, 4, 7, 5], [2, 4, 2, 3, 3], "test02.cat", np.float32)
+                          ])
+-def test_persistency(shape, chunks, blocks, urlpath, sequencial, dtype):
++def test_persistency(shape, chunks, blocks, urlpath, contiguous, dtype):
+     if os.path.exists(urlpath):
+         cat.remove(urlpath)
+ 
+     size = int(np.prod(shape))
+     nparray = np.arange(size, dtype=dtype).reshape(shape)
+     _ = cat.asarray(nparray, chunks=chunks, blocks=blocks,
+-                    urlpath=urlpath, sequencial=sequencial)
++                    urlpath=urlpath, contiguous=contiguous)
+     b = cat.open(urlpath)
+ 
+     bc = b[:]