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

Method _compile

numpy/distutils/fcompiler/__init__.py:576–625  ·  view source on GitHub ↗

Compile 'src' to product 'obj'.

(self, obj, src, ext, cc_args, extra_postargs, pp_opts)

Source from the content-addressed store, hash-verified

574 ###################
575
576 def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts):
577 """Compile 'src' to product 'obj'."""
578 src_flags = {}
579 if Path(src).suffix.lower() in FORTRAN_COMMON_FIXED_EXTENSIONS \
580 and not has_f90_header(src):
581 flavor = ':f77'
582 compiler = self.compiler_f77
583 src_flags = get_f77flags(src)
584 extra_compile_args = self.extra_f77_compile_args or []
585 elif is_free_format(src):
586 flavor = ':f90'
587 compiler = self.compiler_f90
588 if compiler is None:
589 raise DistutilsExecError('f90 not supported by %s needed for %s'\
590 % (self.__class__.__name__, src))
591 extra_compile_args = self.extra_f90_compile_args or []
592 else:
593 flavor = ':fix'
594 compiler = self.compiler_fix
595 if compiler is None:
596 raise DistutilsExecError('f90 (fixed) not supported by %s needed for %s'\
597 % (self.__class__.__name__, src))
598 extra_compile_args = self.extra_f90_compile_args or []
599 if self.object_switch[-1]==' ':
600 o_args = [self.object_switch.strip(), obj]
601 else:
602 o_args = [self.object_switch.strip()+obj]
603
604 assert self.compile_switch.strip()
605 s_args = [self.compile_switch, src]
606
607 if extra_compile_args:
608 log.info('extra %s options: %r' \
609 % (flavor[1:], ' '.join(extra_compile_args)))
610
611 extra_flags = src_flags.get(self.compiler_type, [])
612 if extra_flags:
613 log.info('using compile options from source: %r' \
614 % ' '.join(extra_flags))
615
616 command = compiler + cc_args + extra_flags + s_args + o_args \
617 + extra_postargs + extra_compile_args
618
619 display = '%s: %s' % (os.path.basename(compiler[0]) + flavor,
620 src)
621 try:
622 self.spawn(command, display=display)
623 except DistutilsExecError as e:
624 msg = str(e)
625 raise CompileError(msg) from None
626
627 def module_options(self, module_dirs, module_build_dir):
628 options = []

Callers

nothing calls this directly

Calls 8

has_f90_headerFunction · 0.85
get_f77flagsFunction · 0.85
lowerMethod · 0.80
stripMethod · 0.80
infoMethod · 0.80
is_free_formatFunction · 0.70
joinMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected