Skip to content

Commit 187e874

Browse files
committed
MinGW support (@isuruf, #36) + PEP8 fixes
1 parent b3ea870 commit 187e874

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

Diff for: setup.py

+11-2
Original file line numberDiff line numberDiff 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+
96105
setup(
97106
name='python_example',
98107
version=__version__,

0 commit comments

Comments
 (0)