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

Method __init__

numpy/distutils/ccompiler_opt.py:962–1078  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

960 Dictionary containing the initialized flags of `_Config.conf_cc_flags`
961 """
962 def __init__(self):
963 if hasattr(self, "cc_is_cached"):
964 return
965 # attr regex compiler-expression
966 detect_arch = (
967 ("cc_on_x64", ".*(x|x86_|amd)64.*", ""),
968 ("cc_on_x86", ".*(win32|x86|i386|i686).*", ""),
969 ("cc_on_ppc64le", ".*(powerpc|ppc)64(el|le).*|.*powerpc.*",
970 "defined(__powerpc64__) && "
971 "defined(__LITTLE_ENDIAN__)"),
972 ("cc_on_ppc64", ".*(powerpc|ppc).*|.*powerpc.*",
973 "defined(__powerpc64__) && "
974 "defined(__BIG_ENDIAN__)"),
975 ("cc_on_aarch64", ".*(aarch64|arm64).*", ""),
976 ("cc_on_armhf", ".*arm.*", "defined(__ARM_ARCH_7__) || "
977 "defined(__ARM_ARCH_7A__)"),
978 ("cc_on_s390x", ".*s390x.*", ""),
979 # undefined platform
980 ("cc_on_noarch", "", ""),
981 )
982 detect_compiler = (
983 ("cc_is_gcc", r".*(gcc|gnu\-g).*", ""),
984 ("cc_is_clang", ".*clang.*", ""),
985 # intel msvc like
986 ("cc_is_iccw", ".*(intelw|intelemw|iccw).*", ""),
987 ("cc_is_icc", ".*(intel|icc).*", ""), # intel unix like
988 ("cc_is_msvc", ".*msvc.*", ""),
989 ("cc_is_fcc", ".*fcc.*", ""),
990 # undefined compiler will be treat it as gcc
991 ("cc_is_nocc", "", ""),
992 )
993 detect_args = (
994 ("cc_has_debug", ".*(O0|Od|ggdb|coverage|debug:full).*", ""),
995 ("cc_has_native",
996 ".*(-march=native|-xHost|/QxHost|-mcpu=a64fx).*", ""),
997 # in case if the class run with -DNPY_DISABLE_OPTIMIZATION
998 ("cc_noopt", ".*DISABLE_OPT.*", ""),
999 )
1000
1001 dist_info = self.dist_info()
1002 platform, compiler_info, extra_args = dist_info
1003 # set False to all attrs
1004 for section in (detect_arch, detect_compiler, detect_args):
1005 for attr, rgex, cexpr in section:
1006 setattr(self, attr, False)
1007
1008 for detect, searchin in ((detect_arch, platform), (detect_compiler, compiler_info)):
1009 for attr, rgex, cexpr in detect:
1010 if rgex and not re.match(rgex, searchin, re.IGNORECASE):
1011 continue
1012 if cexpr and not self.cc_test_cexpr(cexpr):
1013 continue
1014 setattr(self, attr, True)
1015 break
1016
1017 for attr, rgex, cexpr in detect_args:
1018 if rgex and not re.match(rgex, extra_args, re.IGNORECASE):
1019 continue

Callers

nothing calls this directly

Calls 7

cc_test_cexprMethod · 0.95
cc_test_flagsMethod · 0.95
dist_fatalMethod · 0.80
dist_infoMethod · 0.45
dist_logMethod · 0.45
getMethod · 0.45
splitMethod · 0.45

Tested by

no test coverage detected