From afa96207bf605316bd17c56a6962ed378fa5ff00 Mon Sep 17 00:00:00 2001 From: Stephen L Arnold Date: Mon, 16 Nov 2020 12:03:45 -0800 Subject: [PATCH] update python versions, remove dependency on (stale) bundled src library * respin debian patch * add endian fix from upstream PR Origin1: https://salsa.debian.org/python-team/packages/python-datrie/-/tree/master/debian/patches Origin2: upstream, https://github.com/pytries/datrie/pull/85 Signed-off-by: Stephen L Arnold --- MANIFEST.in | 4 +--- libdatrie | 2 +- setup.py | 21 ++++++++++----------- src/cdatrie.pxd | 6 +++--- src/datrie.pyx | 6 ++++-- tox-bench.ini | 3 ++- tox.ini | 3 ++- 7 files changed, 23 insertions(+), 22 deletions(-) diff --git a/MANIFEST.in b/MANIFEST.in index 6d6c78b..9bf6ec1 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -4,12 +4,10 @@ include COPYING include tox.ini include tox-bench.ini include update_c.sh -recursive-include libdatrie *.h -recursive-include libdatrie *.c include tests/words100k.txt.zip recursive-include tests *.py include src/datrie.pyx include src/cdatrie.pxd include src/stdio_ext.pxd -exclude src/datrie.c \ No newline at end of file +exclude src/datrie.c diff --git a/libdatrie b/libdatrie index d1dfdb8..d1db08a 160000 --- a/libdatrie +++ b/libdatrie @@ -1 +1 @@ -Subproject commit d1dfdb831093892541cae46eba82c46aec94f726 +Subproject commit d1db08ac1c76f54ba23d63665437473788c999f3 diff --git a/setup.py b/setup.py index ac1c943..228c4ff 100755 --- a/setup.py +++ b/setup.py @@ -7,9 +7,7 @@ from setuptools import setup, Extension from Cython.Build import cythonize - -LIBDATRIE_DIR = 'libdatrie' -LIBDATRIE_FILES = sorted(glob.glob(os.path.join(LIBDATRIE_DIR, "datrie", "*.c"))) +from Cython.Build.Dependencies import default_create_extension DESCRIPTION = __doc__ LONG_DESCRIPTION = open('README.rst').read() + open('CHANGES.rst').read() @@ -30,22 +28,26 @@ 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: Implementation :: CPython', 'Topic :: Software Development :: Libraries :: Python Modules', 'Topic :: Scientific/Engineering :: Information Analysis', 'Topic :: Text Processing :: Linguistic' ] +def do_create_extension(template, kwds): + libs = kwds.get('libraries', []) + ["datrie"] + kwds['libraries'] = libs + return default_create_extension(template, kwds) + ext_modules = cythonize( 'src/datrie.pyx', 'src/cdatrie.pxd', 'src/stdio_ext.pxd', annotate=True, include_path=[os.path.join(os.path.dirname(os.path.abspath(__file__)), "src")], - language_level=2 + language_level=2, + create_extension=do_create_extension ) -for m in ext_modules: - m.include_dirs=[LIBDATRIE_DIR] - setup(name="datrie", version="0.8.2", description=DESCRIPTION, @@ -55,10 +57,7 @@ license=LICENSE, url='https://github.com/kmike/datrie', classifiers=CLASSIFIERS, - libraries=[('datrie', { - "sources": LIBDATRIE_FILES, - "include_dirs": [LIBDATRIE_DIR]})], ext_modules=ext_modules, - python_requires=">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*", + python_requires=">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*", setup_requires=["pytest-runner", 'Cython>=0.28'], tests_require=["pytest", "hypothesis"]) diff --git a/src/cdatrie.pxd b/src/cdatrie.pxd index b80ce99..e2cb777 100644 --- a/src/cdatrie.pxd +++ b/src/cdatrie.pxd @@ -1,13 +1,13 @@ # cython: profile=False from libc cimport stdio -cdef extern from "../libdatrie/datrie/triedefs.h": +cdef extern from "/usr/include/datrie/triedefs.h": ctypedef int AlphaChar # it should be utf32 letter ctypedef unsigned char TrieChar # 1 byte ctypedef int TrieIndex ctypedef int TrieData # int -cdef extern from "../libdatrie/datrie/alpha-map.h": +cdef extern from "/usr/include/datrie/alpha-map.h": struct AlphaMap: pass @@ -20,7 +20,7 @@ cdef extern from "../libdatrie/datrie/alpha-map.h": int alpha_char_strlen (AlphaChar *str) -cdef extern from "../libdatrie/datrie/trie.h": +cdef extern from "/usr/include/datrie/trie.h": ctypedef struct Trie: pass diff --git a/src/datrie.pyx b/src/datrie.pyx index 0f91a41..39dd255 100644 --- a/src/datrie.pyx +++ b/src/datrie.pyx @@ -1120,8 +1120,10 @@ cdef unicode unicode_from_alpha_char(cdatrie.AlphaChar* key, int len=0): if length == 0: length = cdatrie.alpha_char_strlen(key)*sizeof(cdatrie.AlphaChar) cdef char* c_str = key - return c_str[:length].decode('utf_32_le') - + if sys.byteorder == 'little': + return c_str[:length].decode('utf_32_le') + else: + return c_str[:length].decode('utf_32_be') def to_ranges(lst): """ diff --git a/tox-bench.ini b/tox-bench.ini index 426881f..cb9f935 100644 --- a/tox-bench.ini +++ b/tox-bench.ini @@ -1,5 +1,6 @@ [tox] -envlist = py27,py34,py35,py36,py37 +envlist = py27, py3{5,6,7,8,9} +skip_missing_interpreters = true [testenv] commands= diff --git a/tox.ini b/tox.ini index 0f5f5f0..38213c5 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,6 @@ [tox] -envlist = py27,py34,py35,py36,py37,py38 +envlist = py27, py3{5,6,7,8,9} +skip_missing_interpreters = true [testenv] deps =