in setup.py [0:0]
def build_extensions(self):
if sys.platform == 'darwin':
mac_osx_version = float('.'.join(platform.mac_ver()[0].split('.')[:2]))
os.environ['MACOSX_DEPLOYMENT_TARGET'] = str(mac_osx_version)
all_flags = ['-stdlib=libc++', '-mmacosx-version-min=10.7']
if has_flag(self.compiler, [all_flags[0]]):
self.c_opts['unix'] += [all_flags[0]]
elif has_flag(self.compiler, all_flags):
self.c_opts['unix'] += all_flags
else:
raise RuntimeError(
'libc++ is needed! Failed to compile with {} and {}.'.
format(" ".join(all_flags), all_flags[0])
)
ct = self.compiler.compiler_type
opts = self.c_opts.get(ct, [])
extra_link_args = []
if coverage:
coverage_option = '--coverage'
opts.append(coverage_option)
extra_link_args.append(coverage_option)
if ct == 'unix':
opts.append('-DVERSION_INFO="%s"' % self.distribution.get_version())
opts.append(cpp_flag(self.compiler))
if has_flag(self.compiler, ['-fvisibility=hidden']):
opts.append('-fvisibility=hidden')
elif ct == 'msvc':
opts.append(
'/DVERSION_INFO=\\"%s\\"' % self.distribution.get_version()
)
for ext in self.extensions:
ext.extra_compile_args = opts
ext.extra_link_args = extra_link_args
build_ext.build_extensions(self)