def checkCompiler(env): conf = Configure(env.Clone(), custom_tests = {'CheckComplexAcos': CheckComplexAcos}) if 'CheckCXX' in dir(conf): # exists since scons 1.1.0 if not conf.CheckCXX(): print("Cannot run C++ compiler '%s' (check config.log)" % (env['CXX'])) env.Exit(1) else: if not conf.CheckFunc('printf', language='c++'): print("Cannot run C++ compiler '%s' (check config.log)" % (env['CXX'])) env.Exit(1) conf.env['buildvars']['cxx']=conf.env['CXX'] if conf.CheckFunc('gethostname', language='c++'): conf.env.Append(CPPDEFINES = ['HAVE_GETHOSTNAME']) if conf.CheckCXXHeader('byteswap.h'): checkhdr="""#include <byteswap.h> #define SCbswap32() {int x=0;bswap_32(x);}""" if conf.CheckFunc('SCbswap32', header=checkhdr, language='c++'): conf.env.Append(CPPDEFINES = ['HAVE_BYTESWAP_H']) if conf.CheckCXXHeader('sys/endian.h'): conf.env.Append(CPPDEFINES = ['HAVE_SYS_ENDIAN_H']) if conf.CheckCXXHeader('libkern/OSByteOrder.h'): conf.env.Append(CPPDEFINES = ['HAVE_OSBYTEORDER_H']) if not conf.CheckComplexAcos(): conf.env.Append(CPPDEFINES = ['ESYS_USE_BOOST_ACOS']) return conf.Finish()
def checkNumpy(env): if not detectModule(env, 'numpy'): print( "Cannot import numpy. If it is installed try setting your PYTHONPATH and probably %s" % env['LD_LIBRARY_PATH_KEY']) env.Exit(1) ## check for numpy header (optional) conf = Configure(env.Clone()) numpy_h = False if conf.CheckCXXHeader(['Python.h', 'numpy/ndarrayobject.h']): numpy_h = True else: conda_prefix = os.environ.get('CONDA_PREFIX') if conda_prefix: # make a copy of CPPPATH so it can be restored if header check fails cpp_path_old = conf.env.get('CPPPATH', []).copy() conf.env.Append(CPPPATH=[ conda_prefix + '/Lib/site-packages/numpy/core/include' ]) if conf.CheckCXXHeader(['Python.h', 'numpy/ndarrayobject.h']): numpy_h = True else: conf.env['CPPPATH'] = cpp_path_old conf.env['numpy_h'] = numpy_h if numpy_h: conf.env.Append(CPPDEFINES=['ESYS_HAVE_NUMPY_H']) return conf.Finish()
def checkPython(env): # First we check to see if the config file has specified # where to find the file. Ideally, this should be automatic # but we need to deal with the case where python is not in its INSTALL # directory. # Use the python scons is running if env['pythoncmd'] == sys.executable: if env['IS_WINDOWS']: python_inc_path=sysconfig.get_python_inc() python_lib_path=os.path.join(sysconfig.get_config_var('prefix'), 'libs') python_libs=['python%s%s'%(sys.version_info[0], sys.version_info[1])] verstring=".".join([str(i) for i in sys.version_info[:3]]) else: (python_lib_path, python_libs,verstring, python_inc_path)=call_python_config() # if we want to use a python other than the one scons is running # Note: we assume scons is running python 2 in the following. else: (python_lib_path, python_libs,verstring, python_inc_path)=call_python_config(env['pythoncmd']) env['python_version'] = verstring ispython3 = (verstring[0] == '3') if ispython3: env.Append(CPPDEFINES=['ESPYTHON3']) env['buildvars']['python_version'] = verstring env['buildvars']['python'] = env['pythoncmd'] # Check for an override from the config file. # Ideally, this should be automatic but we need to deal with the case # where python is not in its INSTALL directory if env['pythonlibpath'] != '': python_lib_path = env['pythonlibpath'] if env['pythonincpath'] != '': python_inc_path = env['pythonincpath'] if env['pythonlibname'] != '': python_libs = env['pythonlibname'] conf = Configure(env.Clone()) if env['sysheaderopt'] == '': conf.env.AppendUnique(CPPPATH = [python_inc_path]) else: conf.env.Append(CCFLAGS = [env['sysheaderopt'], python_inc_path]) conf.env.AppendUnique(LIBPATH = [python_lib_path]) conf.env.AppendUnique(LIBS = python_libs) # The wrapper script needs to find the libs conf.env.PrependENVPath(env['LD_LIBRARY_PATH_KEY'], python_lib_path) if not conf.CheckCXXHeader('Python.h'): print("Cannot find python include files (tried 'Python.h' in directory %s)" % (python_inc_path)) env.Exit(1) if not conf.CheckFunc('Py_Exit', language='c++'): print("Cannot find python library method Py_Exit (tried %s in directory %s)" % (python_libs, python_lib_path)) env.Exit(1) return conf.Finish()
def checkDependencies(env): conf = Configure(env) checkPkgConfig(env, 'gtkmm-2.4') checkPkgConfig(env, 'libxml++-2.6') checkPkgConfig(env, 'gtkglext-1.0') checkPkgConfig(env, 'libgtksourceviewmm-1.0') if not conf.CheckCXXHeader('osg/Node'): raise Exception( 'ERROR: You have to install OSG development package before compiling osgedit' ) return conf.Finish()
def checkNumpy(env): if not detectModule(env, 'numpy'): print("Cannot import numpy. If it is installed try setting your PYTHONPATH and probably %s"%env['LD_LIBRARY_PATH_KEY']) env.Exit(1) ## check for numpy header (optional) conf = Configure(env.Clone()) if conf.CheckCXXHeader(['Python.h','numpy/ndarrayobject.h']): conf.env.Append(CPPDEFINES = ['ESYS_HAVE_NUMPY_H']) conf.env['numpy_h']=True else: conf.env['numpy_h']=False return conf.Finish()
def checkPython(env): # First we check to see if the config file has specified # where to find the file. Ideally, this should be automatic # but we need to deal with the case where python is not in its INSTALL # directory. # Use the python scons is running if env['pythoncmd'] == sys.executable: if env['IS_WINDOWS']: python_inc_path = sysconfig.get_python_inc() python_lib_path = os.path.join(sysconfig.get_config_var('prefix'), 'libs') python_libs = [ 'python%s%s' % (sys.version_info[0], sys.version_info[1]) ] verstring = ".".join([str(i) for i in sys.version_info[:3]]) else: (python_lib_path, python_libs, verstring, python_inc_path) = call_python_config(env['pythoncmd']) # if we want to use a python other than the one scons is running # Note: we assume scons is running python 2 in the following. else: if env['IS_WINDOWS']: cmd = "import os, sys\n" cmd += "from distutils import sysconfig\n" cmd += "print(sysconfig.get_python_inc())\n" cmd += "print(os.path.join(sysconfig.get_config_var('prefix'), 'libs'))\n" cmd += "print('python%s%s'%(sys.version_info[0], sys.version_info[1]))\n" cmd += "print('.'.join([str(i) for i in sys.version_info[:3]]))" pout = subprocess.Popen([env['pythoncmd'], '-c', cmd], stdout=subprocess.PIPE).stdout.read() if isinstance(pout, bytes): pout = pout.decode(sys.stdout.encoding) lines = pout.split('\n') python_inc_path = lines[0].strip() python_lib_path = lines[1].strip() python_libs = [lines[2].strip()] verstring = lines[3].strip() else: (python_lib_path, python_libs, verstring, python_inc_path) = call_python_config(env['pythoncmd']) if sys.version_info[0] == 3: if isinstance(verstring, str) is False: verstring = str(verstring, 'utf-8') else: if isinstance(verstring, basestring) is False: verstring = str(verstring, 'utf-8') env['python_version'] = verstring try: ispython3 = (verstring[0] == '3') except: ispython3 = sys.version_info[0] == 3 if ispython3: env.Append(CPPDEFINES=['ESPYTHON3']) env['buildvars']['python_version'] = verstring env['buildvars']['python'] = env['pythoncmd'] # Check for an override from the config file. # Ideally, this should be automatic but we need to deal with the case # where python is not in its INSTALL directory if env['pythonlibpath'] != '': python_lib_path = env['pythonlibpath'] if env['pythonincpath'] != '': python_inc_path = env['pythonincpath'] if env['pythonlibname'] != '': python_libs = env['pythonlibname'] conf = Configure(env.Clone()) if env['sysheaderopt'] == '': conf.env.AppendUnique(CPPPATH=[python_inc_path]) else: conf.env.Append(CCFLAGS=[env['sysheaderopt'], python_inc_path]) conf.env.AppendUnique(LIBPATH=[python_lib_path]) conf.env.AppendUnique(LIBS=python_libs) # The wrapper script needs to find the libs conf.env.PrependENVPath(env['LD_LIBRARY_PATH_KEY'], python_lib_path) if not conf.CheckCXXHeader('Python.h'): print( "Cannot find python include files (tried 'Python.h' in directory %s)" % (python_inc_path)) env.Exit(1) if not conf.CheckFunc('Py_Exit', language='c++'): print( "Cannot find python library method Py_Exit (tried %s in directory %s)" % (python_libs, python_lib_path)) env.Exit(1) return conf.Finish()