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 17
17
),
18
18
]
19
19
20
+ # As of Python 3.6, CCompiler has a `has_flag` method.
21
+ # cf http://bugs.python.org/issue26689
20
22
def has_flag (compiler , flagname ):
21
23
"""Return a boolean indicating whether a flag name is supported on
22
24
the specified compiler.
23
25
"""
24
26
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 :
27
28
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
32
33
return True
33
34
34
35
def cpp_flag (compiler ):
You can’t perform that action at this time.
0 commit comments