|
25 | 25 | sys.exit('Sorry, Python < 2.7 is not supported') |
26 | 26 |
|
27 | 27 | import os |
| 28 | +import platform |
28 | 29 |
|
29 | 30 | from setuptools import setup |
30 | 31 | from setuptools.extension import Extension |
|
39 | 40 | # Definitions |
40 | 41 | ######################################################### |
41 | 42 |
|
42 | | -extra_compile_args_math_optimized = ['-fopenmp', '-march=native', '-O2', '-msse', '-msse2', '-mfma', '-mfpmath=sse'] |
43 | | -extra_compile_args_math_debug = ['-fopenmp', '-march=native', '-O0', '-g'] |
| 43 | +system = platform.system() |
44 | 44 |
|
45 | | -extra_compile_args_nonmath_optimized = ['-O2'] |
46 | | -extra_compile_args_nonmath_debug = ['-O0', '-g'] |
| 45 | +if system == "Windows": |
| 46 | + my_extra_compile_args_math = ["/openmp"] |
| 47 | + my_extra_compile_args_nonmath = [] |
| 48 | + my_extra_link_args = [] |
| 49 | + debug = False |
| 50 | +else: |
| 51 | + extra_compile_args_math_optimized = ['-fopenmp', '-march=native', '-O2', '-msse', '-msse2', '-mfma', '-mfpmath=sse'] |
| 52 | + extra_compile_args_math_debug = ['-fopenmp', '-march=native', '-O0', '-g'] |
47 | 53 |
|
48 | | -extra_link_args_optimized = ['-fopenmp'] |
49 | | -extra_link_args_debug = ['-fopenmp'] |
| 54 | + extra_compile_args_nonmath_optimized = ['-O2'] |
| 55 | + extra_compile_args_nonmath_debug = ['-O0', '-g'] |
50 | 56 |
|
| 57 | + extra_link_args_optimized = ['-fopenmp'] |
| 58 | + extra_link_args_debug = ['-fopenmp'] |
51 | 59 |
|
52 | | -if build_type == 'optimized': |
53 | | - my_extra_compile_args_math = extra_compile_args_math_optimized |
54 | | - my_extra_compile_args_nonmath = extra_compile_args_nonmath_optimized |
55 | | - my_extra_link_args = extra_link_args_optimized |
56 | | - debug = False |
57 | | - print( "build configuration selected: optimized" ) |
58 | | -else: # build_type == 'debug': |
59 | | - my_extra_compile_args_math = extra_compile_args_math_debug |
60 | | - my_extra_compile_args_nonmath = extra_compile_args_nonmath_debug |
61 | | - my_extra_link_args = extra_link_args_debug |
62 | | - debug = True |
63 | | - print( "build configuration selected: debug" ) |
| 60 | + |
| 61 | + if build_type == 'optimized': |
| 62 | + my_extra_compile_args_math = extra_compile_args_math_optimized |
| 63 | + my_extra_compile_args_nonmath = extra_compile_args_nonmath_optimized |
| 64 | + my_extra_link_args = extra_link_args_optimized |
| 65 | + debug = False |
| 66 | + print( "build configuration selected: optimized" ) |
| 67 | + else: # build_type == 'debug': |
| 68 | + my_extra_compile_args_math = extra_compile_args_math_debug |
| 69 | + my_extra_compile_args_nonmath = extra_compile_args_nonmath_debug |
| 70 | + my_extra_link_args = extra_link_args_debug |
| 71 | + debug = True |
| 72 | + print( "build configuration selected: debug" ) |
64 | 73 |
|
65 | 74 |
|
66 | 75 | ######################################################### |
@@ -95,12 +104,16 @@ def ext(extName): |
95 | 104 | extra_compile_args=my_extra_compile_args_nonmath |
96 | 105 | ) |
97 | 106 | def ext_math(extName): |
| 107 | + if system == "Windows": |
| 108 | + libraries = [] |
| 109 | + else: |
| 110 | + libraries = ["m"] # "m" links libm, the math library on unix-likes; see http://docs.cython.org/src/tutorial/external.html |
98 | 111 | extPath = extName.replace(".", os.path.sep)+".pyx" |
99 | 112 | return Extension( extName, |
100 | 113 | [extPath], |
101 | 114 | extra_compile_args=my_extra_compile_args_math, |
102 | 115 | extra_link_args=my_extra_link_args, |
103 | | - libraries=["m"] # "m" links libm, the math library on unix-likes; see http://docs.cython.org/src/tutorial/external.html |
| 116 | + libraries=libraries |
104 | 117 | ) |
105 | 118 |
|
106 | 119 | # http://stackoverflow.com/questions/13628979/setuptools-how-to-make-package-contain-extra-data-folder-and-all-folders-inside |
|
0 commit comments