def _fixup_compiler(use_ccache): if "CC" in os.environ: # CC is in the environment, always use explicit # overrides. return try: # Newer version of python have support for dealing with # the compiler mess w.r.t. various versions of Apple's SDKs import _osx_support _osx_support.customize_compiler(get_config_vars()) except (ImportError, AttributeError, KeyError): pass cc = oldcc = get_config_var("CC").split()[0] cc = _find_executable(cc) if cc is not None and os.path.basename(cc).startswith("gcc"): # Check if compiler is LLVM-GCC, that's known to # generate bad code. with os.popen("'%s' --version 2>/dev/null" % (cc.replace("'", "'\"'\"'"), )) as fp: data = fp.read() if "llvm-gcc" in data: cc = None if cc is not None and not _working_compiler(cc): cc = None if cc is None: # Default compiler is not useable, try finding 'clang' cc = _find_executable("clang") if cc is None: cc = os.popen("/usr/bin/xcrun -find clang").read() if not cc: raise DistutilsPlatformError("Cannot locate compiler candidate") if not _working_compiler(cc): raise DistutilsPlatformError("Cannot locate a working compiler") if use_ccache: p = _find_executable("ccache") if p is not None: log.info("Detected and using 'ccache'") cc = "%s %s" % (p, cc) if cc != oldcc: log.info("Use '%s' instead of '%s' as the compiler" % (cc, oldcc)) vars = get_config_vars() for env in ("BLDSHARED", "LDSHARED", "CC", "CXX"): if env in vars and env not in os.environ: split = vars[env].split() split[0] = cc if env != "CXX" else cc + "++" vars[env] = " ".join(split)
def customize_compiler(compiler): """Do any platform-specific customization of a CCompiler instance. Mainly needed on Unix, so we can plug in the information that varies across Unices and is stored in Python's Makefile. """ global _config_vars if compiler.compiler_type == "unix": if sys.platform == "darwin": if not _config_vars.get("CUSTOMIZED_OSX_COMPILER", ""): import _osx_support _osx_support.customize_compiler(_config_vars) _config_vars["CUSTOMIZED_OSX_COMPILER"] = "True" cc, cxx, opt, cflags, ccshared, ldshared, so_ext, ar, ar_flags = get_config_vars( "CC", "CXX", "OPT", "CFLAGS", "CCSHARED", "LDSHARED", "SO", "AR", "ARFLAGS" ) if "CC" in os.environ: newcc = os.environ["CC"] if sys.platform == "darwin" and "LDSHARED" not in os.environ and ldshared.startswith(cc): ldshared = newcc + ldshared[len(cc) :] cc = newcc if "CXX" in os.environ: cxx = os.environ["CXX"] if "LDSHARED" in os.environ: ldshared = os.environ["LDSHARED"] if "CPP" in os.environ: cpp = os.environ["CPP"] else: cpp = cc + " -E" if "LDFLAGS" in os.environ: ldshared = ldshared + " " + os.environ["LDFLAGS"] if "CFLAGS" in os.environ: cflags = opt + " " + os.environ["CFLAGS"] ldshared = ldshared + " " + os.environ["CFLAGS"] if "CPPFLAGS" in os.environ: cpp = cpp + " " + os.environ["CPPFLAGS"] cflags = cflags + " " + os.environ["CPPFLAGS"] ldshared = ldshared + " " + os.environ["CPPFLAGS"] if "AR" in os.environ: ar = os.environ["AR"] if "ARFLAGS" in os.environ: archiver = ar + " " + os.environ["ARFLAGS"] else: archiver = ar + " " + ar_flags cc_cmd = cc + " " + cflags compiler.set_executables( preprocessor=cpp, compiler=cc_cmd, compiler_so=cc_cmd + " " + ccshared, compiler_cxx=cxx, linker_so=ldshared, linker_exe=cc, archiver=archiver, ) compiler.shared_lib_extension = so_ext
def customize_compiler(compiler): """Do any platform-specific customization of a CCompiler instance. Mainly needed on Unix, so we can plug in the information that varies across Unices and is stored in Python's Makefile. """ global _config_vars if compiler.compiler_type == 'unix': if sys.platform == 'darwin': if not _config_vars.get('CUSTOMIZED_OSX_COMPILER', ''): import _osx_support _osx_support.customize_compiler(_config_vars) _config_vars['CUSTOMIZED_OSX_COMPILER'] = 'True' cc, cxx, opt, cflags, ccshared, ldshared, so_ext, ar, ar_flags = get_config_vars( 'CC', 'CXX', 'OPT', 'CFLAGS', 'CCSHARED', 'LDSHARED', 'SO', 'AR', 'ARFLAGS') if 'CC' in os.environ: newcc = os.environ['CC'] if sys.platform == 'darwin' and 'LDSHARED' not in os.environ and ldshared.startswith( cc): ldshared = newcc + ldshared[len(cc):] cc = newcc if 'CXX' in os.environ: cxx = os.environ['CXX'] if 'LDSHARED' in os.environ: ldshared = os.environ['LDSHARED'] if 'CPP' in os.environ: cpp = os.environ['CPP'] else: cpp = cc + ' -E' if 'LDFLAGS' in os.environ: ldshared = ldshared + ' ' + os.environ['LDFLAGS'] if 'CFLAGS' in os.environ: cflags = opt + ' ' + os.environ['CFLAGS'] ldshared = ldshared + ' ' + os.environ['CFLAGS'] if 'CPPFLAGS' in os.environ: cpp = cpp + ' ' + os.environ['CPPFLAGS'] cflags = cflags + ' ' + os.environ['CPPFLAGS'] ldshared = ldshared + ' ' + os.environ['CPPFLAGS'] if 'AR' in os.environ: ar = os.environ['AR'] if 'ARFLAGS' in os.environ: archiver = ar + ' ' + os.environ['ARFLAGS'] else: archiver = ar + ' ' + ar_flags cc_cmd = cc + ' ' + cflags compiler.set_executables(preprocessor=cpp, compiler=cc_cmd, compiler_so=cc_cmd + ' ' + ccshared, compiler_cxx=cxx, linker_so=ldshared, linker_exe=cc, archiver=archiver) compiler.shared_lib_extension = so_ext
def _fixup_compiler(): if 'CC' in os.environ: # CC is in the environment, always use explicit # overrides. return try: import _osx_support _osx_support.customize_compiler(get_config_vars()) except (ImportError, NameError): pass cc = oldcc = get_config_var('CC').split()[0] cc = _find_executable(cc) if cc is not None and os.path.basename(cc).startswith('gcc'): # Check if compiler is LLVM-GCC, that's known to # generate bad code. data = os.popen("'%s' --version 2>/dev/null"%( cc.replace("'", "'\"'\"'"),)).read() if 'llvm-gcc' in data: cc = None if cc is not None and not _working_compiler(cc): cc = None if cc is None: # Default compiler is not useable, try finding 'clang' cc = _find_executable('clang') if cc is None: cc = os.popen("/usr/bin/xcrun -find clang").read() if not cc: raise SystemExit("Cannot locate compiler candidate") if not _working_compiler(cc): raise SystemExit("Cannot locate a working compiler") if cc != oldcc: print("Use '%s' instead of '%s' as the compiler"%( cc, oldcc)) vars = get_config_vars() for env in ('BLDSHARED', 'LDSHARED', 'CC', 'CXX'): if env in vars and env not in os.environ: split = vars[env].split() split[0] = cc if env != 'CXX' else cc + '++' vars[env] = ' '.join(split)
def _fixup_compiler(): if 'CC' in os.environ: # CC is in the environment, always use explicit # overrides. return try: # Newer version of python have support for dealing with # the compiler mess w.r.t. various versions of Apple's SDKs import _osx_support _osx_support.customize_compiler(get_config_vars()) except (ImportError, AttributeError, KeyError): pass cc = oldcc = get_config_var('CC').split()[0] cc = _find_executable(cc) if cc is not None and os.path.basename(cc).startswith('gcc'): # Check if compiler is LLVM-GCC, that's known to # generate bad code. data = os.popen("'%s' --version 2>/dev/null"%( cc.replace("'", "'\"'\"'"),)).read() if 'llvm-gcc' in data: cc = None if cc is not None and not _working_compiler(cc): cc = None if cc is None: # Default compiler is not useable, try finding 'clang' cc = _find_executable('clang') if cc is None: cc = os.popen("/usr/bin/xcrun -find clang").read() if not cc: raise DistutilsPlatformError("Cannot locate compiler candidate") if not _working_compiler(cc): raise DistutilsPlatformError("Cannot locate a working compiler") if cc != oldcc: log.info("Use '%s' instead of '%s' as the compiler"%(cc, oldcc)) vars = get_config_vars() for env in ('BLDSHARED', 'LDSHARED', 'CC', 'CXX'): if env in vars and env not in os.environ: split = vars[env].split() split[0] = cc if env != 'CXX' else cc + '++' vars[env] = ' '.join(split)
def customize_compiler(compiler): global _config_vars if compiler.compiler_type == 'unix': if sys.platform == 'darwin': if not _config_vars.get('CUSTOMIZED_OSX_COMPILER', ''): import _osx_support _osx_support.customize_compiler(_config_vars) _config_vars['CUSTOMIZED_OSX_COMPILER'] = 'True' cc, cxx, opt, cflags, ccshared, ldshared, so_ext, ar, ar_flags = get_config_vars( 'CC', 'CXX', 'OPT', 'CFLAGS', 'CCSHARED', 'LDSHARED', 'SO', 'AR', 'ARFLAGS') if 'CC' in os.environ: newcc = os.environ['CC'] if sys.platform == 'darwin' and 'LDSHARED' not in os.environ and ldshared.startswith( cc): ldshared = newcc + ldshared[len(cc):] cc = newcc if 'CXX' in os.environ: cxx = os.environ['CXX'] if 'LDSHARED' in os.environ: ldshared = os.environ['LDSHARED'] if 'CPP' in os.environ: cpp = os.environ['CPP'] else: cpp = cc + ' -E' if 'LDFLAGS' in os.environ: ldshared = ldshared + ' ' + os.environ['LDFLAGS'] if 'CFLAGS' in os.environ: cflags = opt + ' ' + os.environ['CFLAGS'] ldshared = ldshared + ' ' + os.environ['CFLAGS'] if 'CPPFLAGS' in os.environ: cpp = cpp + ' ' + os.environ['CPPFLAGS'] cflags = cflags + ' ' + os.environ['CPPFLAGS'] ldshared = ldshared + ' ' + os.environ['CPPFLAGS'] if 'AR' in os.environ: ar = os.environ['AR'] if 'ARFLAGS' in os.environ: archiver = ar + ' ' + os.environ['ARFLAGS'] else: archiver = ar + ' ' + ar_flags cc_cmd = cc + ' ' + cflags compiler.set_executables(preprocessor=cpp, compiler=cc_cmd, compiler_so=cc_cmd + ' ' + ccshared, compiler_cxx=cxx, linker_so=ldshared, linker_exe=cc, archiver=archiver) compiler.shared_lib_extension = so_ext
def customize_compiler(compiler): """Do any platform-specific customization of a CCompiler instance. Mainly needed on Unix, so we can plug in the information that varies across Unices and is stored in Python's Makefile. """ global _config_vars if compiler.compiler_type == 'unix': if sys.platform == 'darwin': if not _config_vars.get('CUSTOMIZED_OSX_COMPILER', ''): import _osx_support _osx_support.customize_compiler(_config_vars) _config_vars['CUSTOMIZED_OSX_COMPILER'] = 'True' cc, cxx, opt, cflags, ccshared, ldshared, so_ext, ar, ar_flags = get_config_vars('CC', 'CXX', 'OPT', 'CFLAGS', 'CCSHARED', 'LDSHARED', 'SO', 'AR', 'ARFLAGS') if 'CC' in os.environ: newcc = os.environ['CC'] if sys.platform == 'darwin' and 'LDSHARED' not in os.environ and ldshared.startswith(cc): ldshared = newcc + ldshared[len(cc):] cc = newcc if 'CXX' in os.environ: cxx = os.environ['CXX'] if 'LDSHARED' in os.environ: ldshared = os.environ['LDSHARED'] if 'CPP' in os.environ: cpp = os.environ['CPP'] else: cpp = cc + ' -E' if 'LDFLAGS' in os.environ: ldshared = ldshared + ' ' + os.environ['LDFLAGS'] if 'CFLAGS' in os.environ: cflags = opt + ' ' + os.environ['CFLAGS'] ldshared = ldshared + ' ' + os.environ['CFLAGS'] if 'CPPFLAGS' in os.environ: cpp = cpp + ' ' + os.environ['CPPFLAGS'] cflags = cflags + ' ' + os.environ['CPPFLAGS'] ldshared = ldshared + ' ' + os.environ['CPPFLAGS'] if 'AR' in os.environ: ar = os.environ['AR'] if 'ARFLAGS' in os.environ: archiver = ar + ' ' + os.environ['ARFLAGS'] else: archiver = ar + ' ' + ar_flags cc_cmd = cc + ' ' + cflags compiler.set_executables(preprocessor=cpp, compiler=cc_cmd, compiler_so=cc_cmd + ' ' + ccshared, compiler_cxx=cxx, linker_so=ldshared, linker_exe=cc, archiver=archiver) compiler.shared_lib_extension = so_ext
def customize_compiler(compiler): """Do any platform-specific customization of a CCompiler instance. Mainly needed on Unix, so we can plug in the information that varies across Unices and is stored in Python's Makefile. """ global _config_vars if compiler.compiler_type in ["cygwin", "mingw32"]: # Note that cygwin use posix build and 'unix' compiler. # If build is not based on posix then we must predefine # some environment variables corresponding to posix # build rules and defaults. if not 'GCC' in sys.version: _config_vars['CC'] = "gcc" _config_vars['CXX'] = "g++" _config_vars['OPT'] = "-fwrapv -O3 -Wall -Wstrict-prototypes" _config_vars['CFLAGS'] = "" _config_vars['CCSHARED'] = "" _config_vars[ 'LDSHARED'] = "gcc -shared -Wl,--enable-auto-image-base" _config_vars['AR'] = "ar" _config_vars['ARFLAGS'] = "rc" if compiler.compiler_type in ["unix", "cygwin", "mingw32"]: if sys.platform == "darwin": # Perform first-time customization of compiler-related # config vars on OS X now that we know we need a compiler. # This is primarily to support Pythons from binary # installers. The kind and paths to build tools on # the user system may vary significantly from the system # that Python itself was built on. Also the user OS # version and build tools may not support the same set # of CPU architectures for universal builds. # Use get_config_var() to ensure _config_vars is initialized. if not get_config_var('CUSTOMIZED_OSX_COMPILER'): import _osx_support _osx_support.customize_compiler(_config_vars) _config_vars['CUSTOMIZED_OSX_COMPILER'] = 'True' (cc, cxx, cflags, ccshared, ldshared, shlib_suffix, ar, ar_flags) = \ get_config_vars('CC', 'CXX', 'CFLAGS', 'CCSHARED', 'LDSHARED', 'SHLIB_SUFFIX', 'AR', 'ARFLAGS') if 'CC' in os.environ: newcc = os.environ['CC'] if (sys.platform == 'darwin' and 'LDSHARED' not in os.environ and ldshared.startswith(cc)): # On OS X, if CC is overridden, use that as the default # command for LDSHARED as well ldshared = newcc + ldshared[len(cc):] cc = newcc if 'CXX' in os.environ: cxx = os.environ['CXX'] if 'LDSHARED' in os.environ: ldshared = os.environ['LDSHARED'] if 'CPP' in os.environ: cpp = os.environ['CPP'] else: cpp = cc + " -E" # not always if 'LDFLAGS' in os.environ: ldshared = ldshared + ' ' + os.environ['LDFLAGS'] if 'CFLAGS' in os.environ: cflags = cflags + ' ' + os.environ['CFLAGS'] ldshared = ldshared + ' ' + os.environ['CFLAGS'] if 'CPPFLAGS' in os.environ: cpp = cpp + ' ' + os.environ['CPPFLAGS'] cflags = cflags + ' ' + os.environ['CPPFLAGS'] ldshared = ldshared + ' ' + os.environ['CPPFLAGS'] if 'AR' in os.environ: ar = os.environ['AR'] if 'ARFLAGS' in os.environ: archiver = ar + ' ' + os.environ['ARFLAGS'] else: archiver = ar + ' ' + ar_flags cc_cmd = cc + ' ' + cflags compiler.set_executables(preprocessor=cpp, compiler=cc_cmd, compiler_so=cc_cmd + ' ' + ccshared, compiler_cxx=cxx, linker_so=ldshared, linker_exe=cc, archiver=archiver) compiler.shared_lib_extension = shlib_suffix
def customize_compiler(compiler): """Do any platform-specific customization of a CCompiler instance. Mainly needed on Unix, so we can plug in the information that varies across Unices and is stored in Python's Makefile. """ global _config_vars if compiler.compiler_type in ["cygwin", "mingw32"]: # Note that cygwin use posix build and 'unix' compiler. # If build is not based on posix then we must predefine # some environment variables corresponding to posix # build rules and defaults. if not 'GCC' in sys.version: _config_vars['CC'] = "gcc" _config_vars['CXX'] = "g++" _config_vars['OPT'] = "-fwrapv -O3 -Wall -Wstrict-prototypes" _config_vars['CFLAGS'] = "" _config_vars['CCSHARED'] = "" _config_vars['LDSHARED'] = "gcc -shared -Wl,--enable-auto-image-base" _config_vars['AR'] = "ar" _config_vars['ARFLAGS'] = "rc" if compiler.compiler_type in ["unix", "cygwin", "mingw32"]: if sys.platform == "darwin": # Perform first-time customization of compiler-related # config vars on OS X now that we know we need a compiler. # This is primarily to support Pythons from binary # installers. The kind and paths to build tools on # the user system may vary significantly from the system # that Python itself was built on. Also the user OS # version and build tools may not support the same set # of CPU architectures for universal builds. # Use get_config_var() to ensure _config_vars is initialized. if not get_config_var('CUSTOMIZED_OSX_COMPILER'): import _osx_support _osx_support.customize_compiler(_config_vars) _config_vars['CUSTOMIZED_OSX_COMPILER'] = 'True' (cc, cxx, opt, cflags, ccshared, ldshared, so_ext, ar, ar_flags) = \ get_config_vars('CC', 'CXX', 'OPT', 'CFLAGS', 'CCSHARED', 'LDSHARED', 'SO', 'AR', 'ARFLAGS') if 'CC' in os.environ: newcc = os.environ['CC'] if (sys.platform == 'darwin' and 'LDSHARED' not in os.environ and ldshared.startswith(cc)): # On OS X, if CC is overridden, use that as the default # command for LDSHARED as well ldshared = newcc + ldshared[len(cc):] cc = newcc if 'CXX' in os.environ: cxx = os.environ['CXX'] if 'LDSHARED' in os.environ: ldshared = os.environ['LDSHARED'] if 'CPP' in os.environ: cpp = os.environ['CPP'] else: cpp = cc + " -E" # not always if 'LDFLAGS' in os.environ: ldshared = ldshared + ' ' + os.environ['LDFLAGS'] if 'CFLAGS' in os.environ: cflags = opt + ' ' + os.environ['CFLAGS'] ldshared = ldshared + ' ' + os.environ['CFLAGS'] if 'CPPFLAGS' in os.environ: cpp = cpp + ' ' + os.environ['CPPFLAGS'] cflags = cflags + ' ' + os.environ['CPPFLAGS'] ldshared = ldshared + ' ' + os.environ['CPPFLAGS'] if 'AR' in os.environ: ar = os.environ['AR'] if 'ARFLAGS' in os.environ: archiver = ar + ' ' + os.environ['ARFLAGS'] else: archiver = ar + ' ' + ar_flags cc_cmd = cc + ' ' + cflags compiler.set_executables( preprocessor=cpp, compiler=cc_cmd, compiler_so=cc_cmd + ' ' + ccshared, compiler_cxx=cxx, linker_so=ldshared, linker_exe=cc, archiver=archiver) compiler.shared_lib_extension = so_ext
def customize_compiler(compiler): """Do any platform-specific customization of a CCompiler instance. Mainly needed on Unix, so we can plug in the information that varies across Unices and is stored in Python's Makefile. NOTE: (known limitation of python build/install system) In cross-build environment make macros like CC and LDSHARED contain cross-compiler/linker instead of host compiler/linker. """ posix_build = None if compiler.compiler_type == "unix": posix_build = True elif compiler.compiler_type == "mingw32": if sys.version.find('GCC') >= 0: posix_build = True if posix_build == True: if sys.platform == "darwin": # Perform first-time customization of compiler-related # config vars on OS X now that we know we need a compiler. # This is primarily to support Pythons from binary # installers. The kind and paths to build tools on # the user system may vary significantly from the system # that Python itself was built on. Also the user OS # version and build tools may not support the same set # of CPU architectures for universal builds. global _config_vars if not _config_vars.get('CUSTOMIZED_OSX_COMPILER', ''): import _osx_support _osx_support.customize_compiler(_config_vars) _config_vars['CUSTOMIZED_OSX_COMPILER'] = 'True' (cc, cxx, opt, cflags, ccshared, ldshared, so_ext, ar, ar_flags) = \ get_config_vars('CC', 'CXX', 'OPT', 'CFLAGS', 'CCSHARED', 'LDSHARED', 'SO', 'AR', 'ARFLAGS') newcc = None if 'CC' in os.environ: cc = os.environ['CC'] if 'CXX' in os.environ: cxx = os.environ['CXX'] if 'LDSHARED' in os.environ: ldshared = os.environ['LDSHARED'] if 'CPP' in os.environ: cpp = os.environ['CPP'] else: cpp = cc + " -E" # not always if 'LDFLAGS' in os.environ: ldshared = ldshared + ' ' + os.environ['LDFLAGS'] if 'CFLAGS' in os.environ: cflags = opt + ' ' + os.environ['CFLAGS'] ldshared = ldshared + ' ' + os.environ['CFLAGS'] if 'CPPFLAGS' in os.environ: cpp = cpp + ' ' + os.environ['CPPFLAGS'] cflags = cflags + ' ' + os.environ['CPPFLAGS'] ldshared = ldshared + ' ' + os.environ['CPPFLAGS'] if 'AR' in os.environ: ar = os.environ['AR'] if 'ARFLAGS' in os.environ: archiver = ar + ' ' + os.environ['ARFLAGS'] else: archiver = ar + ' ' + ar_flags cc_cmd = cc + ' ' + cflags compiler.set_executables( preprocessor=cpp, compiler=cc_cmd, compiler_so=cc_cmd + ' ' + ccshared, compiler_cxx=cxx, linker_so=ldshared, linker_exe=cc, archiver=archiver) compiler.shared_lib_extension = so_ext
def customize_compiler(compiler): """Do any platform-specific customization of a CCompiler instance. Mainly needed on Unix, so we can plug in the information that varies across Unices and is stored in Python's Makefile. """ if compiler.compiler_type == "unix": if sys.platform == "darwin": # Perform first-time customization of compiler-related # config vars on OS X now that we know we need a compiler. # This is primarily to support Pythons from binary # installers. The kind and paths to build tools on # the user system may vary significantly from the system # that Python itself was built on. Also the user OS # version and build tools may not support the same set # of CPU architectures for universal builds. global _config_vars # Use get_config_var() to ensure _config_vars is initialized. if not get_config_var("CUSTOMIZED_OSX_COMPILER"): import _osx_support _osx_support.customize_compiler(_config_vars) _config_vars["CUSTOMIZED_OSX_COMPILER"] = "True" ( cc, cxx, cflags, ccshared, ldshared, shlib_suffix, ar, ar_flags, ) = get_config_vars( "CC", "CXX", "CFLAGS", "CCSHARED", "LDSHARED", "SHLIB_SUFFIX", "AR", "ARFLAGS", ) if "CC" in os.environ: newcc = os.environ["CC"] if ( sys.platform == "darwin" and "LDSHARED" not in os.environ and ldshared.startswith(cc) ): # On OS X, if CC is overridden, use that as the default # command for LDSHARED as well ldshared = newcc + ldshared[len(cc) :] cc = newcc if "CXX" in os.environ: cxx = os.environ["CXX"] if "LDSHARED" in os.environ: ldshared = os.environ["LDSHARED"] if "CPP" in os.environ: cpp = os.environ["CPP"] else: cpp = cc + " -E" # not always if "LDFLAGS" in os.environ: ldshared = ldshared + " " + os.environ["LDFLAGS"] if "CFLAGS" in os.environ: cflags = cflags + " " + os.environ["CFLAGS"] ldshared = ldshared + " " + os.environ["CFLAGS"] if "CPPFLAGS" in os.environ: cpp = cpp + " " + os.environ["CPPFLAGS"] cflags = cflags + " " + os.environ["CPPFLAGS"] ldshared = ldshared + " " + os.environ["CPPFLAGS"] if "AR" in os.environ: ar = os.environ["AR"] if "ARFLAGS" in os.environ: archiver = ar + " " + os.environ["ARFLAGS"] else: archiver = ar + " " + ar_flags cc_cmd = cc + " " + cflags compiler.set_executables( preprocessor=cpp, compiler=cc_cmd, compiler_so=cc_cmd + " " + ccshared, compiler_cxx=cxx, linker_so=ldshared, linker_exe=cc, archiver=archiver, ) compiler.shared_lib_extension = shlib_suffix
def customize_compiler(compiler): """Do any platform-specific customization of a CCompiler instance. Mainly needed on Unix, so we can plug in the information that varies across Unices and is stored in Python's Makefile. NOTE: (known limitation of python build/install system) In cross-build environment make macros like CC and LDSHARED contain cross-compiler/linker instead of host compiler/linker. """ posix_build = None if compiler.compiler_type == "unix": posix_build = True elif compiler.compiler_type == "mingw32": if sys.version.find('GCC') >= 0: posix_build = True if posix_build == True: if sys.platform == "darwin": # Perform first-time customization of compiler-related # config vars on OS X now that we know we need a compiler. # This is primarily to support Pythons from binary # installers. The kind and paths to build tools on # the user system may vary significantly from the system # that Python itself was built on. Also the user OS # version and build tools may not support the same set # of CPU architectures for universal builds. global _config_vars if not _config_vars.get('CUSTOMIZED_OSX_COMPILER', ''): import _osx_support _osx_support.customize_compiler(_config_vars) _config_vars['CUSTOMIZED_OSX_COMPILER'] = 'True' (cc, cxx, opt, cflags, ccshared, ldshared, so_ext, ar, ar_flags) = \ get_config_vars('CC', 'CXX', 'OPT', 'CFLAGS', 'CCSHARED', 'LDSHARED', 'SO', 'AR', 'ARFLAGS') newcc = None if 'CC' in os.environ: cc = os.environ['CC'] if 'CXX' in os.environ: cxx = os.environ['CXX'] if 'LDSHARED' in os.environ: ldshared = os.environ['LDSHARED'] if 'CPP' in os.environ: cpp = os.environ['CPP'] else: cpp = cc + " -E" # not always if 'LDFLAGS' in os.environ: ldshared = ldshared + ' ' + os.environ['LDFLAGS'] if 'CFLAGS' in os.environ: cflags = opt + ' ' + os.environ['CFLAGS'] ldshared = ldshared + ' ' + os.environ['CFLAGS'] if 'CPPFLAGS' in os.environ: cpp = cpp + ' ' + os.environ['CPPFLAGS'] cflags = cflags + ' ' + os.environ['CPPFLAGS'] ldshared = ldshared + ' ' + os.environ['CPPFLAGS'] if 'AR' in os.environ: ar = os.environ['AR'] if 'ARFLAGS' in os.environ: archiver = ar + ' ' + os.environ['ARFLAGS'] else: archiver = ar + ' ' + ar_flags cc_cmd = cc + ' ' + cflags compiler.set_executables(preprocessor=cpp, compiler=cc_cmd, compiler_so=cc_cmd + ' ' + ccshared, compiler_cxx=cxx, linker_so=ldshared, linker_exe=cc, archiver=archiver) compiler.shared_lib_extension = so_ext
def update_event(self, inp=-1): self.set_output_val(0, _osx_support.customize_compiler())
def customize_compiler(compiler): """Do any platform-specific customization of a CCompiler instance. Mainly needed on Unix, so we can plug in the information that varies across Unices and is stored in Python's Makefile. """ if compiler.compiler_type == "unix": if sys.platform == "darwin": # Perform first-time customization of compiler-related # config vars on OS X now that we know we need a compiler. # This is primarily to support Pythons from binary # installers. The kind and paths to build tools on # the user system may vary significantly from the system # that Python itself was built on. Also the user OS # version and build tools may not support the same set # of CPU architectures for universal builds. global _config_vars if not _config_vars.get('CUSTOMIZED_OSX_COMPILER', ''): import _osx_support _osx_support.customize_compiler(_config_vars) _config_vars['CUSTOMIZED_OSX_COMPILER'] = 'True' (cc, cxx, opt, cflags, ccshared, ldshared, so_ext, ar, ar_flags) = \ get_config_vars('CC', 'CXX', 'OPT', 'CFLAGS', 'CCSHARED', 'LDSHARED', 'SO', 'AR', 'ARFLAGS') if 'CC' in os.environ: newcc = os.environ['CC'] if (sys.platform == 'darwin' and 'LDSHARED' not in os.environ and ldshared.startswith(cc)): # On OS X, if CC is overridden, use that as the default # command for LDSHARED as well ldshared = newcc + ldshared[len(cc):] cc = newcc if 'CXX' in os.environ: cxx = os.environ['CXX'] if 'LDSHARED' in os.environ: ldshared = os.environ['LDSHARED'] if 'CPP' in os.environ: cpp = os.environ['CPP'] else: cpp = cc + " -E" # not always if 'LDFLAGS' in os.environ: ldshared = ldshared + ' ' + os.environ['LDFLAGS'] if 'CFLAGS' in os.environ: cflags = opt + ' ' + os.environ['CFLAGS'] ldshared = ldshared + ' ' + os.environ['CFLAGS'] if 'CPPFLAGS' in os.environ: cpp = cpp + ' ' + os.environ['CPPFLAGS'] cflags = cflags + ' ' + os.environ['CPPFLAGS'] ldshared = ldshared + ' ' + os.environ['CPPFLAGS'] if 'AR' in os.environ: ar = os.environ['AR'] if 'ARFLAGS' in os.environ: archiver = ar + ' ' + os.environ['ARFLAGS'] else: archiver = ar + ' ' + ar_flags cc_cmd = cc + ' ' + cflags compiler.set_executables(preprocessor=cpp, compiler=cc_cmd, compiler_so=cc_cmd + ' ' + ccshared, compiler_cxx=cxx, linker_so=ldshared, linker_exe=cc, archiver=archiver) compiler.shared_lib_extension = so_ext
def customize_compiler(compiler): """Do any platform-specific customization of a CCompiler instance. Mainly needed on Unix, so we can plug in the information that varies across Unices and is stored in Python's Makefile. """ if compiler.compiler_type == "unix": if sys.platform == "darwin": # Perform first-time customization of compiler-related # config vars on OS X now that we know we need a compiler. # This is primarily to support Pythons from binary # installers. The kind and paths to build tools on # the user system may vary significantly from the system # that Python itself was built on. Also the user OS # version and build tools may not support the same set # of CPU architectures for universal builds. global _config_vars if not _config_vars.get("CUSTOMIZED_OSX_COMPILER", ""): import _osx_support _osx_support.customize_compiler(_config_vars) _config_vars["CUSTOMIZED_OSX_COMPILER"] = "True" (cc, cxx, opt, cflags, ccshared, ldshared, so_ext, ar, ar_flags) = get_config_vars( "CC", "CXX", "OPT", "CFLAGS", "CCSHARED", "LDSHARED", "SO", "AR", "ARFLAGS" ) if "CC" in os.environ: newcc = os.environ["CC"] if sys.platform == "darwin" and "LDSHARED" not in os.environ and ldshared.startswith(cc): # On OS X, if CC is overridden, use that as the default # command for LDSHARED as well ldshared = newcc + ldshared[len(cc) :] cc = newcc if "CXX" in os.environ: cxx = os.environ["CXX"] if "LDSHARED" in os.environ: ldshared = os.environ["LDSHARED"] if "CPP" in os.environ: cpp = os.environ["CPP"] else: cpp = cc + " -E" # not always if "LDFLAGS" in os.environ: ldshared = ldshared + " " + os.environ["LDFLAGS"] if "CFLAGS" in os.environ: cflags = opt + " " + os.environ["CFLAGS"] ldshared = ldshared + " " + os.environ["CFLAGS"] if "CPPFLAGS" in os.environ: cpp = cpp + " " + os.environ["CPPFLAGS"] cflags = cflags + " " + os.environ["CPPFLAGS"] ldshared = ldshared + " " + os.environ["CPPFLAGS"] if "AR" in os.environ: ar = os.environ["AR"] if "ARFLAGS" in os.environ: archiver = ar + " " + os.environ["ARFLAGS"] else: archiver = ar + " " + ar_flags cc_cmd = cc + " " + cflags compiler.set_executables( preprocessor=cpp, compiler=cc_cmd, compiler_so=cc_cmd + " " + ccshared, compiler_cxx=cxx, linker_so=ldshared, linker_exe=cc, archiver=archiver, ) compiler.shared_lib_extension = so_ext
def customize_compiler(compiler): """Do any platform-specific customization of a CCompiler instance. Mainly needed on Unix, so we can plug in the information that varies across Unices and is stored in Python's Makefile. """ if compiler.compiler_type == "unix": if sys.platform == "darwin": # Perform first-time customization of compiler-related # config vars on OS X now that we know we need a compiler. # This is primarily to support Pythons from binary # installers. The kind and paths to build tools on # the user system may vary significantly from the system # that Python itself was built on. Also the user OS # version and build tools may not support the same set # of CPU architectures for universal builds. global _config_vars if not _config_vars.get('CUSTOMIZED_OSX_COMPILER', ''): import _osx_support _osx_support.customize_compiler(_config_vars) _config_vars['CUSTOMIZED_OSX_COMPILER'] = 'True' (cc, cxx, opt, cflags, ccshared, ldshared, shlib_suffix, ar, ar_flags) = \ get_config_vars('CC', 'CXX', 'OPT', 'CFLAGS', 'CCSHARED', 'LDSHARED', 'SHLIB_SUFFIX', 'AR', 'ARFLAGS') if 'CC' in os.environ: newcc = os.environ['CC'] if (sys.platform == 'darwin' and 'LDSHARED' not in os.environ and ldshared.startswith(cc)): # On OS X, if CC is overridden, use that as the default # command for LDSHARED as well ldshared = newcc + ldshared[len(cc):] cc = newcc if 'CXX' in os.environ: cxx = os.environ['CXX'] if 'LDSHARED' in os.environ: ldshared = os.environ['LDSHARED'] if 'CPP' in os.environ: cpp = os.environ['CPP'] else: cpp = cc + " -E" # not always if 'LDFLAGS' in os.environ: ldshared = ldshared + ' ' + os.environ['LDFLAGS'] if 'CFLAGS' in os.environ: cflags = opt + ' ' + os.environ['CFLAGS'] ldshared = ldshared + ' ' + os.environ['CFLAGS'] if 'CPPFLAGS' in os.environ: cpp = cpp + ' ' + os.environ['CPPFLAGS'] cflags = cflags + ' ' + os.environ['CPPFLAGS'] ldshared = ldshared + ' ' + os.environ['CPPFLAGS'] if 'AR' in os.environ: ar = os.environ['AR'] if 'ARFLAGS' in os.environ: archiver = ar + ' ' + os.environ['ARFLAGS'] else: archiver = ar + ' ' + ar_flags cc_cmd = cc + ' ' + cflags compiler.set_executables( preprocessor=cpp, compiler=cc_cmd, compiler_so=cc_cmd + ' ' + ccshared, compiler_cxx=cxx, linker_so=ldshared, linker_exe=cc, archiver=archiver) compiler.shared_lib_extension = shlib_suffix
def customize_compiler(compiler): """Do any platform-specific customization of a CCompiler instance. Mainly needed on Unix, so we can plug in the information that varies across Unices and is stored in Python's Makefile. """ if compiler.compiler_type == "unix": if sys.platform == "darwin": # Perform first-time customization of compiler-related # config vars on OS X now that we know we need a compiler. # This is primarily to support Pythons from binary # installers. The kind and paths to build tools on # the user system may vary significantly from the system # that Python itself was built on. Also the user OS # version and build tools may not support the same set # of CPU architectures for universal builds. global _config_vars # Use get_config_var() to ensure _config_vars is initialized. if not get_config_var('CUSTOMIZED_OSX_COMPILER'): import _osx_support _osx_support.customize_compiler(_config_vars) _config_vars['CUSTOMIZED_OSX_COMPILER'] = 'True' (cc, cxx, opt, cflags, extra_cflags, basecflags, ccshared, ldshared, so_ext, ar, ar_flags, configure_cppflags, configure_cflags, configure_ldflags) = \ get_config_vars('CC', 'CXX', 'OPT', 'CFLAGS', 'EXTRA_CFLAGS', 'BASECFLAGS', 'CCSHARED', 'LDSHARED', 'SO', 'AR', 'ARFLAGS', 'CONFIGURE_CPPFLAGS', 'CONFIGURE_CFLAGS', 'CONFIGURE_LDFLAGS') if 'CC' in os.environ: newcc = os.environ['CC'] if (sys.platform == 'darwin' and 'LDSHARED' not in os.environ and ldshared.startswith(cc)): # On OS X, if CC is overridden, use that as the default # command for LDSHARED as well ldshared = newcc + ldshared[len(cc):] cc = newcc if 'CXX' in os.environ: cxx = os.environ['CXX'] if fnmatch.filter([cc, cxx], '*-4.[0-8]'): configure_cflags = configure_cflags.replace('-fstack-protector-strong', '-fstack-protector') ldshared = ldshared.replace('-fstack-protector-strong', '-fstack-protector') cflags = cflags.replace('-fstack-protector-strong', '-fstack-protector') if 'LDSHARED' in os.environ: ldshared = os.environ['LDSHARED'] if 'CPP' in os.environ: cpp = os.environ['CPP'] else: cpp = cc + " -E" # not always if 'LDFLAGS' in os.environ: ldshared = ldshared + ' ' + os.environ['LDFLAGS'] elif configure_ldflags: ldshared = ldshared + ' ' + configure_ldflags if 'BASECFLAGS' in os.environ: basecflags = os.environ['BASECFLAGS'] if 'OPT' in os.environ: opt = os.environ['OPT'] cflags = ' '.join(str(x) for x in (basecflags, opt, extra_cflags) if x) if 'CFLAGS' in os.environ: cflags = ' '.join(str(x) for x in (opt, basecflags, os.environ['CFLAGS'], extra_cflags) if x) ldshared = ldshared + ' ' + os.environ['CFLAGS'] elif configure_cflags: cflags = ' '.join(str(x) for x in (opt, basecflags, configure_cflags, extra_cflags) if x) ldshared = ldshared + ' ' + configure_cflags if 'CPPFLAGS' in os.environ: cpp = cpp + ' ' + os.environ['CPPFLAGS'] cflags = cflags + ' ' + os.environ['CPPFLAGS'] ldshared = ldshared + ' ' + os.environ['CPPFLAGS'] elif configure_cppflags: cpp = cpp + ' ' + configure_cppflags cflags = cflags + ' ' + configure_cppflags ldshared = ldshared + ' ' + configure_cppflags if 'AR' in os.environ: ar = os.environ['AR'] if 'ARFLAGS' in os.environ: archiver = ar + ' ' + os.environ['ARFLAGS'] else: archiver = ar + ' ' + ar_flags cc_cmd = cc + ' ' + cflags compiler.set_executables( preprocessor=cpp, compiler=cc_cmd, compiler_so=cc_cmd + ' ' + ccshared, compiler_cxx=cxx, linker_so=ldshared, linker_exe=cc, archiver=archiver) compiler.shared_lib_extension = so_ext