diff --git a/pyopenjtalk/htsengine.pyx b/pyopenjtalk/htsengine.pyx index 9936a6e..1bc2b6a 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 import numpy as np @@ -19,7 +20,7 @@ from .htsengine cimport ( HTS_Engine_get_generated_speech, HTS_Engine_get_nsamples ) -cdef class HTSEngine(object): +cdef class HTSEngine: """HTSEngine Args: diff --git a/pyopenjtalk/htsengine/__init__.pxd b/pyopenjtalk/htsengine/__init__.pxd index c24d959..6da5bb3 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": @@ -19,4 +20,4 @@ cdef extern from "HTS_engine.h": size_t HTS_Engine_get_nsamples(HTS_Engine * engine) void HTS_Engine_set_speed(HTS_Engine * engine, double f) - void HTS_Engine_add_half_tone(HTS_Engine * engine, double f) \ No newline at end of file + void HTS_Engine_add_half_tone(HTS_Engine * engine, double f) diff --git a/pyopenjtalk/openjtalk.pyx b/pyopenjtalk/openjtalk.pyx index 291311e..ad2b521 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 import numpy as np @@ -151,7 +152,7 @@ cdef inline int Mecab_load_with_userdic(Mecab *m, char* dicdir, char* userdic): return 1 -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 8e86bea..555885a 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 1538e05..80ff86e 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 be57ccc..a7880c2 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 38d3887..4ffab6a 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 8309288..3bdec33 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 6081757..01f7efe 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) diff --git a/pyproject.toml b/pyproject.toml index fe0e1fe..0599f7a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,7 +2,7 @@ requires = [ "setuptools>=64", "setuptools_scm>=8", - "cython>=0.28.0", + "cython>=3", "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>=3", "pysen", "types-setuptools", "mypy<=0.910", diff --git a/setup.py b/setup.py index dfac91e..14e91d2 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"), ], ) ]