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

Method get_targets

numpy/distutils/tests/test_ccompiler_opt.py:100–142  ·  view source on GitHub ↗
(self, targets, groups, **kwargs)

Source from the content-addressed store, hash-verified

98 return self.opt().cc_name
99
100 def get_targets(self, targets, groups, **kwargs):
101 FakeCCompilerOpt.conf_target_groups = groups
102 opt = self.nopt(
103 cpu_baseline=kwargs.get("baseline", "min"),
104 cpu_dispatch=kwargs.get("dispatch", "max"),
105 trap_files=kwargs.get("trap_files", ""),
106 trap_flags=kwargs.get("trap_flags", "")
107 )
108 with tempdir() as tmpdir:
109 file = os.path.join(tmpdir, "test_targets.c")
110 with open(file, 'w') as f:
111 f.write(targets)
112 gtargets = []
113 gflags = {}
114 fake_objects = opt.try_dispatch([file])
115 for source, flags in fake_objects:
116 gtar = path.basename(source).split('.')[1:-1]
117 glen = len(gtar)
118 if glen == 0:
119 gtar = "baseline"
120 elif glen == 1:
121 gtar = gtar[0].upper()
122 else:
123 # converting multi-target into parentheses str format to be equivalent
124 # to the configuration statements syntax.
125 gtar = ('('+' '.join(gtar)+')').upper()
126 gtargets.append(gtar)
127 gflags[gtar] = flags
128
129 has_baseline, targets = opt.sources_status[file]
130 targets = targets + ["baseline"] if has_baseline else targets
131 # convert tuple that represent multi-target into parentheses str format
132 targets = [
133 '('+' '.join(tar)+')' if isinstance(tar, tuple) else tar
134 for tar in targets
135 ]
136 if len(targets) != len(gtargets) or not all(t in gtargets for t in targets):
137 raise AssertionError(
138 "'sources_status' returns different targets than the compiled targets\n"
139 "%s != %s" % (targets, gtargets)
140 )
141 # return targets from 'sources_status' since the order is matters
142 return targets, gflags
143
144 def arg_regex(self, **kwargs):
145 map2origin = dict(

Callers 2

expect_targetsMethod · 0.95
expect_target_flagsMethod · 0.95

Calls 10

noptMethod · 0.95
tempdirFunction · 0.90
openFunction · 0.85
try_dispatchMethod · 0.80
upperMethod · 0.80
allFunction · 0.50
getMethod · 0.45
joinMethod · 0.45
writeMethod · 0.45
splitMethod · 0.45

Tested by

no test coverage detected