File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Expand file tree Collapse file tree 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):
3939 the specified compiler.
4040 """
4141 import tempfile
42+ import os
4243 with tempfile .NamedTemporaryFile ('w' , suffix = '.cpp' ) as f :
4344 f .write ('int main (int argc, char **argv) { return 0; }' )
45+ fname = f .name
4446 try :
45- compiler .compile ([f . name ], extra_postargs = [flagname ])
47+ compiler .compile ([fname ], extra_postargs = [flagname ])
4648 except setuptools .distutils .errors .CompileError :
4749 return False
50+ finally :
51+ try :
52+ os .remove (fname )
53+ except OSError :
54+ pass
4855 return True
4956
5057
@@ -56,7 +63,8 @@ def cpp_flag(compiler):
5663 flags = ['-std=c++17' , '-std=c++14' , '-std=c++11' ]
5764
5865 for flag in flags :
59- if has_flag (compiler , flag ): return flag
66+ if has_flag (compiler , flag ):
67+ return flag
6068
6169 raise RuntimeError ('Unsupported compiler -- at least C++11 support '
6270 'is needed!' )
@@ -93,6 +101,7 @@ def build_extensions(self):
93101 ext .extra_link_args = link_opts
94102 build_ext .build_extensions (self )
95103
104+
96105setup (
97106 name = 'python_example' ,
98107 version = __version__ ,
You can’t perform that action at this time.
0 commit comments