[PATCHv2 1-14/14] Re: Disabling Python Modules

Ian Stakenvicius axs at gentoo.org
Sun Jan 29 19:28:16 UTC 2017


On 29/01/17 02:14 PM, Andrew Bartlett wrote:
> 
> I can't get this to build when I set --disable-python.
> 
> I get "ADDC requires python" even if I set --without-ad-dc, sorry. 
> Additionally the error string needs to be modified to be "--disable-
> python requires --without-ad-dc".
> 
> The attached autobuild patch will keep this working, once we sort out
> what is going on here.
> 

Yes, this is a mistake on my part -- I was using
conf.env.without_ad_dc to obtain the configured value, but that is
never set from Options.options and so is always false.  I've adjusted
that to use Options.options.without_ad_dc directly in the same manner
that it is used later to set the #define.

I've also adjusted the error message, and incorporated the pep8 fixes
from the previous email.


-------------- next part --------------
From 25d0d75c1d813c9522d49b6568670076cad2f9ee Mon Sep 17 00:00:00 2001
From: Ian Stakenvicius <axs at gentoo.org>
Date: Fri, 27 Jan 2017 13:28:01 -0500
Subject: [PATCH 01/12] waf: disable-python - add option globally to build
 system

This commit adds --disable-python as an option to the build system.
It adds PYTHON_BUILD_IS_ENABLED() to bld, to be used with enabled=
on other modules, and adjusts SAMBA_PYTHON() to set enabled=False
if PYTHON_BUILD_IS_ENABLED() is false.

Signed-off-by: Ian Stakenvicius <axs at gentoo.org>
---
 buildtools/wafsamba/samba_python.py | 33 +++++++++++++++++++++++++++++----
 buildtools/wafsamba/wscript         |  6 ++++++
 2 files changed, 35 insertions(+), 4 deletions(-)

diff --git a/buildtools/wafsamba/samba_python.py b/buildtools/wafsamba/samba_python.py
index 057a017..272b128 100644
--- a/buildtools/wafsamba/samba_python.py
+++ b/buildtools/wafsamba/samba_python.py
@@ -4,8 +4,9 @@ import os
 import Build, Logs, Utils, Configure
 from Configure import conf
 
+
 @conf
-def SAMBA_CHECK_PYTHON(conf, mandatory=True, version=(2,4,2)):
+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)
@@ -40,6 +41,14 @@ def SAMBA_CHECK_PYTHON(conf, mandatory=True, version=(2,4,2)):
 
 @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")
+        return
+
     if conf.env["python_headers_checked"] == []:
         if conf.env['EXTRA_PYTHON']:
             conf.setenv('extrapython')
@@ -54,21 +63,23 @@ def SAMBA_CHECK_PYTHON_HEADERS(conf, mandatory=True):
             if extraversion == conf.env['PYTHON_VERSION']:
                 raise Utils.WafError("extrapython %s is same as main python %s" % (
                     extraversion, conf.env['PYTHON_VERSION']))
+
     else:
-        conf.msg("python headers", "using cache")
+            conf.msg("python headers", "using cache")
 
     # 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'])
 
+
 def _check_python_headers(conf, mandatory):
     try:
         Configure.ConfigurationError
         conf.check_python_headers(mandatory=mandatory)
     except Configure.ConfigurationError:
         if mandatory:
-             raise
+            raise
 
     if conf.env['PYTHON_VERSION'] > '3':
         abi_pattern = os.path.splitext(conf.env['pyext_PATTERN'])[0]
@@ -77,6 +88,12 @@ def _check_python_headers(conf, mandatory):
         conf.env['PYTHON_SO_ABI_FLAG'] = ''
 
 
+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='',
@@ -91,6 +108,11 @@ def SAMBA_PYTHON(bld, name,
                  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
 
@@ -138,7 +160,10 @@ Build.BuildContext.SAMBA_PYTHON = SAMBA_PYTHON
 
 
 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
 
diff --git a/buildtools/wafsamba/wscript b/buildtools/wafsamba/wscript
index 8802e5a..c5c0081 100644
--- a/buildtools/wafsamba/wscript
+++ b/buildtools/wafsamba/wscript
@@ -196,6 +196,10 @@ def set_options(opt):
                    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 "
@@ -279,6 +283,8 @@ def configure(conf):
     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.AUTOCONF_HOST and
-- 
2.10.2


From d1321be86a8b42ba5514f043facbbd736039510e Mon Sep 17 00:00:00 2001
From: Ian Stakenvicius <axs at gentoo.org>
Date: Fri, 27 Jan 2017 14:07:21 -0500
Subject: [PATCH 02/12] waf: disable-python - configuration adjustments

Adjust configuration to accomodate when --disable-python is set:

- Error when AD-DC is still enabled (and others later as needed)

- Set mandatory=false on SAMBA_CHECK_PYTHON_HEADERS

Signed-off-by: Ian Stakenvicius <axs at gentoo.org>
---
 wscript | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/wscript b/wscript
index 9168db1..092a1ae 100644
--- a/wscript
+++ b/wscript
@@ -105,8 +105,12 @@ def configure(conf):
     conf.SAMBA_CHECK_PERL(mandatory=True)
     conf.find_program('xsltproc', var='XSLTPROC')
 
+    if conf.env.disable_python:
+        if not (Options.options.without_ad_dc):
+            raise Utils.WafError('--disable-python requires --without-ad-dc')
+
     conf.SAMBA_CHECK_PYTHON(mandatory=True, version=(2, 6, 0))
-    conf.SAMBA_CHECK_PYTHON_HEADERS(mandatory=True)
+    conf.SAMBA_CHECK_PYTHON_HEADERS(mandatory=(not conf.env.disable_python))
 
     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
-- 
2.10.2


From 8f331efcf961c80d0f5567f120d4b8c994dc61e6 Mon Sep 17 00:00:00 2001
From: Ian Stakenvicius <axs at gentoo.org>
Date: Fri, 27 Jan 2017 14:27:50 -0500
Subject: [PATCH 03/12] waf: disable-python - align talloc's wscript

Drop the configure option for --disable-python as it is now
global in wafsamba

If samba is set to use a system copy of talloc, and talloc wasn't built
with python support, then the system pytalloc-util will not be found.
If samba is being built without python support then pytalloc-util is not
needed, so do not bother to try and find it.

The build configuration for pytalloc-util needs to exist even if it's
not being built, so that dependency resolution can occur throughout
the rest of the samba build system -- this required dropping the higher
level conditional and using the enabled= parameter instead.

Signed-off-by: Ian Stakenvicius <axs at gentoo.org>
---
 lib/talloc/wscript | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/lib/talloc/wscript b/lib/talloc/wscript
index 41f3be7..97891d2 100644
--- a/lib/talloc/wscript
+++ b/lib/talloc/wscript
@@ -32,9 +32,6 @@ def set_options(opt):
         opt.add_option('--enable-talloc-compat1',
                        help=("Build talloc 1.x.x compat library [False]"),
                        action="store_true", dest='TALLOC_COMPAT1', default=False)
-        opt.add_option('--disable-python',
-                       help=("disable the pytalloc module"),
-                       action="store_true", dest='disable_python', default=False)
 
 
 def configure(conf):
@@ -42,13 +39,12 @@ def configure(conf):
 
     conf.env.standalone_talloc = conf.IN_LAUNCH_DIR()
 
-    conf.env.disable_python = getattr(Options.options, 'disable_python', False)
-
     if not conf.env.standalone_talloc:
         if conf.CHECK_BUNDLED_SYSTEM_PKG('talloc', minversion=VERSION,
                                      implied_deps='replace'):
             conf.define('USING_SYSTEM_TALLOC', 1)
-        if conf.CHECK_BUNDLED_SYSTEM_PKG('pytalloc-util', minversion=VERSION,
+        if not conf.env.disable_python and \
+            conf.CHECK_BUNDLED_SYSTEM_PKG('pytalloc-util', minversion=VERSION,
                                      implied_deps='talloc replace'):
             conf.define('USING_SYSTEM_PYTALLOC_UTIL', 1)
 
@@ -122,7 +118,7 @@ def build(bld):
                           private_library=private_library,
                           manpages='man/talloc.3')
 
-    if not bld.CONFIG_SET('USING_SYSTEM_PYTALLOC_UTIL') and not bld.env.disable_python:
+    if not bld.CONFIG_SET('USING_SYSTEM_PYTALLOC_UTIL'):
         for env in bld.gen_python_environments(['PKGCONFIGDIR']):
             name = bld.pyembed_libname('pytalloc-util')
 
@@ -136,18 +132,19 @@ def build(bld):
                 abi_match='pytalloc_* _pytalloc_*',
                 private_library=private_library,
                 public_headers=('' if private_library else 'pytalloc.h'),
-                pc_files='pytalloc-util.pc'
+                pc_files='pytalloc-util.pc',
+                enabled=bld.PYTHON_BUILD_IS_ENABLED()
                 )
             bld.SAMBA_PYTHON('pytalloc',
                             'pytalloc.c',
                             deps='talloc ' + name,
-                            enabled=True,
+                            enabled=bld.PYTHON_BUILD_IS_ENABLED(),
                             realname='talloc.so')
 
             bld.SAMBA_PYTHON('test_pytalloc',
                             'test_pytalloc.c',
                             deps='pytalloc',
-                            enabled=True,
+                            enabled=bld.PYTHON_BUILD_IS_ENABLED(),
                             realname='_test_pytalloc.so',
                             install=False)
 
-- 
2.10.2


From 8a2fb0784b62fa134e6e3997cc663ba656eeb8b2 Mon Sep 17 00:00:00 2001
From: Ian Stakenvicius <axs at gentoo.org>
Date: Fri, 27 Jan 2017 14:34:25 -0500
Subject: [PATCH 04/12] waf: disable-python - align ldb's wscript

If samba is set to use a system copy of ldb, and ldb wasn't built with
python support, then no system pyldb-util will be found.  If samba is
being built without python support then pyldb-util isn not needed, so
do not bother to try and find it.

The system ldb check had to be duplicated due to the earlier commits
which changed order of ldb and pyldb-util checks, and by association
also added a dependency of pyldb-util onto ldb.  This seemed cleaner
than messing with variables.

The build configuration for pyldb-util needs to exist even if it's
not being built, so that dependency resolution can occur throughout
the rest of the samba build system -- this required dropping the higher
level conditional and using the enabled= parameter instead.

Signed-off-by: Ian Stakenvicius <axs at gentoo.org>
---
 lib/ldb/wscript | 25 ++++++++++++++++---------
 1 file changed, 16 insertions(+), 9 deletions(-)

diff --git a/lib/ldb/wscript b/lib/ldb/wscript
index 7f05db3..3bf4adf 100644
--- a/lib/ldb/wscript
+++ b/lib/ldb/wscript
@@ -46,7 +46,7 @@ def configure(conf):
     conf.find_program('xsltproc', var='XSLTPROC')
     conf.check_tool('python')
     conf.check_python_version((2,4,2))
-    conf.SAMBA_CHECK_PYTHON_HEADERS(mandatory=True)
+    conf.SAMBA_CHECK_PYTHON_HEADERS(mandatory=not conf.env.disable_python)
 
     # where does the default LIBDIR end up? in conf.env somewhere?
     #
@@ -55,10 +55,16 @@ def configure(conf):
     conf.env.standalone_ldb = conf.IN_LAUNCH_DIR()
 
     if not conf.env.standalone_ldb:
-        if conf.CHECK_BUNDLED_SYSTEM_PKG('pyldb-util', minversion=VERSION,
+        if conf.env.disable_python:
+            if conf.CHECK_BUNDLED_SYSTEM_PKG('ldb', minversion=VERSION,
+                                         onlyif='talloc tdb tevent',
+                                         implied_deps='replace talloc tdb tevent'):
+                conf.define('USING_SYSTEM_LDB', 1)
+        else:
+            if conf.CHECK_BUNDLED_SYSTEM_PKG('pyldb-util', minversion=VERSION,
                                      onlyif='talloc tdb tevent',
                                      implied_deps='replace talloc tdb tevent ldb'):
-            conf.define('USING_SYSTEM_PYLDB_UTIL', 1)
+                conf.define('USING_SYSTEM_PYLDB_UTIL', 1)
             if conf.CHECK_BUNDLED_SYSTEM_PKG('ldb', minversion=VERSION,
                                          onlyif='talloc tdb tevent pyldb-util',
                                          implied_deps='replace talloc tdb tevent'):
@@ -120,11 +126,10 @@ def build(bld):
         bld.env.PACKAGE_VERSION = VERSION
         bld.env.PKGCONFIGDIR = '${LIBDIR}/pkgconfig'
 
-    if not bld.env.disable_python:
-        if not bld.CONFIG_SET('USING_SYSTEM_PYLDB_UTIL'):
-            for env in bld.gen_python_environments(['PKGCONFIGDIR']):
-                name = bld.pyembed_libname('pyldb-util')
-                bld.SAMBA_LIBRARY(name,
+    if not bld.CONFIG_SET('USING_SYSTEM_PYLDB_UTIL'):
+        for env in bld.gen_python_environments(['PKGCONFIGDIR']):
+            name = bld.pyembed_libname('pyldb-util')
+            bld.SAMBA_LIBRARY(name,
                                   deps='ldb',
                                   source='pyldb_util.c',
                                   public_headers=('' if private_library else 'pyldb.h'),
@@ -133,15 +138,17 @@ def build(bld):
                                   private_library=private_library,
                                   pc_files='pyldb-util.pc',
                                   pyembed=True,
+                                  enabled=bld.PYTHON_BUILD_IS_ENABLED(),
                                   abi_directory='ABI',
                                   abi_match='pyldb_*')
 
-                if not bld.CONFIG_SET('USING_SYSTEM_LDB'):
+            if not bld.CONFIG_SET('USING_SYSTEM_LDB'):
                     bld.SAMBA_PYTHON('pyldb', 'pyldb.c',
                                      deps='ldb ' + name,
                                      realname='ldb.so',
                                      cflags='-DPACKAGE_VERSION=\"%s\"' % VERSION)
 
+        if bld.PYTHON_BUILD_IS_ENABLED():
             for env in bld.gen_python_environments(['PKGCONFIGDIR']):
                 bld.SAMBA_SCRIPT('_ldb_text.py',
                                  pattern='_ldb_text.py',
-- 
2.10.2


From f51456d98e82d0676955176ac7eb8645c0d1b663 Mon Sep 17 00:00:00 2001
From: Ian Stakenvicius <axs at gentoo.org>
Date: Fri, 27 Jan 2017 14:37:39 -0500
Subject: [PATCH 05/12] waf: disable-python - align tevent wscript

Drop the configure option for --disable-python as it is now
global in wafsamba.

If samba is set to use a system copy of tevent, and tevent wasn't built
with python support, then the system pytevent will not be found.  If
samba is being built without python support then pytevent is not needed,
so do not bother to try and find it.

Signed-off-by: Ian Stakenvicius <axs at gentoo.org>
---
 lib/tevent/wscript | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/lib/tevent/wscript b/lib/tevent/wscript
index 580ca4d..0c02f70 100644
--- a/lib/tevent/wscript
+++ b/lib/tevent/wscript
@@ -22,10 +22,6 @@ def set_options(opt):
     opt.PRIVATE_EXTENSION_DEFAULT('tevent', noextension='tevent')
     opt.RECURSE('lib/replace')
     opt.RECURSE('lib/talloc')
-    if opt.IN_LAUNCH_DIR():
-        opt.add_option('--disable-python',
-                       help=("disable the pytevent module"),
-                       action="store_true", dest='disable_python', default=False)
 
 
 def configure(conf):
@@ -38,7 +34,8 @@ def configure(conf):
         if conf.CHECK_BUNDLED_SYSTEM_PKG('tevent', minversion=VERSION,
                                      onlyif='talloc', implied_deps='replace talloc'):
             conf.define('USING_SYSTEM_TEVENT', 1)
-            if conf.CHECK_BUNDLED_SYSTEM_PYTHON('pytevent', 'tevent', minversion=VERSION):
+            if not conf.env.disable_python and \
+                conf.CHECK_BUNDLED_SYSTEM_PYTHON('pytevent', 'tevent', minversion=VERSION):
                 conf.define('USING_SYSTEM_PYTEVENT', 1)
 
     if conf.CHECK_FUNCS('epoll_create', headers='sys/epoll.h'):
@@ -61,8 +58,6 @@ def configure(conf):
     if not conf.CONFIG_SET('USING_SYSTEM_TEVENT'):
         conf.DEFINE('TEVENT_NUM_SIGNALS', tevent_num_signals)
 
-    conf.env.disable_python = getattr(Options.options, 'disable_python', False)
-
     if not conf.env.disable_python:
         # also disable if we don't have the python libs installed
         conf.find_program('python', var='PYTHON')
-- 
2.10.2


From 99a5874f609839fb0859694bb66d3c4fa521495c Mon Sep 17 00:00:00 2001
From: Ian Stakenvicius <axs at gentoo.org>
Date: Fri, 27 Jan 2017 14:42:05 -0500
Subject: [PATCH 06/12] waf: disable-python - align tdb's wscript

Drop the configure option for --disable-python as it is now
global in wafsamba.

If samba is set to use a system copy of tdb, and tdb wasn't built
with python support, then the system pytevent will not be found.  If
samba is being built without python support then pytdb is not needed,
so do not bother to try and find it.

Signed-off-by: Ian Stakenvicius <axs at gentoo.org>
---
 lib/tdb/wscript | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/lib/tdb/wscript b/lib/tdb/wscript
index 34058e4..0d682eb 100644
--- a/lib/tdb/wscript
+++ b/lib/tdb/wscript
@@ -60,10 +60,6 @@ def set_options(opt):
                    help=("Disable the use of pthread robust mutexes"),
                    action="store_true", dest='disable_tdb_mutex_locking',
                    default=False)
-    if opt.IN_LAUNCH_DIR():
-        opt.add_option('--disable-python',
-                       help=("disable the pytdb module"),
-                       action="store_true", dest='disable_python', default=False)
 
 
 def configure(conf):
@@ -82,11 +78,10 @@ def configure(conf):
                                      implied_deps='replace'):
             conf.define('USING_SYSTEM_TDB', 1)
             conf.env.building_tdb = False
-            if conf.CHECK_BUNDLED_SYSTEM_PYTHON('pytdb', 'tdb', minversion=VERSION):
+            if not conf.env.disable_python and \
+                conf.CHECK_BUNDLED_SYSTEM_PYTHON('pytdb', 'tdb', minversion=VERSION):
                 conf.define('USING_SYSTEM_PYTDB', 1)
 
-    conf.env.disable_python = getattr(Options.options, 'disable_python', False)
-
     if (conf.CONFIG_SET('HAVE_ROBUST_MUTEXES') and
         conf.env.building_tdb and
         not conf.env.disable_tdb_mutex_locking):
-- 
2.10.2


From f58acf6aa90d0e36c6f79ce3cc3e16f705bf7681 Mon Sep 17 00:00:00 2001
From: Ian Stakenvicius <axs at gentoo.org>
Date: Fri, 27 Jan 2017 16:38:36 -0500
Subject: [PATCH 07/12] waf: disable-python - don't build python/

Signed-off-by: Ian Stakenvicius <axs at gentoo.org>
---
 python/wscript_build | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/python/wscript_build b/python/wscript_build
index 5ab0d7d..85a983e 100644
--- a/python/wscript_build
+++ b/python/wscript_build
@@ -5,7 +5,8 @@ bld.SAMBA_LIBRARY('samba_python',
 	deps='LIBPYTHON pytalloc-util pyrpc_util',
 	grouping_library=True,
 	private_library=True,
-	pyembed=True)
+	pyembed=True,
+	enabled=bld.PYTHON_BUILD_IS_ENABLED())
 
 bld.SAMBA_SUBSYSTEM('LIBPYTHON',
 	source='modules.c',
@@ -13,7 +14,7 @@ bld.SAMBA_SUBSYSTEM('LIBPYTHON',
 	init_function_sentinel='{NULL,NULL}',
 	deps='talloc',
 	pyext=True,
-	)
+	enabled=bld.PYTHON_BUILD_IS_ENABLED())
 
 
 bld.SAMBA_PYTHON('python_glue',
@@ -22,7 +23,8 @@ bld.SAMBA_PYTHON('python_glue',
 	realname='samba/_glue.so'
 	)
 
-for env in bld.gen_python_environments():
+if bld.PYTHON_BUILD_IS_ENABLED():
+    for env in bld.gen_python_environments():
 	# install out various python scripts for use by make test
 	bld.SAMBA_SCRIPT('samba_python_files',
 	                 pattern='samba/**/*.py',
-- 
2.10.2


From 42099abdf952eb335762c5d31e17c1dd52a31f4d Mon Sep 17 00:00:00 2001
From: Ian Stakenvicius <axs at gentoo.org>
Date: Fri, 27 Jan 2017 16:49:29 -0500
Subject: [PATCH 08/12] waf: disable-python - don't build PROVISION,
 pyparam_util

Signed-off-by: Ian Stakenvicius <axs at gentoo.org>
---
 source4/param/wscript_build | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/source4/param/wscript_build b/source4/param/wscript_build
index 2ad753b..8de5fb5 100644
--- a/source4/param/wscript_build
+++ b/source4/param/wscript_build
@@ -4,6 +4,7 @@ bld.SAMBA_SUBSYSTEM('PROVISION',
 	source='provision.c pyparam.c',
 	deps='LIBPYTHON pyparam_util ldb pytalloc-util pyldb-util',
 	pyext=True,
+	enabled=bld.PYTHON_BUILD_IS_ENABLED(),
 	)
 
 
@@ -51,6 +52,7 @@ bld.SAMBA_SUBSYSTEM('pyparam_util',
 	source='pyparam_util.c',
 	deps='LIBPYTHON samba-hostconfig pytalloc-util',
 	pyext=True,
+	enabled=bld.PYTHON_BUILD_IS_ENABLED(),
 	)
 
 bld.SAMBA_LIBRARY('shares',
-- 
2.10.2


From 6a33117be03baf64135a5aa35b841c3e2daeb0a4 Mon Sep 17 00:00:00 2001
From: Ian Stakenvicius <axs at gentoo.org>
Date: Fri, 27 Jan 2017 17:04:18 -0500
Subject: [PATCH 09/12] waf: disable-python - don't build pyrpc_util, dcerpc.py

Signed-off-by: Ian Stakenvicius <axs at gentoo.org>
---
 source4/librpc/wscript_build | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/source4/librpc/wscript_build b/source4/librpc/wscript_build
index 60404f8..6bbf341 100644
--- a/source4/librpc/wscript_build
+++ b/source4/librpc/wscript_build
@@ -178,6 +178,7 @@ bld.SAMBA_SUBSYSTEM('pyrpc_util',
 	source='rpc/pyrpc_util.c',
 	public_deps='pytalloc-util pyparam_util dcerpc MESSAGING',
 	pyext=True,
+	enabled=bld.PYTHON_BUILD_IS_ENABLED(),
 	)
 
 
@@ -393,9 +394,10 @@ bld.SAMBA_PYTHON('python_dcerpc_smb_acl',
 	realname='samba/dcerpc/smb_acl.so'
 	)
 
-bld.SAMBA_SCRIPT('python_dcerpc_init',
+if bld.PYTHON_BUILD_IS_ENABLED():
+    bld.SAMBA_SCRIPT('python_dcerpc_init',
                  pattern='rpc/dcerpc.py',
                  installdir='python/samba/dcerpc',
                  installname='__init__.py')
 
-bld.INSTALL_FILES('${PYTHONARCHDIR}/samba/dcerpc', 'rpc/dcerpc.py', destname='__init__.py')
+    bld.INSTALL_FILES('${PYTHONARCHDIR}/samba/dcerpc', 'rpc/dcerpc.py', destname='__init__.py')
-- 
2.10.2


From 1dc6d46c0ce0c148c35b1a510f0ca10a7342fbf4 Mon Sep 17 00:00:00 2001
From: Ian Stakenvicius <axs at gentoo.org>
Date: Fri, 27 Jan 2017 21:31:21 -0500
Subject: [PATCH 10/12] waf: disable-python - don't build samba-net

samba-net requires PROVISION, which is disabled when python isn't available.

Signed-off-by: Ian Stakenvicius <axs at gentoo.org>
---
 source4/libnet/wscript_build | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/source4/libnet/wscript_build b/source4/libnet/wscript_build
index 1274a82..f29da29 100644
--- a/source4/libnet/wscript_build
+++ b/source4/libnet/wscript_build
@@ -4,7 +4,8 @@ bld.SAMBA_LIBRARY('samba-net',
 	source='libnet.c libnet_passwd.c libnet_time.c libnet_rpc.c libnet_join.c libnet_site.c libnet_become_dc.c libnet_unbecome_dc.c libnet_vampire.c libnet_samdump.c libnet_samsync_ldb.c libnet_user.c libnet_group.c libnet_share.c libnet_lookup.c libnet_domain.c userinfo.c groupinfo.c userman.c groupman.c prereq_domain.c libnet_samsync.c',
 	autoproto='libnet_proto.h',
 	public_deps='samba-credentials dcerpc dcerpc-samr RPC_NDR_LSA RPC_NDR_SRVSVC RPC_NDR_DRSUAPI cli_composite LIBCLI_RESOLVE LIBCLI_FINDDCS cli_cldap LIBCLI_FINDDCS gensec_schannel LIBCLI_AUTH ndr smbpasswdparser PROVISION LIBCLI_SAMSYNC LIBTSOCKET',
-	private_library=True
+	private_library=True,
+	enabled=bld.PYTHON_BUILD_IS_ENABLED()
 	)
 
 
-- 
2.10.2


From ea3748b804899ecf1a241758c3bedd073499a77c Mon Sep 17 00:00:00 2001
From: Ian Stakenvicius <axs at gentoo.org>
Date: Fri, 27 Jan 2017 21:32:22 -0500
Subject: [PATCH 11/12] waf: disable-python - don't build samba-policy

samba-policy requires samba-net which requires PROVISION, which
is disabled when python isn't available.

Signed-off-by: Ian Stakenvicius <axs at gentoo.org>
---
 source4/lib/policy/wscript_build | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/source4/lib/policy/wscript_build b/source4/lib/policy/wscript_build
index b8ba638..f7c5909 100644
--- a/source4/lib/policy/wscript_build
+++ b/source4/lib/policy/wscript_build
@@ -6,7 +6,8 @@ bld.SAMBA_LIBRARY('samba-policy',
 	public_deps='ldb samba-net',
 	vnum='0.0.1',
 	pyembed=True,
-	public_headers='policy.h'
+	public_headers='policy.h',
+	enabled=bld.PYTHON_BUILD_IS_ENABLED()
 	)
 
 bld.SAMBA_PYTHON('py_policy',
-- 
2.10.2


From 93c9191ad2710ab0fe0ca4d5bd4cba15439b4b04 Mon Sep 17 00:00:00 2001
From: Ian Stakenvicius <axs at gentoo.org>
Date: Fri, 27 Jan 2017 22:53:39 -0500
Subject: [PATCH 12/12] waf: disable-python - don't build torture bits

samba-net being disabled causes a chain of dependency or proto.h-based
missing code issues that require a number of modules or subsystems
to be disabled in samba4/torture.

Signed-off-by: Ian Stakenvicius <axs at gentoo.org>
---
 source4/torture/drs/wscript_build   |  3 ++-
 source4/torture/local/wscript_build |  3 ++-
 source4/torture/wscript_build       | 28 +++++++++++++++++++---------
 3 files changed, 23 insertions(+), 11 deletions(-)

diff --git a/source4/torture/drs/wscript_build b/source4/torture/drs/wscript_build
index cfdd8a2..67bf034 100644
--- a/source4/torture/drs/wscript_build
+++ b/source4/torture/drs/wscript_build
@@ -6,6 +6,7 @@ bld.SAMBA_MODULE('TORTURE_DRS',
 	subsystem='smbtorture',
 	init_function='torture_drs_init',
 	deps='samba-util ldb POPT_SAMBA samba-errors torture ldbsamba talloc dcerpc ndr NDR_DRSUAPI gensec samba-hostconfig RPC_NDR_DRSUAPI DSDB_MODULE_HELPERS asn1util samdb NDR_DRSBLOBS samba-credentials samdb-common LIBCLI_RESOLVE LP_RESOLVE torturemain',
-	internal_module=True
+	internal_module=True,
+	enabled=bld.PYTHON_BUILD_IS_ENABLED()
 	)
 
diff --git a/source4/torture/local/wscript_build b/source4/torture/local/wscript_build
index 3a12b6b..087b842 100644
--- a/source4/torture/local/wscript_build
+++ b/source4/torture/local/wscript_build
@@ -32,5 +32,6 @@ bld.SAMBA_MODULE('TORTURE_LOCAL',
 	subsystem='smbtorture',
 	init_function='torture_local_init',
 	deps=TORTURE_LOCAL_DEPS,
-	internal_module=True
+	internal_module=True,
+	enabled=bld.PYTHON_BUILD_IS_ENABLED()
 	)
diff --git a/source4/torture/wscript_build b/source4/torture/wscript_build
index c065eaa..fe06629 100644
--- a/source4/torture/wscript_build
+++ b/source4/torture/wscript_build
@@ -14,7 +14,8 @@ bld.SAMBA_MODULE('TORTURE_BASIC',
 	deps='LIBCLI_SMB popt POPT_CREDENTIALS TORTURE_UTIL smbclient-raw TORTURE_RAW',
 	internal_module=True,
 	autoproto='basic/proto.h',
-	init_function='torture_base_init'
+	init_function='torture_base_init',
+	enabled=bld.PYTHON_BUILD_IS_ENABLED()
 	)
 
 
@@ -24,7 +25,8 @@ bld.SAMBA_MODULE('TORTURE_RAW',
 	subsystem='smbtorture',
 	init_function='torture_raw_init',
 	deps='LIBCLI_SMB LIBCLI_LSA LIBCLI_SMB_COMPOSITE popt POPT_CREDENTIALS TORTURE_UTIL',
-	internal_module=True
+	internal_module=True,
+	enabled=bld.PYTHON_BUILD_IS_ENABLED()
 	)
 
 bld.RECURSE('smb2')
@@ -67,7 +69,8 @@ bld.SAMBA_SUBSYSTEM('TORTURE_NDR',
                   ndr/charset.c
 		  ''',
 	autoproto='ndr/proto.h',
-	deps='torture krb5samba'
+	deps='torture krb5samba',
+	enabled=bld.PYTHON_BUILD_IS_ENABLED()
 	)
 
 torture_rpc_backupkey = ''
@@ -181,7 +184,8 @@ bld.SAMBA_MODULE('torture_rpc',
                       RPC_NDR_BACKUPKEY
                       RPC_NDR_WINSPOOL
                       ''' + ntvfs_specific['deps'],
-                 internal_module=True)
+                 internal_module=True,
+                 enabled=bld.PYTHON_BUILD_IS_ENABLED())
 
 bld.RECURSE('drs')
 bld.RECURSE('dns')
@@ -192,7 +196,8 @@ bld.SAMBA_MODULE('TORTURE_RAP',
 	subsystem='smbtorture',
 	init_function='torture_rap_init',
 	deps='TORTURE_UTIL LIBCLI_SMB NDR_RAP LIBCLI_RAP',
-	internal_module=True
+	internal_module=True,
+	enabled=bld.PYTHON_BUILD_IS_ENABLED()
 	)
 
 bld.SAMBA_MODULE('TORTURE_DFS',
@@ -252,7 +257,8 @@ bld.SAMBA_MODULE('TORTURE_NBT',
 	subsystem='smbtorture',
 	init_function='torture_nbt_init',
 	deps='LIBCLI_SMB cli-nbt LIBCLI_DGRAM LIBCLI_WREPL torture_rpc',
-	internal_module=True
+	internal_module=True,
+	enabled=bld.PYTHON_BUILD_IS_ENABLED()
 	)
 
 
@@ -262,7 +268,8 @@ bld.SAMBA_MODULE('TORTURE_NET',
 	subsystem='smbtorture',
 	init_function='torture_net_init',
 	deps='samba-net popt POPT_CREDENTIALS torture_rpc PROVISION',
-	internal_module=True
+	internal_module=True,
+	enabled=bld.PYTHON_BUILD_IS_ENABLED()
 	)
 
 
@@ -272,7 +279,8 @@ bld.SAMBA_MODULE('TORTURE_NTP',
 	subsystem='smbtorture',
 	init_function='torture_ntp_init',
 	deps='popt POPT_CREDENTIALS torture_rpc',
-	internal_module=True
+	internal_module=True,
+	enabled=bld.PYTHON_BUILD_IS_ENABLED()
 	)
 
 bld.SAMBA_MODULE('TORTURE_VFS',
@@ -290,6 +298,7 @@ bld.SAMBA_SUBSYSTEM('torturemain',
                     source='smbtorture.c torture.c shell.c',
                     subsystem_name='smbtorture',
                     deps='torture popt POPT_SAMBA POPT_CREDENTIALS dcerpc LIBCLI_SMB SMBREADLINE ' + TORTURE_MODULES,
+                    enabled=bld.PYTHON_BUILD_IS_ENABLED()
                     )
 
 bld.SAMBA_BINARY('smbtorture',
@@ -297,7 +306,8 @@ bld.SAMBA_BINARY('smbtorture',
                  manpages='man/smbtorture.1',
                  private_headers='smbtorture.h',
                  deps='torturemain torture popt POPT_SAMBA POPT_CREDENTIALS dcerpc LIBCLI_SMB SMBREADLINE ' + TORTURE_MODULES,
-                 pyembed=True
+                 pyembed=True,
+                 enabled=bld.PYTHON_BUILD_IS_ENABLED()
                  )
 
 bld.SAMBA_BINARY('gentest',
-- 
2.10.2



More information about the samba-technical mailing list