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

Method _wrap_target

numpy/distutils/ccompiler_opt.py:2548–2584  ·  view source on GitHub ↗
(self, output_dir, dispatch_src, target, nochange=False)

Source from the content-addressed store, hash-verified

2546 return '\n'.join(text)
2547
2548 def _wrap_target(self, output_dir, dispatch_src, target, nochange=False):
2549 assert(isinstance(target, (str, tuple)))
2550 if isinstance(target, str):
2551 ext_name = target_name = target
2552 else:
2553 # multi-target
2554 ext_name = '.'.join(target)
2555 target_name = '__'.join(target)
2556
2557 wrap_path = os.path.join(output_dir, os.path.basename(dispatch_src))
2558 wrap_path = "{0}.{2}{1}".format(*os.path.splitext(wrap_path), ext_name.lower())
2559 if nochange and os.path.exists(wrap_path):
2560 return wrap_path
2561
2562 self.dist_log("wrap dispatch-able target -> ", wrap_path)
2563 # sorting for readability
2564 features = self.feature_sorted(self.feature_implies_c(target))
2565 target_join = "#define %sCPU_TARGET_" % self.conf_c_prefix_
2566 target_defs = [target_join + f for f in features]
2567 target_defs = '\n'.join(target_defs)
2568
2569 with open(wrap_path, "w") as fd:
2570 fd.write(textwrap.dedent("""\
2571 /**
2572 * AUTOGENERATED DON'T EDIT
2573 * Please make changes to the code generator \
2574 (distutils/ccompiler_opt.py)
2575 */
2576 #define {pfx}CPU_TARGET_MODE
2577 #define {pfx}CPU_TARGET_CURRENT {target_name}
2578 {target_defs}
2579 #include "{path}"
2580 """).format(
2581 pfx=self.conf_c_prefix_, target_name=target_name,
2582 path=os.path.abspath(dispatch_src), target_defs=target_defs
2583 ))
2584 return wrap_path
2585
2586 def _generate_config(self, output_dir, dispatch_src, targets, has_baseline=False):
2587 config_path = os.path.basename(dispatch_src)

Callers 1

try_dispatchMethod · 0.95

Calls 9

openFunction · 0.85
lowerMethod · 0.80
feature_sortedMethod · 0.80
feature_implies_cMethod · 0.80
joinMethod · 0.45
existsMethod · 0.45
dist_logMethod · 0.45
writeMethod · 0.45
abspathMethod · 0.45

Tested by

no test coverage detected