MCPcopy Index your code
hub / github.com/python/cpython / new_compiler

Function new_compiler

Tools/c-analyzer/distutils/ccompiler.py:382–425  ·  view source on GitHub ↗

Generate an instance of some CCompiler subclass for the supplied platform/compiler combination. 'plat' defaults to 'os.name' (eg. 'posix', 'nt'), and 'compiler' defaults to the default compiler for that platform. Currently only 'posix' and 'nt' are supported, and the default compil

(plat=None, compiler=None, verbose=0, dry_run=0, force=0)

Source from the content-addressed store, hash-verified

380
381
382def new_compiler(plat=None, compiler=None, verbose=0, dry_run=0, force=0):
383 """Generate an instance of some CCompiler subclass for the supplied
384 platform/compiler combination. 'plat' defaults to 'os.name'
385 (eg. 'posix', 'nt'), and 'compiler' defaults to the default compiler
386 for that platform. Currently only 'posix' and 'nt' are supported, and
387 the default compilers are "traditional Unix interface" (UnixCCompiler
388 class) and Visual C++ (MSVCCompiler class). Note that it's perfectly
389 possible to ask for a Unix compiler object under Windows, and a
390 Microsoft compiler object under Unix -- if you supply a value for
391 'compiler', 'plat' is ignored.
392 """
393 if plat is None:
394 plat = os.name
395
396 try:
397 if compiler is None:
398 compiler = get_default_compiler(plat)
399
400 (module_name, class_name, long_description) = compiler_class[compiler]
401 except KeyError:
402 msg = "don't know how to compile C/C++ code on platform '%s'" % plat
403 if compiler is not None:
404 msg = msg + " with '%s' compiler" % compiler
405 raise DistutilsPlatformError(msg)
406
407 try:
408 module_name = "distutils." + module_name
409 __import__ (module_name)
410 module = sys.modules[module_name]
411 klass = vars(module)[class_name]
412 except ImportError:
413 raise
414 raise DistutilsModuleError(
415 "can't compile C/C++ code: unable to load module '%s'" % \
416 module_name)
417 except KeyError:
418 raise DistutilsModuleError(
419 "can't compile C/C++ code: unable to find class '%s' "
420 "in module '%s'" % (class_name, module_name))
421
422 # XXX The None is necessary to preserve backwards compatibility
423 # with classes that expect verbose to be the first positional
424 # argument.
425 return klass(None, dry_run, force)
426
427
428def gen_preprocess_options(macros, include_dirs):

Callers 1

compile_c_extensionFunction · 0.90

Calls 4

get_default_compilerFunction · 0.85
__import__Function · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…