build: Standardise on calling conf.SAMBA_CHECK_PYTHON() in libraries
authorAndrew Bartlett <abartlet@samba.org>
Fri, 15 Feb 2019 03:13:48 +0000 (16:13 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 21 Mar 2019 04:06:16 +0000 (04:06 +0000)
We do this by removing the confusing mandatory option to
conf.SAMBA_CHECK_PYTHON{,_HEADERS}(), instead just use the value of
--disable-python internally

This follows the default minimum of Python 3.4 and keeps things consistent
with the main Samba build where --disable-python is required to skip building
python bindings.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
buildtools/wafsamba/samba_python.py
ctdb/wscript
lib/ldb/wscript
lib/talloc/wscript
lib/tdb/wscript
lib/tevent/wscript
wscript

index 598f83d68e82f7852fd4762ee31c3b8966cb3467..4476d3352484091bdf5d3877dca81482254f7061 100644 (file)
@@ -5,9 +5,9 @@ from waflib import Build, Logs, Utils, Configure, Errors
 from waflib.Configure import conf
 
 @conf
-def SAMBA_CHECK_PYTHON(conf, mandatory=True, version=(3,4,0)):
+def SAMBA_CHECK_PYTHON(conf, version=(3,4,0)):
 
-    if not mandatory:
+    if conf.env.disable_python:
         version=(2,6,0)
 
     # enable tool to build python extensions
@@ -17,7 +17,8 @@ def SAMBA_CHECK_PYTHON(conf, mandatory=True, version=(3,4,0)):
 
     interpreters = []
 
-    conf.find_program('python3', var='PYTHON', mandatory=mandatory)
+    conf.find_program('python3', var='PYTHON',
+                      mandatory=not conf.env.disable_python)
     conf.load('python')
     path_python = conf.find_program('python3')
 
@@ -29,11 +30,8 @@ def SAMBA_CHECK_PYTHON(conf, mandatory=True, version=(3,4,0)):
 
 
 @conf
-def SAMBA_CHECK_PYTHON_HEADERS(conf, mandatory=True):
+def SAMBA_CHECK_PYTHON_HEADERS(conf):
     if conf.env.disable_python:
-        if mandatory:
-            raise Errors.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
@@ -45,7 +43,7 @@ def SAMBA_CHECK_PYTHON_HEADERS(conf, mandatory=True):
         return
 
     if conf.env["python_headers_checked"] == []:
-        _check_python_headers(conf, mandatory)
+        _check_python_headers(conf)
         conf.env["python_headers_checked"] = "yes"
 
     else:
@@ -57,13 +55,8 @@ def SAMBA_CHECK_PYTHON_HEADERS(conf, mandatory=True):
         if not x.startswith('PYTHONDIR=')
         and not x.startswith('PYTHONARCHDIR=')]
 
-def _check_python_headers(conf, mandatory):
-    try:
-        conf.errors.ConfigurationError
-        conf.check_python_headers()
-    except conf.errors.ConfigurationError:
-        if mandatory:
-             raise
+def _check_python_headers(conf):
+    conf.check_python_headers()
 
     if conf.env['PYTHON_VERSION'] > '3':
         abi_pattern = os.path.splitext(conf.env['pyext_PATTERN'])[0]
index 15dd75708f00aebb5aa2fa1fed76ed88f4d3446b..3fa525b564da837b3b82429236129d2d3d2aaf6c 100644 (file)
@@ -140,8 +140,10 @@ def configure(conf):
     if conf.env.standalone_ctdb:
         conf.SAMBA_CHECK_PERL(mandatory=True)
 
-        conf.SAMBA_CHECK_PYTHON(mandatory=False)
-        conf.SAMBA_CHECK_PYTHON_HEADERS(mandatory=False)
+        # This is just for consistency and to check the version for the
+        # build system, see Options.options.disable_python = True above
+        conf.SAMBA_CHECK_PYTHON()
+        conf.SAMBA_CHECK_PYTHON_HEADERS()
 
     if conf.CHECK_FOR_THIRD_PARTY():
         conf.RECURSE('third_party/popt')
index 4f0c68c9c6cf9a5f73a763f10f2718ce8f78a728..7a8b307fb228315a232aa2b8c841246bce075bc8 100644 (file)
@@ -58,11 +58,9 @@ def configure(conf):
             conf.define('USING_SYSTEM_CMOCKA', 1)
 
     conf.RECURSE('lib/replace')
-    conf.find_program('python', var='PYTHON')
     conf.find_program('xsltproc', var='XSLTPROC')
