File tree 1 file changed +11
-2
lines changed
1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -39,12 +39,19 @@ def has_flag(compiler, flagname):
39
39
the specified compiler.
40
40
"""
41
41
import tempfile
42
+ import os
42
43
with tempfile .NamedTemporaryFile ('w' , suffix = '.cpp' ) as f :
43
44
f .write ('int main (int argc, char **argv) { return 0; }' )
45
+ fname = f .name
44
46
try :
45
- compiler .compile ([f . name ], extra_postargs = [flagname ])
47
+ compiler .compile ([fname ], extra_postargs = [flagname ])
46
48
except setuptools .distutils .errors .CompileError :
47
49
return False
50
+ finally :
51
+ try :
52
+ os .remove (fname )
53
+ except OSError :
54
+ pass
48
55
return True
49
56
50
57
@@ -56,7 +63,8 @@ def cpp_flag(compiler):
56
63
flags = ['-std=c++17' , '-std=c++14' , '-std=c++11' ]
57
64
58
65
for flag in flags :
59
- if has_flag (compiler , flag ): return flag
66
+ if has_flag (compiler , flag ):
67
+ return flag
60
68
61
69
raise RuntimeError ('Unsupported compiler -- at least C++11 support '
62
70
'is needed!' )
@@ -93,6 +101,7 @@ def build_extensions(self):
93
101
ext .extra_link_args = link_opts
94
102
build_ext .build_extensions (self )
95
103
104
+
96
105
setup (
97
106
name = 'python_example' ,
98
107
version = __version__ ,
You can’t perform that action at this time.
0 commit comments