diff --git a/devel/py-editdistance/Makefile b/devel/py-editdistance/Makefile index 794bb8968b763..5d0596463c5e1 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 8558631fd34d3..f9dbbfed507de 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 0000000000000..d64a67a8e8934 --- /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 = malloc(len(a) * sizeof(int64_t)) + for i in range(len(a)): + al[i] = hash(a[i]) + cdef int64_t *bl = 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