-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FIX: Fix or suppress the warning. #91
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 | ||
|
||
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: | ||
Comment on lines
-36
to
+37
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This can be made unnecessary by setting https://cython.readthedocs.io/en/3.0.x/src/changes.html#id33
(It doesn't change anything since Python 3 isn't supported in the first place.) |
||
"""HTSEngine | ||
|
||
Args: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# cython: language_level=3 |
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 | ||
|
||
|
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: | ||
|
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 | ||
|
||
|
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 | ||
|
||
|
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 | ||
|
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) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
requires = [ | ||
"setuptools>=64", | ||
"setuptools_scm>=8", | ||
"cython>=0.28.0", | ||
"cython>=3", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bump to Cython>=3. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It sounds reasonable to me for now, but we may consider reverting this change if some people complain about dependencies. I am generally reluctant to tighten dependencies unless it's strongly necessary. By the way, what's the change that indeed requires cython >= 3? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. /~https://github.com/r9y9/pyopenjtalk/pull/91/files#r1893870541 https://cython.readthedocs.io/en/3.0.x/src/userguide/migrating_to_cy30.html#numpy-c-api
Building with Cython<3 installed will fail. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. diff --git a/pyproject.toml b/pyproject.toml
index 0599f7a..0e27bb7 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -2,7 +2,7 @@
requires = [
"setuptools>=64",
"setuptools_scm>=8",
- "cython>=3",
+ "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>=3",
+ "cython<3",
"pysen",
"types-setuptools",
"mypy<=0.910", With this PR and above, it works OK in my environment
As far as I understand, using cython <3 should be fine. Cython < 3 and newer numpy won't work though. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have also confirmed that it works with Cython<3. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. By the way, I noticed that Python 3.8 requires at least Cython 0.29.12. The minimum version for which a wheel is provided is 0.29.14. The minimum version for which There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixing requirements to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Set to |
||
"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", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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)) | ||
Comment on lines
+26
to
+35
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. MSVC will warn for POSIX names. https://learn.microsoft.com/cpp/error-messages/compiler-warnings/compiler-warning-level-3-c4996?view=msvc-170#posix-function-names Suppresses the warning because it is impractical to write POSIX-compatible code without using these functions. |
||
|
||
|
||
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"), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. From Cython 3.0 onwards, defining It is also required for the |
||
], | ||
) | ||
] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cython 3 now warns about code that has no
language-level
.