git: 232f529c360a - main - devel/py-editdistance: Update to 0.6.2

From: Po-Chuan Hsieh <sunpoet_at_FreeBSD.org>
Date: Mon, 30 Jan 2023 13:08:34 UTC
The branch main has been updated by sunpoet:

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

commit 232f529c360aba352646cab542aee883610b6509
Author:     Po-Chuan Hsieh <sunpoet@FreeBSD.org>
AuthorDate: 2023-01-30 12:31:08 +0000
Commit:     Po-Chuan Hsieh <sunpoet@FreeBSD.org>
CommitDate: 2023-01-30 12:59:42 +0000

    devel/py-editdistance: Update to 0.6.2
    
    Changes:        https://github.com/roy-ht/editdistance/releases
---
 devel/py-editdistance/Makefile           |  8 ++++++--
 devel/py-editdistance/distinfo           |  6 +++---
 devel/py-editdistance/files/bycython.pyx | 22 ++++++++++++++++++++++
 3 files changed, 31 insertions(+), 5 deletions(-)

diff --git a/devel/py-editdistance/Makefile b/devel/py-editdistance/Makefile
index 794bb8968b76..5d0596463c5e 100644
--- a/devel/py-editdistance/Makefile
+++ b/devel/py-editdistance/Makefile
@@ -1,5 +1,5 @@
 PORTNAME=	editdistance
-PORTVERSION=	0.6.1
+PORTVERSION=	0.6.2
 CATEGORIES=	devel python
 MASTER_SITES=	PYPI
 PKGNAMEPREFIX=	${PYTHON_PKGNAMEPREFIX}
@@ -12,7 +12,11 @@ LICENSE=	MIT
 LICENSE_FILE=	${WRKSRC}/LICENSE
 
 USES=		python:3.6+
-USE_PYTHON=	autoplist concurrent distutils
+USE_PYTHON=	autoplist concurrent cython distutils
+
+post-patch:
+# https://github.com/roy-ht/editdistance/blob/master/editdistance/bycython.pyx
+	@${CP} ${FILESDIR}/bycython.pyx ${WRKSRC}/editdistance/bycython.pyx
 
 post-install:
 	${FIND} ${STAGEDIR}${PYTHON_SITELIBDIR} -name '*.so' -exec ${STRIP_CMD} {} +
diff --git a/devel/py-editdistance/distinfo b/devel/py-editdistance/distinfo
index 8558631fd34d..f9dbbfed507d 100644
--- a/devel/py-editdistance/distinfo
+++ b/devel/py-editdistance/distinfo
@@ -1,3 +1,3 @@
-TIMESTAMP = 1669057721
-SHA256 (editdistance-0.6.1.tar.gz) = 124a3ebe1934ed86c0bdb5deafcc67494604a7cc63bdbb587665b76c85648262
-SIZE (editdistance-0.6.1.tar.gz) = 29267
+TIMESTAMP = 1674589766
+SHA256 (editdistance-0.6.2.tar.gz) = 97a722f5e859ed4c26da269e71a11995f23ac9c880618b8a2028373eb74283be
+SIZE (editdistance-0.6.2.tar.gz) = 31508
diff --git a/devel/py-editdistance/files/bycython.pyx b/devel/py-editdistance/files/bycython.pyx
new file mode 100644
index 000000000000..d64a67a8e893
--- /dev/null
+++ b/devel/py-editdistance/files/bycython.pyx
@@ -0,0 +1,22 @@
+# distutils: language = c++
+# distutils: sources = editdistance/_editdistance.cpp
+
+from libc.stdlib cimport malloc, free
+# from libc.stdint cimport int64_t
+
+cdef extern from "./_editdistance.h":
+    ctypedef int int64_t
+    unsigned int edit_distance(const int64_t *a, const unsigned int asize, const int64_t *b, const unsigned int bsize)
+
+cpdef unsigned int eval(object a, object b) except 0xffffffffffffffff:
+    cdef unsigned int i, dist
+    cdef int64_t *al = <int64_t *>malloc(len(a) * sizeof(int64_t))
+    for i in range(len(a)):
+        al[i] = hash(a[i])
+    cdef int64_t *bl = <int64_t *>malloc(len(b) * sizeof(int64_t))
+    for i in range(len(b)):
+        bl[i] = hash(b[i])
+    dist = edit_distance(al, len(a), bl, len(b))
+    free(al)
+    free(bl)
+    return dist