diff --git a/pyopenjtalk/htsengine.pyx b/pyopenjtalk/htsengine.pyx index b8ed5e6..cddd16b 100644 --- a/pyopenjtalk/htsengine.pyx +++ b/pyopenjtalk/htsengine.pyx @@ -1,6 +1,7 @@ # coding: utf-8 # cython: boundscheck=True, wraparound=True # cython: c_string_type=unicode, c_string_encoding=ascii +# cython: language_level=3 from contextlib import contextmanager from threading import RLock @@ -33,7 +34,7 @@ def _generate_lock_manager(): return f -cdef class HTSEngine(object): +cdef class HTSEngine: """HTSEngine Args: diff --git a/pyopenjtalk/htsengine/__init__.pxd b/pyopenjtalk/htsengine/__init__.pxd index d8f4fe4..e919505 100644 --- a/pyopenjtalk/htsengine/__init__.pxd +++ b/pyopenjtalk/htsengine/__init__.pxd @@ -1,4 +1,5 @@ # distutils: language = c++ +# cython: language_level=3 cdef extern from "HTS_engine.h": diff --git a/pyopenjtalk/openjtalk.pyx b/pyopenjtalk/openjtalk.pyx index 0113844..bd8234d 100644 --- a/pyopenjtalk/openjtalk.pyx +++ b/pyopenjtalk/openjtalk.pyx @@ -1,6 +1,7 @@ # coding: utf-8 # cython: boundscheck=True, wraparound=True # cython: c_string_type=unicode, c_string_encoding=ascii +# cython: language_level=3 from contextlib import contextmanager from threading import Lock @@ -157,7 +158,7 @@ def _generate_lock_manager(): return f -cdef class OpenJTalk(object): +cdef class OpenJTalk: """OpenJTalk Args: diff --git a/pyopenjtalk/openjtalk/__init__.pxd b/pyopenjtalk/openjtalk/__init__.pxd index e69de29..f08f4aa 100644 --- a/pyopenjtalk/openjtalk/__init__.pxd +++ b/pyopenjtalk/openjtalk/__init__.pxd @@ -0,0 +1 @@ +# cython: language_level=3 diff --git a/pyopenjtalk/openjtalk/jpcommon.pxd b/pyopenjtalk/openjtalk/jpcommon.pxd index c78dd0f..d2b121a 100644 --- a/pyopenjtalk/openjtalk/jpcommon.pxd +++ b/pyopenjtalk/openjtalk/jpcommon.pxd @@ -1,4 +1,5 @@ # distutils: language = c++ +# cython: language_level=3 from libc.stdio cimport FILE diff --git a/pyopenjtalk/openjtalk/mecab.pxd b/pyopenjtalk/openjtalk/mecab.pxd index 2c31912..746ac18 100644 --- a/pyopenjtalk/openjtalk/mecab.pxd +++ b/pyopenjtalk/openjtalk/mecab.pxd @@ -1,4 +1,5 @@ # distutils: language = c++ +# cython: language_level=3 cdef extern from "mecab.h": cdef cppclass Mecab: diff --git a/pyopenjtalk/openjtalk/mecab2njd.pxd b/pyopenjtalk/openjtalk/mecab2njd.pxd index fdfc1b0..33b6277 100644 --- a/pyopenjtalk/openjtalk/mecab2njd.pxd +++ b/pyopenjtalk/openjtalk/mecab2njd.pxd @@ -1,4 +1,5 @@ # distutils: language = c++ +# cython: language_level=3 from .njd cimport NJD diff --git a/pyopenjtalk/openjtalk/njd.pxd b/pyopenjtalk/openjtalk/njd.pxd index f745f8d..5f7a3ba 100644 --- a/pyopenjtalk/openjtalk/njd.pxd +++ b/pyopenjtalk/openjtalk/njd.pxd @@ -1,4 +1,5 @@ # distutils: language = c++ +# cython: language_level=3 from libc.stdio cimport FILE diff --git a/pyopenjtalk/openjtalk/njd2jpcommon.pxd b/pyopenjtalk/openjtalk/njd2jpcommon.pxd index a84c859..7069815 100644 --- a/pyopenjtalk/openjtalk/njd2jpcommon.pxd +++ b/pyopenjtalk/openjtalk/njd2jpcommon.pxd @@ -1,4 +1,5 @@ # distutils: language = c++ +# cython: language_level=3 from .jpcommon cimport JPCommon from .njd cimport NJD diff --git a/pyopenjtalk/openjtalk/text2mecab.pxd b/pyopenjtalk/openjtalk/text2mecab.pxd index 1d26049..83d79d8 100644 --- a/pyopenjtalk/openjtalk/text2mecab.pxd +++ b/pyopenjtalk/openjtalk/text2mecab.pxd @@ -1,4 +1,5 @@ # distutils: language = c++ +# cython: language_level=3 cdef extern from "text2mecab.h": void text2mecab(char *output, const char *input) nogil diff --git a/pyproject.toml b/pyproject.toml index d56bac5..995aae7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,7 +2,7 @@ requires = [ "setuptools>=64", "setuptools_scm>=8", - "cython>=0.28.0", + "cython>=0.29.16", "cmake", "numpy>=1.25.0; python_version>='3.9'", "oldest-supported-numpy; python_version<'3.9'", @@ -52,7 +52,7 @@ docs = [ "jupyter", ] dev = [ - "cython>=0.28.0", + "cython>=0.29.16", "pysen", "types-setuptools", "mypy<=0.910", diff --git a/setup.py b/setup.py index c67d3c4..b7b2658 100644 --- a/setup.py +++ b/setup.py @@ -23,6 +23,18 @@ def msvc_extra_compile_args(compile_args): return list(chain(compile_args, xs)) +msvc_define_macros_config = [ + ("_CRT_NONSTDC_NO_WARNINGS", None), + ("_CRT_SECURE_NO_WARNINGS", None), +] + + +def msvc_define_macros(macros): + mns = set([i[0] for i in macros]) + xs = filter(lambda x: x[0] not in mns, msvc_define_macros_config) + return list(chain(macros, xs)) + + class custom_build_ext(setuptools.command.build_ext.build_ext): def build_extensions(self): compiler_type_is_msvc = self.compiler.compiler_type == "msvc" @@ -33,6 +45,9 @@ def build_extensions(self): if hasattr(entry, "extra_compile_args") else [] ) + entry.define_macros = msvc_define_macros( + entry.define_macros if hasattr(entry, "define_macros") else [] + ) setuptools.command.build_ext.build_ext.build_extensions(self) @@ -148,6 +163,7 @@ def check_cmake_in_path(): language="c++", define_macros=[ ("AUDIO_PLAY_NONE", None), + ("NPY_NO_DEPRECATED_API", "NPY_1_7_API_VERSION"), ], ) ]