def detect(conf): join = os.path.join conf.env['PREFIX_NODE'] = get_prefix() prefix = conf.env['PREFIX_NODE'] lib = join(prefix, 'lib') conf.env['LIBPATH_NODE'] = lib conf.env['CPPPATH_NODE'] = join(prefix, 'include', 'node') conf.env['CPPFLAGS_NODE'] = '-D_GNU_SOURCE' conf.env['CPPFLAGS_NODE'] = '-DEV_MULTIPLICITY=0' # with symbols conf.env.append_value('CCFLAGS', ['-g']) conf.env.append_value('CXXFLAGS', ['-g']) # install path conf.env['NODE_PATH'] = get_node_path() # this changes the install path of cxx task_gen conf.env['LIBDIR'] = conf.env['NODE_PATH'] found = os.path.exists(conf.env['NODE_PATH']) conf.check_message('node path', '', found, conf.env['NODE_PATH']) found = os.path.exists(join(prefix, 'bin', 'node')) conf.check_message('node prefix', '', found, prefix) ## On Cygwin we need to link to the generated symbol definitions if Options.platform.startswith('cygwin'): conf.env['LIB_NODE'] = 'node' ## On Mac OSX we need to use mac bundles if Options.platform == 'darwin': conf.check_tool('osx')
def SAMBA_CHECK_PYTHON(conf, mandatory=True, version=(2,4,2)): # enable tool to build python extensions conf.find_program('python', var='PYTHON', mandatory=mandatory) conf.check_tool('python') path_python = conf.find_program('python') conf.env.PYTHON_SPECIFIED = (conf.env.PYTHON != path_python) conf.check_python_version(version)
def detect(conf): join = os.path.join abspath = os.path.abspath wafadmin = abspath(join(os.path.dirname(__file__), '..')) libnode = abspath(join(wafadmin, '..')) lib = abspath(join(libnode, '..')) prefix = abspath(join(lib, '..')) conf.env['PREFIX_NODE'] = prefix conf.env['LIBPATH_NODE'] = lib conf.env['CPPPATH_NODE'] = join(prefix, 'include/node') conf.env['CPPFLAGS_NODE'] = '-D_GNU_SOURCE' conf.env['CPPFLAGS_NODE'] = '-DEV_MULTIPLICITY=0' # with symbols conf.env.append_value('CCFLAGS', ['-g']) conf.env.append_value('CXXFLAGS', ['-g']) found = os.path.exists(join(prefix, "bin/node")) conf.check_message('node prefix', '', found, prefix) ## On Cygwin we need to link to the generated symbol definitions if Options.platform.startswith('cygwin'): conf.env['LIB_NODE'] = 'node' ## On Mac OSX we need to use mac bundles if Options.platform == 'darwin': conf.check_tool('osx')
def SAMBA_CHECK_PYTHON(conf, mandatory=True, version=(2,4,2)): # enable tool to build python extensions if conf.env.HAVE_PYTHON_H: conf.check_python_version(version) return interpreters = [] if conf.env['EXTRA_PYTHON']: conf.all_envs['extrapython'] = conf.env.copy() conf.setenv('extrapython') conf.env['PYTHON'] = conf.env['EXTRA_PYTHON'] conf.env['IS_EXTRA_PYTHON'] = 'yes' conf.find_program('python', var='PYTHON', mandatory=True) conf.check_tool('python') try: conf.check_python_version((3, 3, 0)) except Exception: Logs.warn('extra-python needs to be Python 3.3 or later') raise interpreters.append(conf.env['PYTHON']) conf.setenv('default') conf.find_program('python', var='PYTHON', mandatory=mandatory) conf.check_tool('python') path_python = conf.find_program('python') conf.env.PYTHON_SPECIFIED = (conf.env.PYTHON != path_python) conf.check_python_version(version) interpreters.append(conf.env['PYTHON']) conf.env.python_interpreters = interpreters
def SAMBA_CHECK_PERL(conf, mandatory=True, version=(5, 0, 0)): # # TODO: use the @runonce mechanism for this. # The problem is that @runonce currently does # not seem to work together with @conf... # So @runonce (and/or) @conf needs fixing. # if "done" in done: return done["done"] = True conf.find_program("perl", var="PERL", mandatory=mandatory) conf.check_tool("perl") path_perl = conf.find_program("perl") conf.env.PERL_SPECIFIED = conf.env.PERL != path_perl conf.check_perl_version(version) def read_perl_config_var(cmd): return Utils.to_list(Utils.cmd_output([conf.env.PERL, "-MConfig", "-e", cmd])) def check_perl_config_var(var): conf.start_msg("Checking for perl $Config{%s}:" % var) try: v = read_perl_config_var("print $Config{%s}" % var)[0] conf.end_msg("'%s'" % (v), "GREEN") return v except IndexError: conf.end_msg(False, "YELLOW") pass return None vendor_prefix = check_perl_config_var("vendorprefix") perl_arch_install_dir = None if vendor_prefix == conf.env.PREFIX: perl_arch_install_dir = check_perl_config_var("vendorarch") if perl_arch_install_dir is None: perl_arch_install_dir = "${LIBDIR}/perl5" conf.start_msg("PERL_ARCH_INSTALL_DIR: ") conf.end_msg("'%s'" % (perl_arch_install_dir), "GREEN") conf.env.PERL_ARCH_INSTALL_DIR = perl_arch_install_dir perl_lib_install_dir = None if vendor_prefix == conf.env.PREFIX: perl_lib_install_dir = check_perl_config_var("vendorlib") if perl_lib_install_dir is None: perl_lib_install_dir = "${DATADIR}/perl5" conf.start_msg("PERL_LIB_INSTALL_DIR: ") conf.end_msg("'%s'" % (perl_lib_install_dir), "GREEN") conf.env.PERL_LIB_INSTALL_DIR = perl_lib_install_dir perl_inc = read_perl_config_var('print "@INC"') perl_inc.remove(".") conf.start_msg("PERL_INC: ") conf.end_msg("%s" % (perl_inc), "GREEN") conf.env.PERL_INC = perl_inc
def SAMBA_CHECK_PERL(conf, mandatory=True, version=(5,0,0)): if "done" in done: return done["done"] = True conf.find_program('perl', var='PERL', mandatory=mandatory) conf.check_tool('perl') path_perl = conf.find_program('perl') conf.env.PERL_SPECIFIED = (conf.env.PERL != path_perl) conf.check_perl_version(version) def read_perl_config_var(cmd): return Utils.to_list(Utils.cmd_output([conf.env.PERL, '-MConfig', '-e', cmd])) def check_perl_config_var(var): conf.start_msg("Checking for perl $Config{%s}:" % var) try: v = read_perl_config_var('print $Config{%s}' % var)[0] conf.end_msg("'%s'" % (v), 'GREEN') return v except IndexError: conf.end_msg(False, 'YELLOW') pass return None vendor_prefix = check_perl_config_var('vendorprefix') perl_arch_install_dir = None if vendor_prefix == conf.env.PREFIX: perl_arch_install_dir = check_perl_config_var('vendorarch'); if perl_arch_install_dir is None: perl_arch_install_dir = "${LIBDIR}/perl5"; conf.start_msg("PERL_ARCH_INSTALL_DIR: ") conf.end_msg("'%s'" % (perl_arch_install_dir), 'GREEN') conf.env.PERL_ARCH_INSTALL_DIR = perl_arch_install_dir perl_lib_install_dir = None if vendor_prefix == conf.env.PREFIX: perl_lib_install_dir = check_perl_config_var('vendorlib'); if perl_lib_install_dir is None: perl_lib_install_dir = "${DATADIR}/perl5"; conf.start_msg("PERL_LIB_INSTALL_DIR: ") conf.end_msg("'%s'" % (perl_lib_install_dir), 'GREEN') conf.env.PERL_LIB_INSTALL_DIR = perl_lib_install_dir perl_inc = read_perl_config_var('print "@INC"') if '.' in perl_inc: perl_inc.remove('.') conf.start_msg("PERL_INC: ") conf.end_msg("%s" % (perl_inc), 'GREEN') conf.env.PERL_INC = perl_inc
def SAMBA_CHECK_PERL(conf, mandatory=True, version=(5, 0, 0)): if "done" in done: return done["done"] = True conf.find_program("perl", var="PERL", mandatory=mandatory) conf.check_tool("perl") path_perl = conf.find_program("perl") conf.env.PERL_SPECIFIED = conf.env.PERL != path_perl conf.check_perl_version(version) def read_perl_config_var(cmd): return Utils.to_list(Utils.cmd_output([conf.env.PERL, "-MConfig", "-e", cmd])) def check_perl_config_var(var): conf.start_msg("Checking for perl $Config{{{0!s}}}:".format(var)) try: v = read_perl_config_var("print $Config{{{0!s}}}".format(var))[0] conf.end_msg("'{0!s}'".format((v)), "GREEN") return v except IndexError: conf.end_msg(False, "YELLOW") pass return None vendor_prefix = check_perl_config_var("vendorprefix") perl_arch_install_dir = None if vendor_prefix == conf.env.PREFIX: perl_arch_install_dir = check_perl_config_var("vendorarch") if perl_arch_install_dir is None: perl_arch_install_dir = "${LIBDIR}/perl5" conf.start_msg("PERL_ARCH_INSTALL_DIR: ") conf.end_msg("'{0!s}'".format((perl_arch_install_dir)), "GREEN") conf.env.PERL_ARCH_INSTALL_DIR = perl_arch_install_dir perl_lib_install_dir = None if vendor_prefix == conf.env.PREFIX: perl_lib_install_dir = check_perl_config_var("vendorlib") if perl_lib_install_dir is None: perl_lib_install_dir = "${DATADIR}/perl5" conf.start_msg("PERL_LIB_INSTALL_DIR: ") conf.end_msg("'{0!s}'".format((perl_lib_install_dir)), "GREEN") conf.env.PERL_LIB_INSTALL_DIR = perl_lib_install_dir perl_inc = read_perl_config_var('print "@INC"') perl_inc.remove(".") conf.start_msg("PERL_INC: ") conf.end_msg("{0!s}".format((perl_inc)), "GREEN") conf.env.PERL_INC = perl_inc
def find_msvc(conf): if sys.platform!='win32': conf.fatal('MSVC module only works under native Win32 Python! cygwin is not supported yet') v=conf.env compiler,version,path,includes,libdirs=detect_msvc(conf) compiler_name,linker_name,lib_name=_get_prog_names(conf,compiler) has_msvc_manifest=(compiler=='msvc'and float(version)>=8)or(compiler=='wsdk'and float(version)>=6)or(compiler=='intel'and float(version)>=11) cxx=None if v.CXX:cxx=v.CXX elif'CXX'in conf.environ:cxx=conf.environ['CXX'] if not cxx:cxx=conf.find_program(compiler_name,var='CXX',path_list=path,mandatory=True) cxx=conf.cmd_to_list(cxx) env=dict(conf.environ) env.update(PATH=';'.join(path)) if not Utils.cmd_output([cxx,'/nologo','/?'],silent=True,env=env): conf.fatal('the msvc compiler could not be identified') link=v.LINK_CXX if not link: link=conf.find_program(linker_name,path_list=path,mandatory=True) ar=v.AR if not ar: ar=conf.find_program(lib_name,path_list=path,mandatory=True) mt=v.MT if has_msvc_manifest: mt=conf.find_program('MT',path_list=path,mandatory=True) v.MSVC_MANIFEST=has_msvc_manifest v.PATH=path v.CPPPATH=includes v.LIBPATH=libdirs v.CC=v.CXX=cxx v.CC_NAME=v.CXX_NAME='msvc' v.LINK=v.LINK_CXX=link if not v.LINK_CC: v.LINK_CC=v.LINK_CXX v.AR=ar v.MT=mt v.MTFLAGS=v.ARFLAGS=['/NOLOGO'] conf.check_tool('winres') if not conf.env.WINRC: warn('Resource compiler not found. Compiling resource file is disabled') try:v.prepend_value('CPPPATH',conf.environ['INCLUDE']) except KeyError:pass try:v.prepend_value('LIBPATH',conf.environ['LIB']) except KeyError:pass
def detect(conf): join = os.path.join conf.env['PREFIX_NODE'] = get_prefix() prefix = conf.env['PREFIX_NODE'] lib = join(prefix, 'lib') nodebin = join(prefix, 'bin', 'node') conf.env['LIBPATH_NODE'] = lib conf.env['CPPPATH_NODE'] = join(prefix, 'include', 'node') conf.env.append_value('CPPFLAGS_NODE', '-D_GNU_SOURCE') conf.env.append_value('CCFLAGS_NODE', '-D_LARGEFILE_SOURCE') conf.env.append_value('CCFLAGS_NODE', '-D_FILE_OFFSET_BITS=64') conf.env.append_value('CXXFLAGS_NODE', '-D_LARGEFILE_SOURCE') conf.env.append_value('CXXFLAGS_NODE', '-D_FILE_OFFSET_BITS=64') # with symbols conf.env.append_value('CCFLAGS', ['-g']) conf.env.append_value('CXXFLAGS', ['-g']) # install path conf.env['NODE_PATH'] = get_node_path() # this changes the install path of cxx task_gen conf.env['LIBDIR'] = conf.env['NODE_PATH'] found = os.path.exists(conf.env['NODE_PATH']) conf.check_message('node path', '', found, conf.env['NODE_PATH']) found = os.path.exists(nodebin) conf.check_message('node prefix', '', found, prefix) ## On Cygwin we need to link to the generated symbol definitions if Options.platform.startswith('cygwin'): conf.env['LIB_NODE'] = 'node' ## On Mac OSX we need to use mac bundles if Options.platform == 'darwin': if 'i386' in Utils.cmd_output(['file', nodebin]): conf.env.append_value('CPPFLAGS_NODE', ['-arch', 'i386']) conf.env.append_value('CXXFLAGS_NODE', ['-arch', 'i386']) conf.env.append_value('LINKFLAGS', ['-arch', 'i386']) conf.env['DEST_CPU'] = 'i386' conf.check_tool('osx')
def detect(conf): join = os.path.join abspath = os.path.abspath wafadmin = abspath(join(os.path.dirname(__file__), '..')) libnode = abspath(join(wafadmin, '..')) lib = abspath(join(libnode, '..')) prefix = abspath(join(lib, '..')) conf.env['PREFIX_NODE'] = prefix conf.env['LIBPATH_NODE'] = lib conf.env['CPPPATH_NODE'] = join(prefix, 'include/node') conf.env['CPPFLAGS_NODE'] = '-D_GNU_SOURCE' conf.env['CPPFLAGS_NODE'] = '-DEV_MULTIPLICITY=0' found = os.path.exists(join(prefix, "bin/node")) conf.check_message('node prefix', '', found, prefix) ## On Mac OSX we need to use mac bundles if Options.platform == 'darwin': conf.check_tool('osx')
def find_msvc(conf): if sys.platform!='win32': conf.fatal('MSVC module only works under native Win32 Python! cygwin is not supported yet') v=conf.env compiler,path,includes,libdirs=detect_msvc(conf) v['PATH']=path v['CPPPATH']=includes v['LIBPATH']=libdirs compiler_name,linker_name,lib_name=_get_prog_names(conf,compiler) cxx=None if v['CXX']:cxx=v['CXX'] elif'CXX'in conf.environ:cxx=conf.environ['CXX'] if not cxx:cxx=conf.find_program(compiler_name,var='CXX',path_list=path) if not cxx:conf.fatal('%s was not found (compiler)'%compiler_name) cxx=conf.cmd_to_list(cxx) env=dict(conf.environ) env.update(PATH=';'.join(path)) if not Utils.cmd_output([cxx,'/nologo','/?'],silent=True,env=env): conf.fatal('the msvc compiler could not be identified') v['CC']=v['CXX']=cxx v['CC_NAME']=v['CXX_NAME']='msvc' try:v.prepend_value('CPPPATH',conf.environ['INCLUDE']) except KeyError:pass try:v.prepend_value('LIBPATH',conf.environ['LIB']) except KeyError:pass if not v['LINK_CXX']: link=conf.find_program(linker_name,path_list=path) if link:v['LINK_CXX']=link else:conf.fatal('%s was not found (linker)'%linker_name) v['LINK']=link if not v['LINK_CC']:v['LINK_CC']=v['LINK_CXX'] if not v['AR']: stliblink=conf.find_program(lib_name,path_list=path) if not stliblink:return v['AR']=stliblink v['ARFLAGS']=['/NOLOGO'] manifesttool=conf.find_program('MT',path_list=path) if manifesttool: v['MT']=manifesttool v['MTFLAGS']=['/NOLOGO'] conf.check_tool('winres') if not conf.env['WINRC']: warn('Resource compiler not found. Compiling resource file is disabled')
def detect(conf): join = os.path.join conf.env["PREFIX_NODE"] = get_prefix() prefix = conf.env["PREFIX_NODE"] lib = join(prefix, "lib") conf.env["LIBPATH_NODE"] = lib conf.env["CPPPATH_NODE"] = join(prefix, "include", "node") conf.env.append_value("CPPFLAGS_NODE", "-D_GNU_SOURCE") conf.env.append_value("CPPFLAGS_NODE", "-DEV_MULTIPLICITY=0") conf.env.append_value("CCFLAGS_NODE", "-D_LARGEFILE_SOURCE") conf.env.append_value("CCFLAGS_NODE", "-D_FILE_OFFSET_BITS=64") conf.env.append_value("CXXFLAGS_NODE", "-D_LARGEFILE_SOURCE") conf.env.append_value("CXXFLAGS_NODE", "-D_FILE_OFFSET_BITS=64") # with symbols conf.env.append_value("CCFLAGS", ["-g"]) conf.env.append_value("CXXFLAGS", ["-g"]) # install path conf.env["NODE_PATH"] = get_node_path() # this changes the install path of cxx task_gen conf.env["LIBDIR"] = conf.env["NODE_PATH"] found = os.path.exists(conf.env["NODE_PATH"]) conf.check_message("node path", "", found, conf.env["NODE_PATH"]) found = os.path.exists(join(prefix, "bin", "node")) conf.check_message("node prefix", "", found, prefix) ## On Cygwin we need to link to the generated symbol definitions if Options.platform.startswith("cygwin"): conf.env["LIB_NODE"] = "node" ## On Mac OSX we need to use mac bundles if Options.platform == "darwin": conf.check_tool("osx")
def find_msvc(conf): # due to path format limitations, limit operation only to native Win32. Yeah it sucks. if sys.platform != 'win32': conf.fatal('MSVC module only works under native Win32 Python! cygwin is not supported yet') v = conf.env compiler, version, path, includes, libdirs = detect_msvc(conf) compiler_name, linker_name, lib_name = _get_prog_names(conf, compiler) has_msvc_manifest = (compiler == 'msvc' and float(version) >= 8) or (compiler == 'wsdk' and float(version) >= 6) or (compiler == 'intel' and float(version) >= 11) # compiler cxx = None if v.CXX: cxx = v.CXX elif 'CXX' in conf.environ: cxx = conf.environ['CXX'] if not cxx: cxx = conf.find_program(compiler_name, var='CXX', path_list=path, mandatory=True) cxx = conf.cmd_to_list(cxx) # before setting anything, check if the compiler is really msvc env = dict(conf.environ) env.update(PATH = ';'.join(path)) if not Utils.cmd_output([cxx, '/nologo', '/?'], silent=True, env=env): conf.fatal('the msvc compiler could not be identified') link = v.LINK_CXX if not link: link = conf.find_program(linker_name, path_list=path, mandatory=True) ar = v.AR if not ar: ar = conf.find_program(lib_name, path_list=path, mandatory=True) # manifest tool. Not required for VS 2003 and below. Must have for VS 2005 and later mt = v.MT if has_msvc_manifest: mt = conf.find_program('MT', path_list=path, mandatory=True) # no more possibility of failure means the data state will be consistent # we may store the data safely now v.MSVC_MANIFEST = has_msvc_manifest v.PATH = path v.CPPPATH = includes v.LIBPATH = libdirs # c/c++ compiler v.CC = v.CXX = cxx v.CC_NAME = v.CXX_NAME = 'msvc' v.LINK = v.LINK_CXX = link if not v.LINK_CC: v.LINK_CC = v.LINK_CXX v.AR = ar v.MT = mt v.MTFLAGS = v.ARFLAGS = ['/NOLOGO'] conf.check_tool('winres') if not conf.env.WINRC: warn('Resource compiler not found. Compiling resource file is disabled') # environment flags try: v.prepend_value('CPPPATH', conf.environ['INCLUDE']) except KeyError: pass try: v.prepend_value('LIBPATH', conf.environ['LIB']) except KeyError: pass
def cc_load_tools(conf): conf.check_tool('cc')
def find_msvc(conf): # due to path format limitations, limit operation only to native Win32. Yeah it sucks. if sys.platform != 'win32': conf.fatal( 'MSVC module only works under native Win32 Python! cygwin is not supported yet' ) v = conf.env compiler, version, path, includes, libdirs = detect_msvc(conf) compiler_name, linker_name, lib_name = _get_prog_names(conf, compiler) has_msvc_manifest = (compiler == 'msvc' and float(version) >= 8) or ( compiler == 'wsdk' and float(version) >= 6) or (compiler == 'intel' and float(version) >= 11) # compiler cxx = None if v.CXX: cxx = v.CXX elif 'CXX' in conf.environ: cxx = conf.environ['CXX'] if not cxx: cxx = conf.find_program(compiler_name, var='CXX', path_list=path, mandatory=True) cxx = conf.cmd_to_list(cxx) # before setting anything, check if the compiler is really msvc env = dict(conf.environ) env.update(PATH=';'.join(path)) if not Utils.cmd_output([cxx, '/nologo', '/?'], silent=True, env=env): conf.fatal('the msvc compiler could not be identified') link = v.LINK_CXX if not link: link = conf.find_program(linker_name, path_list=path, mandatory=True) ar = v.AR if not ar: ar = conf.find_program(lib_name, path_list=path, mandatory=True) # manifest tool. Not required for VS 2003 and below. Must have for VS 2005 and later mt = v.MT if has_msvc_manifest: mt = conf.find_program('MT', path_list=path, mandatory=True) # no more possibility of failure means the data state will be consistent # we may store the data safely now v.MSVC_MANIFEST = has_msvc_manifest v.PATH = path v.CPPPATH = includes v.LIBPATH = libdirs # c/c++ compiler v.CC = v.CXX = cxx v.CC_NAME = v.CXX_NAME = 'msvc' v.LINK = v.LINK_CXX = link if not v.LINK_CC: v.LINK_CC = v.LINK_CXX v.AR = ar v.MT = mt v.MTFLAGS = v.ARFLAGS = ['/NOLOGO'] conf.check_tool('winres') if not conf.env.WINRC: warn( 'Resource compiler not found. Compiling resource file is disabled') # environment flags try: v.prepend_value('CPPPATH', conf.environ['INCLUDE']) except KeyError: pass try: v.prepend_value('LIBPATH', conf.environ['LIB']) except KeyError: pass
def cxx_load_tools(conf): conf.check_tool("cxx")
def check_python_headers(conf, mandatory=True): """Check for headers and libraries necessary to extend or embed python. On success the environment variables xxx_PYEXT and xxx_PYEMBED are added for uselib PYEXT: for compiling python extensions PYEMBED: for embedding a python interpreter""" if not conf.env['CC_NAME'] and not conf.env['CXX_NAME']: conf.fatal('load a compiler first (gcc, g++, ..)') if not conf.env['PYTHON_VERSION']: conf.check_python_version() env = conf.env python = env['PYTHON'] if not python: conf.fatal('could not find the python executable') ## On Mac OSX we need to use mac bundles for python plugins if Options.platform == 'darwin': conf.check_tool('osx') try: # Get some python configuration variables using distutils v = 'prefix SO SYSLIBS LDFLAGS SHLIBS LIBDIR LIBPL INCLUDEPY Py_ENABLE_SHARED MACOSX_DEPLOYMENT_TARGET'.split( ) (python_prefix, python_SO, python_SYSLIBS, python_LDFLAGS, python_SHLIBS, python_LIBDIR, python_LIBPL, INCLUDEPY, Py_ENABLE_SHARED, python_MACOSX_DEPLOYMENT_TARGET) = \ _get_python_variables(python, ["get_config_var('%s') or ''" % x for x in v], ['from distutils.sysconfig import get_config_var']) except RuntimeError: conf.fatal("Python development headers not found (-v for details).") conf.log.write("""Configuration returned from %r: python_prefix = %r python_SO = %r python_SYSLIBS = %r python_LDFLAGS = %r python_SHLIBS = %r python_LIBDIR = %r python_LIBPL = %r INCLUDEPY = %r Py_ENABLE_SHARED = %r MACOSX_DEPLOYMENT_TARGET = %r """ % (python, python_prefix, python_SO, python_SYSLIBS, python_LDFLAGS, python_SHLIBS, python_LIBDIR, python_LIBPL, INCLUDEPY, Py_ENABLE_SHARED, python_MACOSX_DEPLOYMENT_TARGET)) if python_MACOSX_DEPLOYMENT_TARGET: conf.env['MACOSX_DEPLOYMENT_TARGET'] = python_MACOSX_DEPLOYMENT_TARGET conf.environ[ 'MACOSX_DEPLOYMENT_TARGET'] = python_MACOSX_DEPLOYMENT_TARGET env['pyext_PATTERN'] = '%s' + python_SO # Check for python libraries for embedding if python_SYSLIBS is not None: for lib in python_SYSLIBS.split(): if lib.startswith('-l'): lib = lib[2:] # strip '-l' env.append_value('LIB_PYEMBED', lib) if python_SHLIBS is not None: for lib in python_SHLIBS.split(): if lib.startswith('-l'): env.append_value('LIB_PYEMBED', lib[2:]) # strip '-l' else: env.append_value('LINKFLAGS_PYEMBED', lib) if Options.platform != 'darwin' and python_LDFLAGS: env.append_value('LINKFLAGS_PYEMBED', python_LDFLAGS.split()) result = False name = 'python' + env['PYTHON_VERSION'] if python_LIBDIR is not None: path = [python_LIBDIR] conf.log.write("\n\n# Trying LIBDIR: %r\n" % path) result = conf.check(lib=name, uselib='PYEMBED', libpath=path) if not result and python_LIBPL is not None: conf.log.write( "\n\n# try again with -L$python_LIBPL (some systems don't install the python library in $prefix/lib)\n" ) path = [python_LIBPL] result = conf.check(lib=name, uselib='PYEMBED', libpath=path) if not result: conf.log.write( "\n\n# try again with -L$prefix/libs, and pythonXY name rather than pythonX.Y (win32)\n" ) path = [os.path.join(python_prefix, "libs")] name = 'python' + env['PYTHON_VERSION'].replace('.', '') result = conf.check(lib=name, uselib='PYEMBED', libpath=path) if result: env['LIBPATH_PYEMBED'] = path env.append_value('LIB_PYEMBED', name) else: conf.log.write("\n\n### LIB NOT FOUND\n") # under certain conditions, python extensions must link to # python libraries, not just python embedding programs. if (sys.platform == 'win32' or sys.platform.startswith('os2') or sys.platform == 'darwin' or Py_ENABLE_SHARED): env['LIBPATH_PYEXT'] = env['LIBPATH_PYEMBED'] env['LIB_PYEXT'] = env['LIB_PYEMBED'] # We check that pythonX.Y-config exists, and if it exists we # use it to get only the includes, else fall back to distutils. python_config = conf.find_program( 'python%s-config' % ('.'.join(env['PYTHON_VERSION'].split('.')[:2])), var='PYTHON_CONFIG') if not python_config: python_config = conf.find_program( 'python-config-%s' % ('.'.join(env['PYTHON_VERSION'].split('.')[:2])), var='PYTHON_CONFIG') includes = [] if python_config: for incstr in Utils.cmd_output("%s --includes" % (python_config, )).strip().split(): # strip the -I or /I if (incstr.startswith('-I') or incstr.startswith('/I')): incstr = incstr[2:] # append include path, unless already given if incstr not in includes: includes.append(incstr) conf.log.write("Include path for Python extensions " "(found via python-config --includes): %r\n" % (includes, )) env['CPPPATH_PYEXT'] = includes env['CPPPATH_PYEMBED'] = includes else: conf.log.write("Include path for Python extensions " "(found via distutils module): %r\n" % (INCLUDEPY, )) env['CPPPATH_PYEXT'] = [INCLUDEPY] env['CPPPATH_PYEMBED'] = [INCLUDEPY] # Code using the Python API needs to be compiled with -fno-strict-aliasing if env['CC_NAME'] == 'gcc': env.append_value('CCFLAGS_PYEMBED', '-fno-strict-aliasing') env.append_value('CCFLAGS_PYEXT', '-fno-strict-aliasing') if env['CXX_NAME'] == 'gcc': env.append_value('CXXFLAGS_PYEMBED', '-fno-strict-aliasing') env.append_value('CXXFLAGS_PYEXT', '-fno-strict-aliasing') # See if it compiles conf.check(define_name='HAVE_PYTHON_H', uselib='PYEMBED', fragment=FRAG_2, errmsg='Could not find the python development headers', mandatory=mandatory)
def check_python_headers(conf, mandatory=True): """Check for headers and libraries necessary to extend or embed python. On success the environment variables xxx_PYEXT and xxx_PYEMBED are added for uselib PYEXT: for compiling python extensions PYEMBED: for embedding a python interpreter""" if not conf.env['CC_NAME'] and not conf.env['CXX_NAME']: conf.fatal('load a compiler first (gcc, g++, ..)') if not conf.env['PYTHON_VERSION']: conf.check_python_version() env = conf.env python = env['PYTHON'] if not python: conf.fatal('could not find the python executable') ## On Mac OSX we need to use mac bundles for python plugins if Options.platform == 'darwin': conf.check_tool('osx') try: # Get some python configuration variables using distutils v = 'prefix SO SYSLIBS LDFLAGS SHLIBS LIBDIR LIBPL INCLUDEPY Py_ENABLE_SHARED MACOSX_DEPLOYMENT_TARGET LDVERSION'.split() (python_prefix, python_SO, python_SYSLIBS, python_LDFLAGS, python_SHLIBS, python_LIBDIR, python_LIBPL, INCLUDEPY, Py_ENABLE_SHARED, python_MACOSX_DEPLOYMENT_TARGET, python_LDVERSION) = \ _get_python_variables(python, ["get_config_var('%s') or ''" % x for x in v], ['from distutils.sysconfig import get_config_var']) except RuntimeError: conf.fatal("Python development headers not found (-v for details).") conf.log.write("""Configuration returned from %r: python_prefix = %r python_SO = %r python_SYSLIBS = %r python_LDFLAGS = %r python_SHLIBS = %r python_LIBDIR = %r python_LIBPL = %r INCLUDEPY = %r Py_ENABLE_SHARED = %r MACOSX_DEPLOYMENT_TARGET = %r LDVERSION = %r """ % (python, python_prefix, python_SO, python_SYSLIBS, python_LDFLAGS, python_SHLIBS, python_LIBDIR, python_LIBPL, INCLUDEPY, Py_ENABLE_SHARED, python_MACOSX_DEPLOYMENT_TARGET, python_LDVERSION)) # Allow some python overrides from env vars for cross-compiling os_env = dict(os.environ) override_python_LDFLAGS = os_env.get('python_LDFLAGS', None) if override_python_LDFLAGS is not None: conf.log.write("python_LDFLAGS override from environment = %r\n" % (override_python_LDFLAGS)) python_LDFLAGS = override_python_LDFLAGS override_python_LIBDIR = os_env.get('python_LIBDIR', None) if override_python_LIBDIR is not None: conf.log.write("python_LIBDIR override from environment = %r\n" % (override_python_LIBDIR)) python_LIBDIR = override_python_LIBDIR if python_MACOSX_DEPLOYMENT_TARGET: conf.env['MACOSX_DEPLOYMENT_TARGET'] = python_MACOSX_DEPLOYMENT_TARGET conf.environ['MACOSX_DEPLOYMENT_TARGET'] = python_MACOSX_DEPLOYMENT_TARGET env['pyext_PATTERN'] = '%s'+python_SO # Check for python libraries for embedding if python_SYSLIBS is not None: for lib in python_SYSLIBS.split(): if lib.startswith('-l'): lib = lib[2:] # strip '-l' env.append_value('LIB_PYEMBED', lib) if python_SHLIBS is not None: for lib in python_SHLIBS.split(): if lib.startswith('-l'): env.append_value('LIB_PYEMBED', lib[2:]) # strip '-l' else: env.append_value('LINKFLAGS_PYEMBED', lib) if Options.platform != 'darwin' and python_LDFLAGS: parse_flags(python_LDFLAGS, 'PYEMBED', env) result = False if not python_LDVERSION: python_LDVERSION = env['PYTHON_VERSION'] name = 'python' + python_LDVERSION if python_LIBDIR is not None: path = [python_LIBDIR] conf.log.write("\n\n# Trying LIBDIR: %r\n" % path) result = conf.check(lib=name, uselib='PYEMBED', libpath=path) if not result and python_LIBPL is not None: conf.log.write("\n\n# try again with -L$python_LIBPL (some systems don't install the python library in $prefix/lib)\n") path = [python_LIBPL] result = conf.check(lib=name, uselib='PYEMBED', libpath=path) if not result: conf.log.write("\n\n# try again with -L$prefix/libs, and pythonXY name rather than pythonX.Y (win32)\n") path = [os.path.join(python_prefix, "libs")] name = 'python' + python_LDVERSION.replace('.', '') result = conf.check(lib=name, uselib='PYEMBED', libpath=path) if result: env['LIBPATH_PYEMBED'] = path env.append_value('LIB_PYEMBED', name) else: conf.log.write("\n\n### LIB NOT FOUND\n") # under certain conditions, python extensions must link to # python libraries, not just python embedding programs. if (sys.platform == 'win32' or sys.platform.startswith('os2') or sys.platform == 'darwin' or Py_ENABLE_SHARED): env['LIBPATH_PYEXT'] = env['LIBPATH_PYEMBED'] env['LIB_PYEXT'] = env['LIB_PYEMBED'] # We check that pythonX.Y-config exists, and if it exists we # use it to get only the includes, else fall back to distutils. python_config = conf.find_program( 'python%s-config' % ('.'.join(env['PYTHON_VERSION'].split('.')[:2])), var='PYTHON_CONFIG') if not python_config: python_config = conf.find_program( 'python-config-%s' % ('.'.join(env['PYTHON_VERSION'].split('.')[:2])), var='PYTHON_CONFIG') includes = [] if python_config: for incstr in Utils.cmd_output("%s --includes" % (python_config,)).strip().split(): # strip the -I or /I if (incstr.startswith('-I') or incstr.startswith('/I')): incstr = incstr[2:] # append include path, unless already given if incstr not in includes: includes.append(incstr) conf.log.write("Include path for Python extensions " "(found via python-config --includes): %r\n" % (includes,)) env['CPPPATH_PYEXT'] = includes env['CPPPATH_PYEMBED'] = includes else: conf.log.write("Include path for Python extensions " "(found via distutils module): %r\n" % (INCLUDEPY,)) env['CPPPATH_PYEXT'] = [INCLUDEPY] env['CPPPATH_PYEMBED'] = [INCLUDEPY] # Code using the Python API needs to be compiled with -fno-strict-aliasing if env['CC_NAME'] == 'gcc': env.append_value('CCFLAGS_PYEMBED', '-fno-strict-aliasing') env.append_value('CCFLAGS_PYEXT', '-fno-strict-aliasing') if env['CXX_NAME'] == 'gcc': env.append_value('CXXFLAGS_PYEMBED', '-fno-strict-aliasing') env.append_value('CXXFLAGS_PYEXT', '-fno-strict-aliasing') # See if it compiles conf.check(define_name='HAVE_PYTHON_H', uselib='PYEMBED', fragment=FRAG_2, errmsg='Could not find the python development headers', mandatory=mandatory)
def check_python_headers(conf): """Check for headers and libraries necessary to extend or embed python. If successful, xxx_PYEXT and xxx_PYEMBED variables are defined in the environment (for uselib). PYEXT should be used for compiling python extensions, while PYEMBED should be used by programs that need to embed a python interpreter. Note: this test requires that check_python_version was previously executed and successful.""" env = conf.env python = env['PYTHON'] assert python, ("python is %r !" % (python,)) ## On Mac OSX we need to use mac bundles for python plugins if Options.platform == 'darwin': conf.check_tool('osx') try: # Get some python configuration variables using distutils v = 'prefix SO SYSLIBS LDFLAGS SHLIBS LIBDIR LIBPL INCLUDEPY Py_ENABLE_SHARED'.split() (python_prefix, python_SO, python_SYSLIBS, python_LDFLAGS, python_SHLIBS, python_LIBDIR, python_LIBPL, INCLUDEPY, Py_ENABLE_SHARED) = \ _get_python_variables(python, ["get_config_var('%s')" % x for x in v], ['from distutils.sysconfig import get_config_var']) except ValueError: conf.fatal("Python development headers not found (-v for details).") conf.log.write("""Configuration returned from %r: python_prefix = %r python_SO = %r python_SYSLIBS = %r python_LDFLAGS = %r python_SHLIBS = %r python_LIBDIR = %r python_LIBPL = %r INCLUDEPY = %r Py_ENABLE_SHARED = %r """ % (python, python_prefix, python_SO, python_SYSLIBS, python_LDFLAGS, python_SHLIBS, python_LIBDIR, python_LIBPL, INCLUDEPY, Py_ENABLE_SHARED)) env['pyext_PATTERN'] = '%s'+python_SO # Check for python libraries for embedding if python_SYSLIBS is not None: for lib in python_SYSLIBS.split(): if lib.startswith('-l'): lib = lib[2:] # strip '-l' env.append_value('LIB_PYEMBED', lib) if python_SHLIBS is not None: for lib in python_SHLIBS.split(): if lib.startswith('-l'): lib = lib[2:] # strip '-l' env.append_value('LIB_PYEMBED', lib) env.append_value('LINKFLAGS_PYEMBED', python_LDFLAGS) code = ''' #ifdef __cplusplus extern "C" { #endif void Py_Initialize(void); void Py_Finalize(void); #ifdef __cplusplus } #endif int main(int argc, char *argv[]) { Py_Initialize(); Py_Finalize(); return 0; } ''' result = False name = 'python' + env['PYTHON_VERSION'] if python_LIBDIR is not None: path = [python_LIBDIR] result = conf.check(lib=name, uselib='PYEMBED', libpath=path) # try again with -L$python_LIBPL (some systems don't install the python library in $prefix/lib) if not result and python_LIBPL is not None: path = [python_LIBPL] result = conf.check(lib=name, uselib='PYEMBED', libpath=path) # try again with -L$prefix/libs, and pythonXY name rather than pythonX.Y (win32) if not result: path = [os.path.join(python_prefix, "libs")] name = 'python' + env['PYTHON_VERSION'].replace('.', '') result = conf.check(lib=name, uselib='PYEMBED', libpath=path) if result: env['LIBPATH_PYEMBED'] = path env.append_value('LIB_PYEMBED', name) # under certain conditions, python extensions must link to # python libraries, not just python embedding programs. if (sys.platform == 'win32' or sys.platform.startswith('os2') or sys.platform == 'darwin' or Py_ENABLE_SHARED): env['LIBPATH_PYEXT'] = env['LIBPATH_PYEMBED'] env['LIB_PYEXT'] = env['LIB_PYEMBED'] # We check that pythonX.Y-config exists, and if it exists we # use it to get only the includes, else fall back to distutils. python_config = conf.find_program( 'python%s-config' % ('.'.join(env['PYTHON_VERSION'].split('.')[:2])), var='PYTHON_CONFIG') if not python_config: python_config = conf.find_program( 'python-config-%s' % ('.'.join(env['PYTHON_VERSION'].split('.')[:2])), var='PYTHON_CONFIG') includes = [] if python_config: for incstr in os.popen("%s %s --includes" % (python, python_config)).readline().strip().split(): # strip the -I or /I if (incstr.startswith('-I') or incstr.startswith('/I')): incstr = incstr[2:] # append include path, unless already given if incstr not in includes: includes.append(incstr) conf.log.write("Include path for Python extensions " "(found via python-config --includes): %r\n" % (includes,)) env['CPPPATH_PYEXT'] = includes env['CPPPATH_PYEMBED'] = includes else: conf.log.write("Include path for Python extensions " "(found via distutils module): %r\n" % (INCLUDEPY,)) env['CPPPATH_PYEXT'] = [INCLUDEPY] env['CPPPATH_PYEMBED'] = [INCLUDEPY] # Code using the Python API needs to be compiled with -fno-strict-aliasing if env['CC']: version = os.popen("%s --version" % env['CC']).readline() if '(GCC)' in version or 'gcc' in version: env.append_value('CCFLAGS_PYEMBED', '-fno-strict-aliasing') env.append_value('CCFLAGS_PYEXT', '-fno-strict-aliasing') if env['CXX']: version = os.popen("%s --version" % env['CXX']).readline() if '(GCC)' in version or 'g++' in version: env.append_value('CXXFLAGS_PYEMBED', '-fno-strict-aliasing') env.append_value('CXXFLAGS_PYEXT', '-fno-strict-aliasing') # See if it compiles test_env = env.copy() test_env.append_value('CPPPATH', env['CPPPATH_PYEMBED']) test_env.append_value('LIBPATH', env['LIBPATH_PYEMBED']) test_env.append_value('LIB', env['LIB_PYEMBED']) test_env.append_value('LINKFLAGS', env['LINKFLAGS_PYEMBED']) test_env.append_value('CXXFLAGS', env['CXXFLAGS_PYEMBED']) test_env.append_value('CCFLAGS', env['CCFLAGS_PYEMBED']) conf.check(header_name='Python.h', define_name='HAVE_PYTHON_H', env=test_env, fragment='''#include <Python.h>\nint main(int argc, char *argv[]) { Py_Initialize(); Py_Finalize(); return 0; }\n''', errmsg='Could not find the python development headers', mandatory=1)
def check_python_headers(conf): if not conf.env['CC_NAME'] and not conf.env['CXX_NAME']: conf.fatal('load a compiler first (gcc, g++, ..)') if not conf.env['PYTHON_VERSION']: conf.check_python_version() env = conf.env python = env['PYTHON'] if not python: conf.fatal('could not find the python executable') if Options.platform == 'darwin': conf.check_tool('osx') try: v = 'prefix SO SYSLIBS LDFLAGS SHLIBS LIBDIR LIBPL INCLUDEPY Py_ENABLE_SHARED MACOSX_DEPLOYMENT_TARGET'.split( ) (python_prefix, python_SO, python_SYSLIBS, python_LDFLAGS, python_SHLIBS, python_LIBDIR, python_LIBPL, INCLUDEPY, Py_ENABLE_SHARED, python_MACOSX_DEPLOYMENT_TARGET) = _get_python_variables( python, ["get_config_var('%s')" % x for x in v], ['from distutils.sysconfig import get_config_var']) except RuntimeError: conf.fatal("Python development headers not found (-v for details).") conf.log.write("""Configuration returned from %r: python_prefix = %r python_SO = %r python_SYSLIBS = %r python_LDFLAGS = %r python_SHLIBS = %r python_LIBDIR = %r python_LIBPL = %r INCLUDEPY = %r Py_ENABLE_SHARED = %r MACOSX_DEPLOYMENT_TARGET = %r """ % (python, python_prefix, python_SO, python_SYSLIBS, python_LDFLAGS, python_SHLIBS, python_LIBDIR, python_LIBPL, INCLUDEPY, Py_ENABLE_SHARED, python_MACOSX_DEPLOYMENT_TARGET)) if python_MACOSX_DEPLOYMENT_TARGET: conf.env['MACOSX_DEPLOYMENT_TARGET'] = python_MACOSX_DEPLOYMENT_TARGET conf.environ[ 'MACOSX_DEPLOYMENT_TARGET'] = python_MACOSX_DEPLOYMENT_TARGET env['pyext_PATTERN'] = '%s' + python_SO if python_SYSLIBS is not None: for lib in python_SYSLIBS.split(): if lib.startswith('-l'): lib = lib[2:] env.append_value('LIB_PYEMBED', lib) if python_SHLIBS is not None: for lib in python_SHLIBS.split(): if lib.startswith('-l'): env.append_value('LIB_PYEMBED', lib[2:]) else: env.append_value('LINKFLAGS_PYEMBED', lib) if Options.platform != 'darwin' and python_LDFLAGS: env.append_value('LINKFLAGS_PYEMBED', python_LDFLAGS.split()) result = False name = 'python' + env['PYTHON_VERSION'] if python_LIBDIR is not None: path = [python_LIBDIR] conf.log.write("\n\n# Trying LIBDIR: %r\n" % path) result = conf.check(lib=name, uselib='PYEMBED', libpath=path) if not result and python_LIBPL is not None: conf.log.write( "\n\n# try again with -L$python_LIBPL (some systems don't install the python library in $prefix/lib)\n" ) path = [python_LIBPL] result = conf.check(lib=name, uselib='PYEMBED', libpath=path) if not result: conf.log.write( "\n\n# try again with -L$prefix/libs, and pythonXY name rather than pythonX.Y (win32)\n" ) path = [os.path.join(python_prefix, "libs")] name = 'python' + env['PYTHON_VERSION'].replace('.', '') result = conf.check(lib=name, uselib='PYEMBED', libpath=path) if result: env['LIBPATH_PYEMBED'] = path env.append_value('LIB_PYEMBED', name) else: conf.log.write("\n\n### LIB NOT FOUND\n") if (sys.platform == 'win32' or sys.platform.startswith('os2') or sys.platform == 'darwin' or Py_ENABLE_SHARED): env['LIBPATH_PYEXT'] = env['LIBPATH_PYEMBED'] env['LIB_PYEXT'] = env['LIB_PYEMBED'] python_config = conf.find_program( 'python%s-config' % ('.'.join(env['PYTHON_VERSION'].split('.')[:2])), var='PYTHON_CONFIG') if not python_config: python_config = conf.find_program( 'python-config-%s' % ('.'.join(env['PYTHON_VERSION'].split('.')[:2])), var='PYTHON_CONFIG') includes = [] if python_config: for incstr in Utils.cmd_output( "%s %s --includes" % (python, python_config)).strip().split(): if (incstr.startswith('-I') or incstr.startswith('/I')): incstr = incstr[2:] if incstr not in includes: includes.append(incstr) conf.log.write("Include path for Python extensions " "(found via python-config --includes): %r\n" % (includes, )) env['CPPPATH_PYEXT'] = includes env['CPPPATH_PYEMBED'] = includes else: conf.log.write("Include path for Python extensions " "(found via distutils module): %r\n" % (INCLUDEPY, )) env['CPPPATH_PYEXT'] = [INCLUDEPY] env['CPPPATH_PYEMBED'] = [INCLUDEPY] if env['CC_NAME'] == 'gcc': env.append_value('CCFLAGS_PYEMBED', '-fno-strict-aliasing') env.append_value('CCFLAGS_PYEXT', '-fno-strict-aliasing') if env['CXX_NAME'] == 'gcc': env.append_value('CXXFLAGS_PYEMBED', '-fno-strict-aliasing') env.append_value('CXXFLAGS_PYEXT', '-fno-strict-aliasing') conf.check(header_name='Python.h', define_name='HAVE_PYTHON_H', uselib='PYEMBED', fragment=FRAG_2, errmsg='Could not find the python development headers', mandatory=1)
def cxx_load_tools(conf): conf.check_tool('cxx')
def check_python_headers(conf, mandatory=True): if not conf.env["CC_NAME"] and not conf.env["CXX_NAME"]: conf.fatal("load a compiler first (gcc, g++, ..)") if not conf.env["PYTHON_VERSION"]: conf.check_python_version() env = conf.env python = env["PYTHON"] if not python: conf.fatal("could not find the python executable") if Options.platform == "darwin": conf.check_tool("osx") try: v = "prefix SO SYSLIBS LDFLAGS SHLIBS LIBDIR LIBPL INCLUDEPY Py_ENABLE_SHARED MACOSX_DEPLOYMENT_TARGET".split() ( python_prefix, python_SO, python_SYSLIBS, python_LDFLAGS, python_SHLIBS, python_LIBDIR, python_LIBPL, INCLUDEPY, Py_ENABLE_SHARED, python_MACOSX_DEPLOYMENT_TARGET, ) = _get_python_variables( python, ["get_config_var('%s')" % x for x in v], ["from distutils.sysconfig import get_config_var"] ) except RuntimeError: conf.fatal("Python development headers not found (-v for details).") conf.log.write( """Configuration returned from %r: python_prefix = %r python_SO = %r python_SYSLIBS = %r python_LDFLAGS = %r python_SHLIBS = %r python_LIBDIR = %r python_LIBPL = %r INCLUDEPY = %r Py_ENABLE_SHARED = %r MACOSX_DEPLOYMENT_TARGET = %r """ % ( python, python_prefix, python_SO, python_SYSLIBS, python_LDFLAGS, python_SHLIBS, python_LIBDIR, python_LIBPL, INCLUDEPY, Py_ENABLE_SHARED, python_MACOSX_DEPLOYMENT_TARGET, ) ) if python_MACOSX_DEPLOYMENT_TARGET: conf.env["MACOSX_DEPLOYMENT_TARGET"] = python_MACOSX_DEPLOYMENT_TARGET conf.environ["MACOSX_DEPLOYMENT_TARGET"] = python_MACOSX_DEPLOYMENT_TARGET env["pyext_PATTERN"] = "%s" + python_SO if python_SYSLIBS is not None: for lib in python_SYSLIBS.split(): if lib.startswith("-l"): lib = lib[2:] env.append_value("LIB_PYEMBED", lib) if python_SHLIBS is not None: for lib in python_SHLIBS.split(): if lib.startswith("-l"): env.append_value("LIB_PYEMBED", lib[2:]) else: env.append_value("LINKFLAGS_PYEMBED", lib) if Options.platform != "darwin" and python_LDFLAGS: env.append_value("LINKFLAGS_PYEMBED", python_LDFLAGS.split()) result = False name = "python" + env["PYTHON_VERSION"] if python_LIBDIR is not None: path = [python_LIBDIR] conf.log.write("\n\n# Trying LIBDIR: %r\n" % path) result = conf.check(lib=name, uselib="PYEMBED", libpath=path) if not result and python_LIBPL is not None: conf.log.write( "\n\n# try again with -L$python_LIBPL (some systems don't install the python library in $prefix/lib)\n" ) path = [python_LIBPL] result = conf.check(lib=name, uselib="PYEMBED", libpath=path) if not result: conf.log.write("\n\n# try again with -L$prefix/libs, and pythonXY name rather than pythonX.Y (win32)\n") path = [os.path.join(python_prefix, "libs")] name = "python" + env["PYTHON_VERSION"].replace(".", "") result = conf.check(lib=name, uselib="PYEMBED", libpath=path) if result: env["LIBPATH_PYEMBED"] = path env.append_value("LIB_PYEMBED", name) else: conf.log.write("\n\n### LIB NOT FOUND\n") if sys.platform == "win32" or sys.platform.startswith("os2") or sys.platform == "darwin" or Py_ENABLE_SHARED: env["LIBPATH_PYEXT"] = env["LIBPATH_PYEMBED"] env["LIB_PYEXT"] = env["LIB_PYEMBED"] python_config = conf.find_program( "python%s-config" % (".".join(env["PYTHON_VERSION"].split(".")[:2])), var="PYTHON_CONFIG" ) if not python_config: python_config = conf.find_program( "python-config-%s" % (".".join(env["PYTHON_VERSION"].split(".")[:2])), var="PYTHON_CONFIG" ) includes = [] if python_config: for incstr in Utils.cmd_output("%s %s --includes" % (python, python_config)).strip().split(): if incstr.startswith("-I") or incstr.startswith("/I"): incstr = incstr[2:] if incstr not in includes: includes.append(incstr) conf.log.write("Include path for Python extensions " "(found via python-config --includes): %r\n" % (includes,)) env["CPPPATH_PYEXT"] = includes env["CPPPATH_PYEMBED"] = includes else: conf.log.write("Include path for Python extensions " "(found via distutils module): %r\n" % (INCLUDEPY,)) env["CPPPATH_PYEXT"] = [INCLUDEPY] env["CPPPATH_PYEMBED"] = [INCLUDEPY] if env["CC_NAME"] == "gcc": env.append_value("CCFLAGS_PYEMBED", "-fno-strict-aliasing") env.append_value("CCFLAGS_PYEXT", "-fno-strict-aliasing") if env["CXX_NAME"] == "gcc": env.append_value("CXXFLAGS_PYEMBED", "-fno-strict-aliasing") env.append_value("CXXFLAGS_PYEXT", "-fno-strict-aliasing") conf.check( define_name="HAVE_PYTHON_H", uselib="PYEMBED", fragment=FRAG_2, errmsg="Could not find the python development headers", mandatory=mandatory, )
def find_msvc(conf): # due to path format limitations, limit operation only to native Win32. Yeah it sucks. if sys.platform != "win32": conf.fatal("MSVC module only works under native Win32 Python! cygwin is not supported yet") v = conf.env compiler, path, includes, libdirs = detect_msvc(conf) v["PATH"] = path v["CPPPATH"] = includes v["LIBPATH"] = libdirs compiler_name, linker_name, lib_name = _get_prog_names(conf, compiler) # compiler cxx = None if v["CXX"]: cxx = v["CXX"] elif "CXX" in conf.environ: cxx = conf.environ["CXX"] if not cxx: cxx = conf.find_program(compiler_name, var="CXX", path_list=path) if not cxx: conf.fatal("%s was not found (compiler)" % compiler_name) cxx = conf.cmd_to_list(cxx) # before setting anything, check if the compiler is really msvc env = dict(conf.environ) env.update(PATH=";".join(path)) if not Utils.cmd_output([cxx, "/nologo", "/?"], silent=True, env=env): conf.fatal("the msvc compiler could not be identified") # c/c++ compiler v["CC"] = v["CXX"] = cxx v["CC_NAME"] = v["CXX_NAME"] = "msvc" # environment flags try: v.prepend_value("CPPPATH", conf.environ["INCLUDE"]) except KeyError: pass try: v.prepend_value("LIBPATH", conf.environ["LIB"]) except KeyError: pass # linker if not v["LINK_CXX"]: link = conf.find_program(linker_name, path_list=path) if link: v["LINK_CXX"] = link else: conf.fatal("%s was not found (linker)" % linker_name) v["LINK"] = link if not v["LINK_CC"]: v["LINK_CC"] = v["LINK_CXX"] # staticlib linker if not v["AR"]: stliblink = conf.find_program(lib_name, path_list=path) if not stliblink: return v["AR"] = stliblink v["ARFLAGS"] = ["/NOLOGO"] # manifest tool. Not required for VS 2003 and below. Must have for VS 2005 and later manifesttool = conf.find_program("MT", path_list=path) if manifesttool: v["MT"] = manifesttool v["MTFLAGS"] = ["/NOLOGO"] conf.check_tool("winres") if not conf.env["WINRC"]: warn("Resource compiler not found. Compiling resource file is disabled")
def cc_load_tools(conf): conf.check_tool("cc")
def find_msvc(conf): # due to path format limitations, limit operation only to native Win32. Yeah it sucks. if sys.platform != 'win32': conf.fatal('MSVC module only works under native Win32 Python! cygwin is not supported yet') v = conf.env compiler, path, includes, libdirs = detect_msvc(conf) v['PATH'] = path v['CPPPATH'] = includes v['LIBPATH'] = libdirs compiler_name, linker_name, lib_name = _get_prog_names(conf, compiler) # compiler cxx = None if v['CXX']: cxx = v['CXX'] elif 'CXX' in conf.environ: cxx = conf.environ['CXX'] if not cxx: cxx = conf.find_program(compiler_name, var='CXX', path_list=path) if not cxx: conf.fatal('%s was not found (compiler)' % compiler_name) cxx = conf.cmd_to_list(cxx) # before setting anything, check if the compiler is really msvc env = dict(conf.environ) env.update(PATH = ';'.join(path)) if not Utils.cmd_output([cxx, '/nologo', '/?'], silent=True, env=env): conf.fatal('the msvc compiler could not be identified') # c/c++ compiler v['CC'] = v['CXX'] = cxx v['CC_NAME'] = v['CXX_NAME'] = 'msvc' # environment flags try: v.prepend_value('CPPPATH', conf.environ['INCLUDE']) except KeyError: pass try: v.prepend_value('LIBPATH', conf.environ['LIB']) except KeyError: pass # linker if not v['LINK_CXX']: link = conf.find_program(linker_name, path_list=path) if link: v['LINK_CXX'] = link else: conf.fatal('%s was not found (linker)' % linker_name) v['LINK'] = link if not v['LINK_CC']: v['LINK_CC'] = v['LINK_CXX'] # staticlib linker if not v['AR']: stliblink = conf.find_program(lib_name, path_list=path) if not stliblink: return v['AR'] = stliblink v['ARFLAGS'] = ['/NOLOGO'] # manifest tool. Not required for VS 2003 and below. Must have for VS 2005 and later manifesttool = conf.find_program('MT', path_list=path) if manifesttool: v['MT'] = manifesttool v['MTFLAGS'] = ['/NOLOGO'] conf.check_tool('winres') if not conf.env['WINRC']: warn('Resource compiler not found. Compiling resource file is disabled')
def check_python_headers(conf,mandatory=True): if not conf.env['CC_NAME']and not conf.env['CXX_NAME']: conf.fatal('load a compiler first (gcc, g++, ..)') if not conf.env['PYTHON_VERSION']: conf.check_python_version() env=conf.env python=env['PYTHON'] if not python: conf.fatal('could not find the python executable') if Options.platform=='darwin': conf.check_tool('osx') try: v='prefix SO SYSLIBS LDFLAGS SHLIBS LIBDIR LIBPL INCLUDEPY Py_ENABLE_SHARED MACOSX_DEPLOYMENT_TARGET'.split() (python_prefix,python_SO,python_SYSLIBS,python_LDFLAGS,python_SHLIBS,python_LIBDIR,python_LIBPL,INCLUDEPY,Py_ENABLE_SHARED,python_MACOSX_DEPLOYMENT_TARGET)=_get_python_variables(python,["get_config_var('%s')"%x for x in v],['from distutils.sysconfig import get_config_var']) except RuntimeError: conf.fatal("Python development headers not found (-v for details).") conf.log.write("""Configuration returned from %r: python_prefix = %r python_SO = %r python_SYSLIBS = %r python_LDFLAGS = %r python_SHLIBS = %r python_LIBDIR = %r python_LIBPL = %r INCLUDEPY = %r Py_ENABLE_SHARED = %r MACOSX_DEPLOYMENT_TARGET = %r """%(python,python_prefix,python_SO,python_SYSLIBS,python_LDFLAGS,python_SHLIBS,python_LIBDIR,python_LIBPL,INCLUDEPY,Py_ENABLE_SHARED,python_MACOSX_DEPLOYMENT_TARGET)) if python_MACOSX_DEPLOYMENT_TARGET: conf.env['MACOSX_DEPLOYMENT_TARGET']=python_MACOSX_DEPLOYMENT_TARGET conf.environ['MACOSX_DEPLOYMENT_TARGET']=python_MACOSX_DEPLOYMENT_TARGET env['pyext_PATTERN']='%s'+python_SO if python_SYSLIBS is not None: for lib in python_SYSLIBS.split(): if lib.startswith('-l'): lib=lib[2:] env.append_value('LIB_PYEMBED',lib) if python_SHLIBS is not None: for lib in python_SHLIBS.split(): if lib.startswith('-l'): env.append_value('LIB_PYEMBED',lib[2:]) else: env.append_value('LINKFLAGS_PYEMBED',lib) if Options.platform!='darwin'and python_LDFLAGS: env.append_value('LINKFLAGS_PYEMBED',python_LDFLAGS.split()) result=False name='python'+env['PYTHON_VERSION'] if python_LIBDIR is not None: path=[python_LIBDIR] conf.log.write("\n\n# Trying LIBDIR: %r\n"%path) result=conf.check(lib=name,uselib='PYEMBED',libpath=path) if not result and python_LIBPL is not None: conf.log.write("\n\n# try again with -L$python_LIBPL (some systems don't install the python library in $prefix/lib)\n") path=[python_LIBPL] result=conf.check(lib=name,uselib='PYEMBED',libpath=path) if not result: conf.log.write("\n\n# try again with -L$prefix/libs, and pythonXY name rather than pythonX.Y (win32)\n") path=[os.path.join(python_prefix,"libs")] name='python'+env['PYTHON_VERSION'].replace('.','') result=conf.check(lib=name,uselib='PYEMBED',libpath=path) if result: env['LIBPATH_PYEMBED']=path env.append_value('LIB_PYEMBED',name) else: conf.log.write("\n\n### LIB NOT FOUND\n") if(sys.platform=='win32'or sys.platform.startswith('os2')or sys.platform=='darwin'or Py_ENABLE_SHARED): env['LIBPATH_PYEXT']=env['LIBPATH_PYEMBED'] env['LIB_PYEXT']=env['LIB_PYEMBED'] python_config=conf.find_program('python%s-config'%('.'.join(env['PYTHON_VERSION'].split('.')[:2])),var='PYTHON_CONFIG') if not python_config: python_config=conf.find_program('python-config-%s'%('.'.join(env['PYTHON_VERSION'].split('.')[:2])),var='PYTHON_CONFIG') includes=[] if python_config: for incstr in Utils.cmd_output("%s %s --includes"%(python,python_config)).strip().split(): if(incstr.startswith('-I')or incstr.startswith('/I')): incstr=incstr[2:] if incstr not in includes: includes.append(incstr) conf.log.write("Include path for Python extensions ""(found via python-config --includes): %r\n"%(includes,)) env['CPPPATH_PYEXT']=includes env['CPPPATH_PYEMBED']=includes else: conf.log.write("Include path for Python extensions ""(found via distutils module): %r\n"%(INCLUDEPY,)) env['CPPPATH_PYEXT']=[INCLUDEPY] env['CPPPATH_PYEMBED']=[INCLUDEPY] if env['CC_NAME']=='gcc': env.append_value('CCFLAGS_PYEMBED','-fno-strict-aliasing') env.append_value('CCFLAGS_PYEXT','-fno-strict-aliasing') if env['CXX_NAME']=='gcc': env.append_value('CXXFLAGS_PYEMBED','-fno-strict-aliasing') env.append_value('CXXFLAGS_PYEXT','-fno-strict-aliasing') conf.check(define_name='HAVE_PYTHON_H',uselib='PYEMBED',fragment=FRAG_2,errmsg='Could not find the python development headers',mandatory=mandatory)
def check_python_headers(conf): env=conf.env python=env['PYTHON'] assert python,("python is %r !"%(python,)) if Options.platform=='darwin': conf.check_tool('osx') try: v='prefix SO SYSLIBS SHLIBS LIBDIR LIBPL INCLUDEPY Py_ENABLE_SHARED'.split() (python_prefix,python_SO,python_SYSLIBS,python_SHLIBS,python_LIBDIR,python_LIBPL,INCLUDEPY,Py_ENABLE_SHARED)=_get_python_variables(python,["get_config_var('%s')"%x for x in v],['from distutils.sysconfig import get_config_var']) except ValueError: conf.fatal("Python development headers not found (-v for details).") conf.log.write("""Configuration returned from %r: python_prefix = %r python_SO = %r python_SYSLIBS = %r python_SHLIBS = %r python_LIBDIR = %r python_LIBPL = %r INCLUDEPY = %r Py_ENABLE_SHARED = %r """%(python,python_prefix,python_SO,python_SYSLIBS,python_SHLIBS,python_LIBDIR,python_LIBPL,INCLUDEPY,Py_ENABLE_SHARED)) env['pyext_PATTERN']='%s'+python_SO if python_SYSLIBS is not None: for lib in python_SYSLIBS.split(): if lib.startswith('-l'): lib=lib[2:] env.append_value('LIB_PYEMBED',lib) if python_SHLIBS is not None: for lib in python_SHLIBS.split(): if lib.startswith('-l'): lib=lib[2:] env.append_value('LIB_PYEMBED',lib) code=''' #ifdef __cplusplus extern "C" { #endif void Py_Initialize(void); void Py_Finalize(void); #ifdef __cplusplus } #endif int main(int argc, char *argv[]) { Py_Initialize(); Py_Finalize(); return 0; } ''' result=1 name='python'+env['PYTHON_VERSION'] if python_LIBDIR is not None: path=[python_LIBDIR] result=conf.check_cc(lib=name,uselib='PYEMBED',libpath=path) if result and python_LIBPL is not None: path=[python_LIBPL] result=conf.check_cc(lib=name,uselib='PYEMBED',libpath=path) if result: path=[os.path.join(python_prefix,"libs")] name='python'+env['PYTHON_VERSION'].replace('.','') result=conf.check_cc(lib=name,uselib='PYEMBED',libpath=path) if not result: env['LIBPATH_PYEMBED']=path env.append_value('LIB_PYEMBED',name) if(sys.platform=='win32'or sys.platform.startswith('os2')or sys.platform=='darwin'or Py_ENABLE_SHARED): env['LIBPATH_PYEXT']=env['LIBPATH_PYEMBED'] env['LIB_PYEXT']=env['LIB_PYEMBED'] python_config=conf.find_program('python%s-config'%('.'.join(env['PYTHON_VERSION'].split('.')[:2])),var='PYTHON_CONFIG') if python_config: includes=[] for incstr in os.popen("%s %s --includes"%(python,python_config)).readline().strip().split(): if(incstr.startswith('-I')or incstr.startswith('/I')): incstr=incstr[2:] if incstr not in includes: includes.append(incstr) conf.log.write("Include path for Python extensions ""(found via python-config --includes): %r\n"%(list(includes),)) env['CPPPATH_PYEXT']=list(includes) env['CPPPATH_PYEMBED']=list(includes) else: conf.log.write("Include path for Python extensions ""(found via distutils module): %r\n"%(list(includes),)) env['CPPPATH_PYEXT']=[INCLUDEPY] env['CPPPATH_PYEMBED']=[INCLUDEPY] if env['CC']: version=os.popen("%s --version"%env['CC']).readline() if'(GCC)'in version or'gcc'in version: env.append_value('CCFLAGS_PYEMBED','-fno-strict-aliasing') env.append_value('CCFLAGS_PYEXT','-fno-strict-aliasing') if env['CXX']: version=os.popen("%s --version"%env['CXX']).readline() if'(GCC)'in version or'g++'in version: env.append_value('CXXFLAGS_PYEMBED','-fno-strict-aliasing') env.append_value('CXXFLAGS_PYEXT','-fno-strict-aliasing') test_env=env.copy() test_env.append_value('CPPPATH',env['CPPPATH_PYEMBED']) test_env.append_value('LIBPATH',env['LIBPATH_PYEMBED']) test_env.append_value('LIB',env['LIB_PYEMBED']) test_env.append_value('CXXFLAGS',env['CXXFLAGS_PYEMBED']) test_env.append_value('CCFLAGS',env['CCFLAGS_PYEMBED']) conf.check_cc(header_name='Python.h',define_name='HAVE_PYTHON_H',env=test_env,fragment='''#include <Python.h>\nint main(int argc, char *argv[]) { Py_Initialize(); Py_Finalize(); return 0; }\n''',errmsg='Could not find the python development headers',mandatory=1)