summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormattip <matti.picus@gmail.com>2020-07-28 11:56:35 +0300
committermattip <matti.picus@gmail.com>2020-07-28 11:56:35 +0300
commit10dcfb0da453b103192a3adeca3197ac161f29a0 (patch)
tree65ecd36f841e789344b48951a5675a23a84632a6
parent57fb47cc267eef54005f97d8e55b31df24590093 (diff)
downloadnumpy-10dcfb0da453b103192a3adeca3197ac161f29a0.tar.gz
MAINT: refactoring from review
-rwxr-xr-xsetup.py33
1 files changed, 17 insertions, 16 deletions
diff --git a/setup.py b/setup.py
index 5dedf7a7b..a9296f1b9 100755
--- a/setup.py
+++ b/setup.py
@@ -235,24 +235,25 @@ def get_build_overrides():
from numpy.distutils.command.build_ext import build_ext
from distutils.version import LooseVersion
- def _is_using_old_gcc(obj):
- is_old_gcc = False
- if obj.compiler.compiler_type == 'unix':
- cc = obj.compiler.compiler[0]
- if "gcc" in cc:
- out = subprocess.run([cc, '-dumpversion'],
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE,
- universal_newlines=True,
- )
- # will print something like '4.2.1\n'
- if LooseVersion(out.stdout) < LooseVersion('5.0'):
- is_old_gcc = True
- return is_old_gcc
+ def _needs_gcc_c99_flag(obj):
+ if obj.compiler.compiler_type != 'unix':
+ return False
+
+ cc = obj.compiler.compiler[0]
+ if "gcc" not in cc:
+ return False
+
+ # will print something like '4.2.1\n'
+ out = subprocess.run([cc, '-dumpversion'], stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE, universal_newlines=True)
+ # -std=c99 is default from this version on
+ if LooseVersion(out.stdout) >= LooseVersion('5.0'):
+ return False
+ return True
class new_build_clib(build_clib):
def build_a_library(self, build_info, lib_name, libraries):
- if _is_using_old_gcc(self):
+ if _needs_gcc_c99_flag(self):
args = build_info.get('extra_compiler_args') or []
args.append('-std=c99')
build_info['extra_compiler_args'] = args
@@ -260,7 +261,7 @@ def get_build_overrides():
class new_build_ext(build_ext):
def build_extension(self, ext):
- if _is_using_old_gcc(self):
+ if _needs_gcc_c99_flag(self):
if '-std=c99' not in ext.extra_compile_args:
ext.extra_compile_args.append('-std=c99')
build_ext.build_extension(self, ext)