From 18c05748fc9abbf47dde04687c54d928206fe1f2 Mon Sep 17 00:00:00 2001 From: KmolYuan Date: Sun, 6 Oct 2019 17:49:53 +0800 Subject: [PATCH] Support MSVC compiler. --- cython/setup.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/cython/setup.py b/cython/setup.py index 1de21adb..e771a948 100644 --- a/cython/setup.py +++ b/cython/setup.py @@ -108,6 +108,17 @@ def copy_source(dry_run): class Build(build_ext): + def build_extensions(self): + if self.compiler.compiler_type in {'mingw32'}: + for e in self.extensions: + e.define_macros = macros + e.extra_compile_args = compile_args + elif self.compiler.compiler_type == 'msvc': + for e in self.extensions: + e.define_macros = [('_USE_MATH_DEFINES', None)] + macros[2:] + e.libraries = ['shell32'] + super(Build, self).build_extensions() + def run(self): has_src = isdir(include_path) and isdir(src_path) if not has_src: @@ -142,9 +153,7 @@ setup( "python_solvespace.slvs", sources, language="c++", - include_dirs=[include_path, src_path, platform_path, extra_path], - define_macros=macros, - extra_compile_args=compile_args + include_dirs=[include_path, src_path, platform_path, extra_path] )], cmdclass={'build_ext': Build, 'sdist': PackSource}, zip_safe=False,