File tree Expand file tree Collapse file tree 1 file changed +7
-6
lines changed
Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Original file line number Diff line number Diff line change 1717 ),
1818]
1919
20+ # As of Python 3.6, CCompiler has a `has_flag` method.
21+ # cf http://bugs.python.org/issue26689
2022def has_flag (compiler , flagname ):
2123 """Return a boolean indicating whether a flag name is supported on
2224 the specified compiler.
2325 """
2426 import tempfile
25- fd , fname = tempfile .mkstemp ('.cpp' , 'main' , text = True )
26- with os .fdopen (fd , 'w' ) as f :
27+ with tempfile .NamedTemporaryFile ('w' , suffix = '.cpp' ) as f :
2728 f .write ('int main (int argc, char **argv) { return 0; }' )
28- try :
29- compiler .compile ([fname ], extra_postargs = [flagname ])
30- except setuptools .distutils .errors .CompileError :
31- return False
29+ try :
30+ compiler .compile ([f . name ], extra_postargs = [flagname ])
31+ except setuptools .distutils .errors .CompileError :
32+ return False
3233 return True
3334
3435def cpp_flag (compiler ):
You can’t perform that action at this time.
0 commit comments