-    conf.load('python')
-    conf.check_python_version((2,4,2))
-    conf.SAMBA_CHECK_PYTHON_HEADERS(mandatory=not conf.env.disable_python)
+    conf.SAMBA_CHECK_PYTHON()
+    conf.SAMBA_CHECK_PYTHON_HEADERS()
 
     # where does the default LIBDIR end up? in conf.env somewhere?
     #
index 827ae88498be791b01a513b4e1107bdac5d8995b..6947b1d0b806750dbf3e4cc60e24ff8315140a16 100644 (file)
@@ -57,16 +57,8 @@ def configure(conf):
 
     conf.SAMBA_CHECK_UNDEFINED_SYMBOL_FLAGS()
 
-    # We need to set everything non-python up before here, because
-    # SAMBA_CHECK_PYTHON makes a copy of conf and we need it set up correctly
-
-    if not conf.env.disable_python:
-        # also disable if we don't have the python libs installed
-        conf.SAMBA_CHECK_PYTHON(mandatory=False)
-        conf.SAMBA_CHECK_PYTHON_HEADERS(mandatory=False)
-        if not conf.env.HAVE_PYTHON_H:
-            Logs.warn('Disabling pytalloc-util as python devel libs not found')
-            conf.env.disable_python = True
+    conf.SAMBA_CHECK_PYTHON()
+    conf.SAMBA_CHECK_PYTHON_HEADERS()
 
     if not conf.env.standalone_talloc:
         if conf.CHECK_BUNDLED_SYSTEM_PKG('talloc', minversion=VERSION,
index c616b40fbe55ece75fd2b8d1fbe2bae1d90109fc..02105d06c847a1f9aa222022b30a61ff5951d2a4 100644 (file)
@@ -97,14 +97,8 @@ def configure(conf):
 
     conf.CHECK_XSLTPROC_MANPAGES()
 
-    if not conf.env.disable_python:
-        # also disable if we don't have the python libs installed
-        conf.SAMBA_CHECK_PYTHON(mandatory=False)
-        conf.check_python_version((2,4,2))
-        conf.SAMBA_CHECK_PYTHON_HEADERS(mandatory=False)
-        if not conf.env.HAVE_PYTHON_H:
-            Logs.warn('Disabling pytdb as python devel libs not found')
-            conf.env.disable_python = True
+    conf.SAMBA_CHECK_PYTHON()
+    conf.SAMBA_CHECK_PYTHON_HEADERS()
 
     conf.SAMBA_CONFIG_H()
 
index a9288add0a30268f70b45889728921154d219618..df3068af487703daac4f70ea5dbd8e60eff36515 100644 (file)
@@ -60,15 +60,8 @@ def configure(conf):
     if not conf.CONFIG_SET('USING_SYSTEM_TEVENT'):
         conf.DEFINE('TEVENT_NUM_SIGNALS', tevent_num_signals)
 
-    if not conf.env.disable_python:
-        # also disable if we don't have the python libs installed
-        conf.find_program('python', var='PYTHON')
-        conf.load('python')
-        conf.check_python_version((2,4,2))
-        conf.SAMBA_CHECK_PYTHON_HEADERS(mandatory=False)
-        if not conf.env.HAVE_PYTHON_H:
-            Logs.warn('Disabling pytevent as python devel libs not found')
-            conf.env.disable_python = True
+    conf.SAMBA_CHECK_PYTHON()
+    conf.SAMBA_CHECK_PYTHON_HEADERS()
 
     conf.SAMBA_CONFIG_H()
 
diff --git a/wscript b/wscript
index a0a8080b448ff618a8e8cdb7fc70bbd6dd7cfb16..47fc2ba24605ac4053744a35c0e2434bf621de88 100644 (file)
--- a/wscript
+++ b/wscript
@@ -151,8 +151,8 @@ def configure(conf):
         if not (Options.options.without_ad_dc):
             raise Errors.WafError('--disable-python requires --without-ad-dc')
 
-    conf.SAMBA_CHECK_PYTHON(mandatory=not conf.env.disable_python)
-    conf.SAMBA_CHECK_PYTHON_HEADERS(mandatory=(not conf.env.disable_python))
+    conf.SAMBA_CHECK_PYTHON()
+    conf.SAMBA_CHECK_PYTHON_HEADERS()
 
     if sys.platform == 'darwin' and not conf.env['HAVE_ENVIRON_DECL']:
         # Mac OSX needs to have this and it's also needed that the python is compiled with this