@conf
def SAMBA_CHECK_PYTHON_HEADERS(conf, mandatory=True):
+ if conf.env.disable_python:
+ if mandatory:
+ raise Utils.WafError("Cannot check for python headers when "
+ "--disable-python specified")
+
+ conf.msg("python headers", "Check disabled due to --disable-python")
+ # we don't want PYTHONDIR in config.h, as otherwise changing
+ # --prefix causes a complete rebuild
+ del(conf.env.defines['PYTHONDIR'])
+ del(conf.env.defines['PYTHONARCHDIR'])
+ return
+
if conf.env["python_headers_checked"] == []:
if conf.env['EXTRA_PYTHON']:
conf.setenv('extrapython')
conf.env['PYTHON_SO_ABI_FLAG'].replace('_', '-'))
+def PYTHON_BUILD_IS_ENABLED(self):
+ return self.CONFIG_SET('HAVE_PYTHON_H')
+
+Build.BuildContext.PYTHON_BUILD_IS_ENABLED = PYTHON_BUILD_IS_ENABLED
+
+
def SAMBA_PYTHON(bld, name,
source='',
deps='',
enabled=True):
'''build a python extension for Samba'''
+ # force-disable when we can't build python modules, so
+ # every single call doesn't need to pass this in.
+ if not bld.PYTHON_BUILD_IS_ENABLED():
+ enabled = False
+
if bld.env['IS_EXTRA_PYTHON']:
name = 'extra-' + name
def pyembed_libname(bld, name, extrapython=False):
- return name + bld.env['PYTHON_SO_ABI_FLAG']
+ if bld.env['PYTHON_SO_ABI_FLAG']:
+ return name + bld.env['PYTHON_SO_ABI_FLAG']
+ else:
+ return name
Build.BuildContext.pyembed_libname = pyembed_libname
help='tag release in git at the same time',
type='string', action='store', dest='TAG_RELEASE')
+ opt.add_option('--disable-python',
+ help='do not generate python modules',
+ action='store_true', dest='disable_python', default=False)
+
opt.add_option('--extra-python', type=str,
help=("build selected libraries for the specified "
"additional version of Python "
conf.env.AUTOCONF_HOST = Options.options.AUTOCONF_HOST
conf.env.AUTOCONF_PROGRAM_PREFIX = Options.options.AUTOCONF_PROGRAM_PREFIX
+ conf.env.disable_python = Options.options.disable_python
+
conf.env.EXTRA_PYTHON = Options.options.EXTRA_PYTHON
+ if (conf.env.disable_python and conf.env.EXTRA_PYTHON):
+ Logs.error('ERROR: cannot specify both --disable-python and --extra-python.')
+ sys.exit(1)
+
if (conf.env.AUTOCONF_HOST and
conf.env.AUTOCONF_BUILD and
conf.env.AUTOCONF_BUILD != conf.env.AUTOCONF_HOST):