Skip to content

Commit

Permalink
devel/py-editdistance: Update to 0.6.2
Browse files Browse the repository at this point in the history
  • Loading branch information
sunpoet committed Jan 30, 2023
1 parent de0f736 commit 232f529
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 5 deletions.
8 changes: 6 additions & 2 deletions 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}
Expand All @@ -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} {} +
Expand Down
6 changes: 3 additions & 3 deletions 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
22 changes: 22 additions & 0 deletions 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

0 comments on commit 232f529

Please sign in to comment.