From 187e8749719c5d80673818ff424a3b2ad0ae120c Mon Sep 17 00:00:00 2001 From: Wenzel Jakob Date: Sun, 26 Apr 2020 18:00:46 +0200 Subject: [PATCH] MinGW support (@isuruf, #36) + PEP8 fixes --- setup.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 181e8cf..db6a24e 100644 --- a/setup.py +++ b/setup.py @@ -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): 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 @@ def build_extensions(self): ext.extra_link_args = link_opts build_ext.build_extensions(self) + setup( name='python_example', version=__version__,