|
|
@ -39,12 +39,19 @@ def has_flag(compiler, flagname): |
|
|
|
the specified compiler. |
|
|
|
the specified compiler. |
|
|
|
""" |
|
|
|
""" |
|
|
|
import tempfile |
|
|
|
import tempfile |
|
|
|
|
|
|
|
import os |
|
|
|
with tempfile.NamedTemporaryFile('w', suffix='.cpp') as f: |
|
|
|
with tempfile.NamedTemporaryFile('w', suffix='.cpp') as f: |
|
|
|
f.write('int main (int argc, char **argv) { return 0; }') |
|
|
|
f.write('int main (int argc, char **argv) { return 0; }') |
|
|
|
|
|
|
|
fname = f.name |
|
|
|
try: |
|
|
|
try: |
|
|
|
compiler.compile([f.name], extra_postargs=[flagname]) |
|
|
|
compiler.compile([fname], extra_postargs=[flagname]) |
|
|
|
except setuptools.distutils.errors.CompileError: |
|
|
|
except setuptools.distutils.errors.CompileError: |
|
|
|
return False |
|
|
|
return False |
|
|
|
|
|
|
|
finally: |
|
|
|
|
|
|
|
try: |
|
|
|
|
|
|
|
os.remove(fname) |
|
|
|
|
|
|
|
except OSError: |
|
|
|
|
|
|
|
pass |
|
|
|
return True |
|
|
|
return True |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -56,7 +63,8 @@ def cpp_flag(compiler): |
|
|
|
flags = ['-std=c++17', '-std=c++14', '-std=c++11'] |
|
|
|
flags = ['-std=c++17', '-std=c++14', '-std=c++11'] |
|
|
|
|
|
|
|
|
|
|
|
for flag in flags: |
|
|
|
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 ' |
|
|
|
raise RuntimeError('Unsupported compiler -- at least C++11 support ' |
|
|
|
'is needed!') |
|
|
|
'is needed!') |
|
|
@ -93,6 +101,7 @@ class BuildExt(build_ext): |
|
|
|
ext.extra_link_args = link_opts |
|
|
|
ext.extra_link_args = link_opts |
|
|
|
build_ext.build_extensions(self) |
|
|
|
build_ext.build_extensions(self) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setup( |
|
|
|
setup( |
|
|
|
name='python_example', |
|
|
|
name='python_example', |
|
|
|
version=__version__, |
|
|
|
version=__version__, |
|
|
|