Skip to content

Commit

Permalink
Merge pull request #91 from sabonerune/fix/fix-or-suppress-warning
Browse files Browse the repository at this point in the history
FIX: Fix or suppress the warning.
  • Loading branch information
r9y9 authored Dec 26, 2024
2 parents 42cf16f + 723bdde commit eaed6bb
Show file tree
Hide file tree
Showing 12 changed files with 30 additions and 4 deletions.
3 changes: 2 additions & 1 deletion pyopenjtalk/htsengine.pyx
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -33,7 +34,7 @@ def _generate_lock_manager():
return f


cdef class HTSEngine(object):
cdef class HTSEngine:
"""HTSEngine
Args:
Expand Down
1 change: 1 addition & 0 deletions pyopenjtalk/htsengine/__init__.pxd
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# distutils: language = c++
# cython: language_level=3


cdef extern from "HTS_engine.h":
Expand Down
3 changes: 2 additions & 1 deletion pyopenjtalk/openjtalk.pyx
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -157,7 +158,7 @@ def _generate_lock_manager():
return f


cdef class OpenJTalk(object):
cdef class OpenJTalk:
"""OpenJTalk
Args:
Expand Down
1 change: 1 addition & 0 deletions pyopenjtalk/openjtalk/__init__.pxd
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# cython: language_level=3
1 change: 1 addition & 0 deletions pyopenjtalk/openjtalk/jpcommon.pxd
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# distutils: language = c++
# cython: language_level=3

from libc.stdio cimport FILE

Expand Down
1 change: 1 addition & 0 deletions pyopenjtalk/openjtalk/mecab.pxd
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# distutils: language = c++
# cython: language_level=3

cdef extern from "mecab.h":
cdef cppclass Mecab:
Expand Down
1 change: 1 addition & 0 deletions pyopenjtalk/openjtalk/mecab2njd.pxd
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# distutils: language = c++
# cython: language_level=3

from .njd cimport NJD

Expand Down
1 change: 1 addition & 0 deletions pyopenjtalk/openjtalk/njd.pxd
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# distutils: language = c++
# cython: language_level=3

from libc.stdio cimport FILE

Expand Down
1 change: 1 addition & 0 deletions pyopenjtalk/openjtalk/njd2jpcommon.pxd
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# distutils: language = c++
# cython: language_level=3

from .jpcommon cimport JPCommon
from .njd cimport NJD
Expand Down
1 change: 1 addition & 0 deletions pyopenjtalk/openjtalk/text2mecab.pxd
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# distutils: language = c++
# cython: language_level=3

cdef extern from "text2mecab.h":
void text2mecab(char *output, const char *input) nogil
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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'",
Expand Down Expand Up @@ -52,7 +52,7 @@ docs = [
"jupyter",
]
dev = [
"cython>=0.28.0",
"cython>=0.29.16",
"pysen",
"types-setuptools",
"mypy<=0.910",
Expand Down
16 changes: 16 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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)

Expand Down Expand Up @@ -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"),
],
)
]
Expand Down

0 comments on commit eaed6bb

Please sign in to comment.