MCPcopy Create free account
hub / github.com/numpy/numpy / flags_is_required

Function flags_is_required

setup.py:206–240  ·  view source on GitHub ↗
(compiler, is_cpp, flags, code)

Source from the content-addressed store, hash-verified

204 compiler.verbose = bk_ver
205
206 def flags_is_required(compiler, is_cpp, flags, code):
207 if is_cpp:
208 compiler = compiler.cxx_compiler()
209 suf = '.cpp'
210 else:
211 suf = '.c'
212 with tempfile.TemporaryDirectory() as temp_dir:
213 tmp_file = os.path.join(temp_dir, "test" + suf)
214 with open(tmp_file, "w+") as f:
215 f.write(code)
216 # without specify any flags in case of the required
217 # standard already supported by default, then there's
218 # no need for passing the flags
219 comp = try_compile(compiler, tmp_file)
220 if not comp[0]:
221 comp = try_compile(compiler, tmp_file, flags)
222 if not comp[0]:
223 # rerun to verbose the error
224 try_compile(compiler, tmp_file, flags, True)
225 if is_cpp:
226 raise RuntimeError(
227 "Broken toolchain during testing C++ compiler. \n"
228 "A compiler with support for C++17 language "
229 "features is required.\n"
230 f"Triggered the following error: {comp[1]}."
231 )
232 else:
233 raise RuntimeError(
234 "Broken toolchain during testing C compiler. \n"
235 "A compiler with support for C99 language "
236 "features is required.\n"
237 f"Triggered the following error: {comp[1]}."
238 )
239 return True
240 return False
241
242 def std_cxx_flags(cmd):
243 compiler = cmd.compiler

Callers 2

std_cxx_flagsFunction · 0.85
std_c_flagsFunction · 0.85

Calls 4

openFunction · 0.85
try_compileFunction · 0.85
joinMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected