@@ -25,22 +25,6 @@ def is_msvc():
2525 return os .name == "nt" and "mingw" not in "" .join (sys .argv )
2626
2727
28- def get_compiler_flags ():
29- """Get compiler flags for C++ dependencies compilation"""
30- if is_msvc ():
31- cflags = ["/EHsc" ]
32- else :
33- cflags = ["-Wall" ]
34- for arg , compile_arg in (("--sse2" , "-msse2" ), ("--sse3" , "-msse3" )):
35- if arg in sys .argv :
36- sys .argv .pop (sys .argv .index (arg ))
37- cflags .insert (0 , compile_arg )
38- return cflags
39-
40-
41- CFLAGS_CPP = get_compiler_flags ()
42-
43-
4428def compile_cython_extensions ():
4529 """Compile Cython extensions"""
4630 for fname in os .listdir (SRCPATH ):
@@ -52,17 +36,18 @@ def compile_cython_extensions():
5236
5337INCLUDE_DIRS = [SRCPATH , numpy .get_include ()]
5438
39+ MACROS_CYTHON = [("NPY_NO_DEPRECATED_API" , "NPY_1_7_API_VERSION" )]
40+ CFLAGS_CYTHON = []
5541# -------------------------------------------------------------------------------------
56- # TODO: When dropping support for Cython < 3.0, we can remove the following line
57- # and uncomment the next one.
42+ # TODO: When dropping support for Cython < 3.0, we can remove the following lines.
5843# In the meantime, we hide the deprecation warnings when building the package.
59- DEFINE_MACROS_CYTHON = []
60- CFLAGS_CYTHON = ["-Wno-cpp" ]
61- # DEFINE_MACROS_CYTHON = [("NPY_NO_DEPRECATED_API", "NPY_1_7_API_VERSION")]
62- # CFLAGS_CYTHON = []
44+ if not is_msvc ():
45+ MACROS_CYTHON = []
46+ CFLAGS_CYTHON = ["-Wno-cpp" ]
6347# -------------------------------------------------------------------------------------
6448
65- DEFINE_MACROS_CPP = [("NPY_NO_DEPRECATED_API" , "NPY_1_7_API_VERSION" )]
49+ MACROS_CPP = [("NPY_NO_DEPRECATED_API" , "NPY_1_7_API_VERSION" )]
50+ CFLAGS_CPP = ["/EHsc" ] if is_msvc () else ["-Wall" ]
6651
6752setup (
6853 ext_modules = [
@@ -71,21 +56,21 @@ def compile_cython_extensions():
7156 sources = [osp .join (SRCPATH , "mandelbrot.c" )],
7257 include_dirs = INCLUDE_DIRS ,
7358 extra_compile_args = CFLAGS_CYTHON ,
74- define_macros = DEFINE_MACROS_CYTHON ,
59+ define_macros = MACROS_CYTHON ,
7560 ),
7661 Extension (
7762 name = f"{ LIBNAME } .histogram2d" ,
7863 sources = [osp .join (SRCPATH , "histogram2d.c" )],
7964 include_dirs = INCLUDE_DIRS ,
8065 extra_compile_args = CFLAGS_CYTHON ,
81- define_macros = DEFINE_MACROS_CYTHON ,
66+ define_macros = MACROS_CYTHON ,
8267 ),
8368 Extension (
8469 name = f"{ LIBNAME } .contour2d" ,
8570 sources = [osp .join (SRCPATH , "contour2d.c" )],
8671 include_dirs = INCLUDE_DIRS ,
8772 extra_compile_args = CFLAGS_CYTHON ,
88- define_macros = DEFINE_MACROS_CYTHON ,
73+ define_macros = MACROS_CYTHON ,
8974 ),
9075 Extension (
9176 name = f"{ LIBNAME } ._scaler" ,
@@ -99,7 +84,7 @@ def compile_cython_extensions():
9984 osp .join (SRCPATH , "debug.hpp" ),
10085 ],
10186 include_dirs = INCLUDE_DIRS ,
102- define_macros = DEFINE_MACROS_CPP ,
87+ define_macros = MACROS_CPP ,
10388 ),
10489 ]
10590)
0 commit comments