2
0
mirror of https://gitlab.com/ita1024/waf.git synced 2024-11-22 09:57:15 +01:00

Issue 1538 - make detection of pyembed optional

This commit is contained in:
Thomas Nagy 2015-02-27 12:03:53 +01:00
parent fa139c5d09
commit 47a100480f
No known key found for this signature in database
GPG Key ID: 67A565EDFDF90E64
2 changed files with 16 additions and 13 deletions

View File

@ -321,7 +321,7 @@ def exec_cfg(self, kw):
for key, val in defi.items():
lst.append('--define-variable=%s=%s' % (key, val))
static = False
static = kw.get('force_static', False)
if 'args' in kw:
args = Utils.to_list(kw['args'])
if '--static' in args or '--static-libs' in args:

View File

@ -223,7 +223,7 @@ def get_python_variables(self, variables, imports=None):
return return_values
@conf
def check_python_headers(conf):
def check_python_headers(conf, features='pyembed pyext'):
"""
Check for headers and libraries necessary to extend or embed python by using the module *distutils*.
On success the environment variables xxx_PYEXT and xxx_PYEMBED are added:
@ -231,6 +231,7 @@ def check_python_headers(conf):
* PYEXT: for compiling python extensions
* PYEMBED: for embedding a python interpreter
"""
assert ('pyembed' in features) or ('pyext' in features), "check_python_headers features must include 'pyembed' and/or 'pyext'"
env = conf.env
if not env['CC_NAME'] and not env['CXX_NAME']:
conf.fatal('load a compiler first (gcc, g++, ..)')
@ -264,25 +265,27 @@ def check_python_headers(conf):
conf.find_program([''.join(pybin) + '-config', 'python%s-config' % num, 'python-config-%s' % num, 'python%sm-config' % num], var='PYTHON_CONFIG', msg="python-config", mandatory=False)
if env.PYTHON_CONFIG:
# python2.5-config requires 3 runs
# python2.6-config requires 3 runs
all_flags = [['--cflags', '--libs', '--ldflags']]
if sys.hexversion < 0x2060000:
if sys.hexversion < 0x2070000:
all_flags = [[k] for k in all_flags[0]]
xx = env.CXX_NAME and 'cxx' or 'c'
for flags in all_flags:
conf.check_cfg(msg='Asking python-config for pyembed %r flags' % ' '.join(flags), path=env.PYTHON_CONFIG, package='', uselib_store='PYEMBED', args=flags)
if 'pyembed' in features:
for flags in all_flags:
conf.check_cfg(msg='Asking python-config for pyembed %r flags' % ' '.join(flags), path=env.PYTHON_CONFIG, package='', uselib_store='PYEMBED', args=flags)
conf.check(header_name='Python.h', define_name='HAVE_PYEMBED', msg='Getting pyembed flags from python-config',
fragment=FRAG, errmsg='Could not build a python embedded interpreter',
features='%s %sprogram pyembed' % (xx, xx))
conf.check(header_name='Python.h', define_name='HAVE_PYEMBED', msg='Getting pyembed flags from python-config',
fragment=FRAG, errmsg='Could not build a python embedded interpreter',
features='%s %sprogram pyembed' % (xx, xx))
for flags in all_flags:
conf.check_cfg(msg='Asking python-config for pyext %r flags' % ' '.join(flags), path=env.PYTHON_CONFIG, package='', uselib_store='PYEXT', args=flags)
if 'pyext' in features:
for flags in all_flags:
conf.check_cfg(msg='Asking python-config for pyext %r flags' % ' '.join(flags), path=env.PYTHON_CONFIG, package='', uselib_store='PYEXT', args=flags)
conf.check(header_name='Python.h', define_name='HAVE_PYEXT', msg='Getting pyext flags from python-config',
features='%s %sshlib pyext' % (xx, xx), fragment=FRAG, errmsg='Could not build python extensions')
conf.check(header_name='Python.h', define_name='HAVE_PYEXT', msg='Getting pyext flags from python-config',
features='%s %sshlib pyext' % (xx, xx), fragment=FRAG, errmsg='Could not build python extensions')
conf.define('HAVE_PYTHON_H', 1)
return