@@ -28,10 +28,19 @@ class GppInterface(CompilerInterface):
2828 'MPI' : pathlib .Path ('mpic++' )
2929 }
3030
31+ compile_flags = tuple ()
32+
33+ # Config does not always contain these items (eg. on Windows)
34+
35+ if 'BASECFLAGS' in PYTHON_CONFIG :
36+ compile_flags = tuple (split_and_strip ('{} {}' .format (compile_flags ,PYTHON_CONFIG ['BASECFLAGS' ])))
37+
38+ if 'BASECPPFLAGS' in PYTHON_CONFIG :
39+ compile_flags = tuple (split_and_strip ('{} {}' .format (compile_flags ,PYTHON_CONFIG ['BASECPPFLAGS' ])))
40+
3141 _flags = {
3242 '' : ('-O3' , '-fPIC' , '-Wall' , '-Wextra' , '-Wpedantic' , '-fdiagnostics-color=always' ),
33- 'compile' : tuple (split_and_strip ('{} {}' .format (
34- PYTHON_CONFIG ['BASECFLAGS' ], PYTHON_CONFIG ['BASECPPFLAGS' ]))),
43+ 'compile' : compile_flags ,
3544 'link' : (),
3645 'OpenMP' : ('-fopenmp' ,)
3746 }
@@ -41,13 +50,20 @@ class GppInterface(CompilerInterface):
4150 pathlib .Path (PYTHON_CONFIG ['INCLUDEPY' ]),
4251 * [pathlib .Path (_ , 'core' , 'include' ) for _ in np .__path__ ]]
4352
44- library_paths = [
45- pathlib .Path (PYTHON_CONFIG ['LIBDIR' ])]
53+ library_paths = []
54+ if 'LIBDIR' in PYTHON_CONFIG :
55+ library_paths .append (pathlib .Path (PYTHON_CONFIG ['LIBDIR' ]))
4656
47- ldlibrary = pathlib .Path (PYTHON_CONFIG ['LDLIBRARY' ].lstrip ('lib' )).with_suffix ('' )
57+ if 'LDLIBRARY' in PYTHON_CONFIG :
58+ ldlibrary = pathlib .Path (PYTHON_CONFIG ['LDLIBRARY' ].lstrip ('lib' )).with_suffix ('' )
59+ else :
60+ ldlibrary = None
4861
49- libraries = split_and_strip ('-l{} {} {} {}' .format (
50- ldlibrary , PYTHON_CONFIG ['LIBS' ], PYTHON_CONFIG ['SYSLIBS' ], PYTHON_CONFIG ['LINKFORSHARED' ]))
62+ if 'LIBS' in PYTHON_CONFIG and 'SYSLIBS' in PYTHON_CONFIG and 'LINKFORSHARED' in PYTHON_CONFIG :
63+ libraries = split_and_strip ('-l{} {} {} {}' .format (
64+ ldlibrary , PYTHON_CONFIG ['LIBS' ], PYTHON_CONFIG ['SYSLIBS' ], PYTHON_CONFIG ['LINKFORSHARED' ]))
65+ else :
66+ libraries = []
5167
5268 _options = {
5369 'compile' : ['-I{}' .format (_ ) for _ in include_paths ],
@@ -63,10 +79,19 @@ class ClangppInterface(CompilerInterface):
6379
6480 _executables = {'' : pathlib .Path ('clang++' )}
6581
82+ compile_flags = tuple ()
83+
84+ # Config does not always contain these items (eg. on Windows)
85+
86+ if 'BASECFLAGS' in PYTHON_CONFIG :
87+ compile_flags = tuple (split_and_strip ('{} {}' .format (compile_flags , PYTHON_CONFIG ['BASECFLAGS' ])))
88+
89+ if 'BASECPPFLAGS' in PYTHON_CONFIG :
90+ compile_flags = tuple (split_and_strip ('{} {}' .format (compile_flags , PYTHON_CONFIG ['BASECPPFLAGS' ])))
91+
6692 _flags = {
6793 '' : ('-O3' , '-fPIC' , '-Wall' , '-Wextra' , '-Wpedantic' , '-fcolor-diagnostics' ),
68- 'compile' : tuple (split_and_strip ('{} {}' .format (
69- PYTHON_CONFIG ['BASECFLAGS' ], PYTHON_CONFIG ['BASECPPFLAGS' ]))),
94+ 'compile' : compile_flags ,
7095 'OpenMP' : ('-fopenmp' ,)
7196 }
7297 # -Ofast
@@ -75,13 +100,20 @@ class ClangppInterface(CompilerInterface):
75100 pathlib .Path (PYTHON_CONFIG ['INCLUDEPY' ]),
76101 * [pathlib .Path (_ , 'core' , 'include' ) for _ in np .__path__ ]]
77102
78- library_paths = [
79- pathlib .Path (PYTHON_CONFIG ['LIBDIR' ])]
103+ library_paths = []
104+ if 'LIBDIR' in PYTHON_CONFIG :
105+ library_paths .append (pathlib .Path (PYTHON_CONFIG ['LIBDIR' ]))
80106
81- ldlibrary = pathlib .Path (PYTHON_CONFIG ['LDLIBRARY' ].lstrip ('lib' )).with_suffix ('' )
107+ if 'LDLIBRARY' in PYTHON_CONFIG :
108+ ldlibrary = pathlib .Path (PYTHON_CONFIG ['LDLIBRARY' ].lstrip ('lib' )).with_suffix ('' )
109+ else :
110+ ldlibrary = None
82111
83- libraries = split_and_strip ('-l{} {} {} {}' .format (
84- ldlibrary , PYTHON_CONFIG ['LIBS' ], PYTHON_CONFIG ['SYSLIBS' ], PYTHON_CONFIG ['LINKFORSHARED' ]))
112+ if 'LIBS' in PYTHON_CONFIG and 'SYSLIBS' in PYTHON_CONFIG and 'LINKFORSHARED' in PYTHON_CONFIG :
113+ libraries = split_and_strip ('-l{} {} {} {}' .format (
114+ ldlibrary , PYTHON_CONFIG ['LIBS' ], PYTHON_CONFIG ['SYSLIBS' ], PYTHON_CONFIG ['LINKFORSHARED' ]))
115+ else :
116+ libraries = []
85117
86118 _options = {
87119 'compile' : ['-I{}' .format (_ ) for _ in include_paths ],
0 commit comments