Browse Source

MinGW support (@isuruf, #36) + PEP8 fixes

master
Wenzel Jakob 5 years ago
parent
commit
187e874971
  1. 13
      setup.py

13
setup.py

@ -39,12 +39,19 @@ def has_flag(compiler, flagname): @@ -39,12 +39,19 @@ def has_flag(compiler, flagname):
the specified compiler.
"""
import tempfile
import os
with tempfile.NamedTemporaryFile('w', suffix='.cpp') as f:
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
@ -56,7 +63,8 @@ def cpp_flag(compiler): @@ -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!')
@ -93,6 +101,7 @@ class BuildExt(build_ext): @@ -93,6 +101,7 @@ class BuildExt(build_ext):
ext.extra_link_args = link_opts
build_ext.build_extensions(self)
setup(
name='python_example',
version=__version__,

Loading…
Cancel
Save