Skip to content

Commit

Permalink
MinGW support (@isuruf, #36) + PEP8 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
wjakob committed Apr 26, 2020
1 parent b3ea870 commit 187e874
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,19 @@ def has_flag(compiler, flagname):
the specified compiler.
"""
import tempfile
import os
with tempfile.NamedTemporaryFile('w', suffix='.cpp') as f:

This comment has been minimized.

Copy link
@isuruf

isuruf Apr 26, 2020

Contributor

Need a delete=False here

f.write('int main (int argc, char **argv) { return 0; }')
fname = f.name
try:
compiler.compile([f.name], extra_postargs=[flagname])
compiler.compile([fname], extra_postargs=[flagname])
except setuptools.distutils.errors.CompileError:
return False
finally:
try:
os.remove(fname)
except OSError:
pass
return True


Expand All @@ -56,7 +63,8 @@ def cpp_flag(compiler):
flags = ['-std=c++17', '-std=c++14', '-std=c++11']

for flag in flags:
if has_flag(compiler, flag): return flag
if has_flag(compiler, flag):
return flag

raise RuntimeError('Unsupported compiler -- at least C++11 support '
'is needed!')
Expand Down Expand Up @@ -93,6 +101,7 @@ def build_extensions(self):
ext.extra_link_args = link_opts
build_ext.build_extensions(self)


setup(
name='python_example',
version=__version__,
Expand Down

0 comments on commit 187e874

Please sign in to comment.