| """build_env_internal defines a bunch of helper functions for build_env. |
| def GetSubprocessOutput(commands): |
| proc = subprocess.Popen(commands, stdout=subprocess.PIPE) |
| out, err = proc.communicate() |
| print 'Cannot run command', commands, '. Return empty output.' |
| # determine compiler type. |
| _COMPILER_VERSION_STR = GetSubprocessOutput([CC, '--version']) |
| if 'clang' in _COMPILER_VERSION_STR: |
| elif ('g++' in _COMPILER_VERSION_STR or |
| 'Free Software Foundation' in _COMPILER_VERSION_STR): |
| raise RuntimeError('Cannot determine C++ compiler type.') |
| includes = GetSubprocessOutput(['python-config', '--includes']) |
| # determine the numpy include directory. If any error happens, return |
| includes += ' -I' + ' -I'.join( |
| numpy.distutils.misc_util.get_numpy_include_dirs()) |
| python_root = GetSubprocessOutput(['python-config', '--prefix']) |
| lib_dir = os.path.join(python_root, 'lib') |