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

Method template_sources

numpy/distutils/command/build_src.py:407–441  ·  view source on GitHub ↗
(self, sources, extension)

Source from the content-addressed store, hash-verified

405 return new_sources, files
406
407 def template_sources(self, sources, extension):
408 new_sources = []
409 if is_sequence(extension):
410 depends = extension[1].get('depends')
411 include_dirs = extension[1].get('include_dirs')
412 else:
413 depends = extension.depends
414 include_dirs = extension.include_dirs
415 for source in sources:
416 (base, ext) = os.path.splitext(source)
417 if ext == '.src': # Template file
418 if self.inplace:
419 target_dir = os.path.dirname(base)
420 else:
421 target_dir = appendpath(self.build_src, os.path.dirname(base))
422 self.mkpath(target_dir)
423 target_file = os.path.join(target_dir, os.path.basename(base))
424 if (self.force or newer_group([source] + depends, target_file)):
425 if _f_pyf_ext_match(base):
426 log.info("from_template:> %s" % (target_file))
427 outstr = process_f_file(source)
428 else:
429 log.info("conv_template:> %s" % (target_file))
430 outstr = process_c_file(source)
431 with open(target_file, 'w') as fid:
432 fid.write(outstr)
433 if _header_ext_match(target_file):
434 d = os.path.dirname(target_file)
435 if d not in include_dirs:
436 log.info(" adding '%s' to include_dirs." % (d))
437 include_dirs.append(d)
438 new_sources.append(target_file)
439 else:
440 new_sources.append(source)
441 return new_sources
442
443 def pyrex_sources(self, sources, extension):
444 """Pyrex not supported; this remains for Cython support (see below)"""

Callers 2

build_library_sourcesMethod · 0.95

Calls 7

is_sequenceFunction · 0.90
appendpathFunction · 0.90
openFunction · 0.85
infoMethod · 0.80
getMethod · 0.45
joinMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected