From 89962b76fcc4a188c775aac7a88f283d6cac58e8 Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Tue, 18 Sep 2018 16:27:54 -0500 Subject: [PATCH 1/2] Add C++11 flag for mingw32 too --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 46666608..c3e5971b 100644 --- a/setup.py +++ b/setup.py @@ -95,7 +95,7 @@ class BuildExt(build_ext): def build_extensions(self): ct = self.compiler.compiler_type opts = self.c_opts.get(ct, []) - if ct == 'unix': + if ct in ['unix', 'mingw32']: opts.append('-DVERSION_INFO="%s"' % self.distribution.get_version()) opts.append(cpp_flag(self.compiler)) if has_flag(self.compiler, '-fvisibility=hidden'): -- GitLab From b8ed6735d4a0f4d700d073b9c0134db3b1d5fef8 Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Tue, 18 Sep 2018 16:28:13 -0500 Subject: [PATCH 2/2] Fix for temp file on windows On windows the temp file cannot be opened a second time while it is still opened by python. Close the file in python before asking the compiler to read it. See https://docs.python.org/3.7/library/tempfile.html#tempfile.NamedTemporaryFile --- setup.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/setup.py b/setup.py index c3e5971b..930bf51d 100644 --- a/setup.py +++ b/setup.py @@ -59,12 +59,13 @@ def has_flag(compiler, flagname): the specified compiler. """ import tempfile - with tempfile.NamedTemporaryFile('w', suffix='.cpp') as f: + with tempfile.NamedTemporaryFile('w', suffix='.cpp', delete=False) as f: f.write('int main (int argc, char **argv) { return 0; }') - try: - compiler.compile([f.name], extra_postargs=[flagname]) - except setuptools.distutils.errors.CompileError: - return False + fname = f.name + try: + compiler.compile([fname], extra_postargs=[flagname]) + except setuptools.distutils.errors.CompileError: + return False return True -- GitLab