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

Ian Stakenvicius axs at gentoo.org
Sun Jan 29 05:28:45 UTC 2017


On 28/01/17 12:25 PM, Alexander Bokovoy wrote:
> On la, 28 tammi 2017, Ian Stakenvicius wrote:
>> On 28/01/17 05:02 AM, Alexander Bokovoy wrote:
>>> On la, 28 tammi 2017, Ian Stakenvicius wrote:
>>>> diff --git a/buildtools/wafsamba/samba_python.py b/buildtools/wafsamba/samba_python.py
>>>> index 057a017..b6bf079 100644
>>>> --- a/buildtools/wafsamba/samba_python.py
>>>> +++ b/buildtools/wafsamba/samba_python.py
>>>> @@ -40,22 +40,31 @@ def SAMBA_CHECK_PYTHON(conf, mandatory=True, version=(2,4,2)):
>>>>  
>>>>  @conf
>>>>  def SAMBA_CHECK_PYTHON_HEADERS(conf, mandatory=True):
>>>> [...]
>>>
>>> Could you please turn the logic upside down here?
>>> Instead of 
>>>
>>>    if not conf.env.disable_python:
>>>     -> re-indent code
>>>    else:
>>>     ....
>>>
>>> please do 
>>>
>>>    if conf.env.disable_python:
>>>       ....
>>>       return
>>>
>>>    original code
>>>
>>> This would further reduce the diff size and will not touch the original
>>> code at all.
>>>
>>
>> Definitely.
>>
>>
>>>>  
>>>>      # we don't want PYTHONDIR in config.h, as otherwise changing
>>>>      # --prefix causes a complete rebuild
>>>> @@ -77,6 +86,14 @@ def _check_python_headers(conf, mandatory):
>>>>          conf.env['PYTHON_SO_ABI_FLAG'] = ''
>>>>  
>>>>  
>>>> +def PYTHON_BUILD_IS_ENABLED(self):
>>>> +    if self.CONFIG_SET('HAVE_PYTHON_H'):
>>>> +        return True
>>>> +    return False
>>> CONFIG_SET already returns True or False, so this could be simplified
>>> down to
>>>
>>>    def PYTHON_BUILD_IS_ENABLED(self):
>>>        return self.CONFIG_SET('HAVE_PYTHON_H')
>>>
>>>
>>
>> Will do.  Note that I found the code pattern I used a lot, so it might
>> be worth doing a cleanup commit to change them all to your suggested
>> format?
>>
> Sounds like a good idea, thanks.
> 
> 
>>>> +
>>>> +Build.BuildContext.PYTHON_BUILD_IS_ENABLED = PYTHON_BUILD_IS_ENABLED
>>>> +
>>>> +
>>>>  def SAMBA_PYTHON(bld, name,
>>>>                   source='',
>>>>                   deps='',
>>>> @@ -91,6 +108,9 @@ def SAMBA_PYTHON(bld, name,
>>>>                   enabled=True):
>>>>      '''build a python extension for Samba'''
>>>>  
>>>> +    if not bld.PYTHON_BUILD_IS_ENABLED():
>>>> +        enabled = False
>>>> +
>>> As PYTHON_BUILD_IS_ENABLED already returns True or False, this could be
>>> written as
>>>
>>>    enabled = bld.PYTHON_BUILD_IS_ENABLED()
>>>
>>
>>
>> We would lose the passed-in value of 'enabled' if we overwrote it in
>> that manner.  I could do:
>>
>> 	enabled = (enabled and bld.PYTHON_BUILD_IS_ENABLED())
>>
>> ..if that would be preferable?  I'm thinking the earlier form would be
>> easier to understand when someone looks at it in a year, though.
> Ok, you are right. However, please add a comment there why we are
> forcing an override. In a year nobody will remember that.
> 
>> -----
>>
>> So as-is, would this patchset be complete or should I also include the
>> code to remove --disable-python from the wscript of standalone modules?
> Please add patches for the standalone modules too.
> 


I've integrated the suggested changes and finished adjustments to the
standalone modules.  I also squashed the patchset a bit more.  Please
find attached the patchset for review and approval.

As promised, I've also rebased Petr's multi-python work on top of this
patchset, available for review at
https://github.com/axs-gentoo/samba/tree/disable-python-v2-with-python3
-- note that with this patchset there are only two conflicting lines
between them that I had to compensate for.

(edit - re-sending without openpgp signature)




-------------- next part --------------
From ad7892b01d7f61a83ce9e71a2e73f029476f9804 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 | 26 ++++++++++++++++++++++++--
 buildtools/wafsamba/wscript         |  6 ++++++
 2 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/buildtools/wafsamba/samba_python.py b/buildtools/wafsamba/samba_python.py
index 057a017..2e5b342 100644
--- a/buildtools/wafsamba/samba_python.py
+++ b/buildtools/wafsamba/samba_python.py
@@ -40,6 +40,13 @@ 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,8 +61,9 @@ 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
@@ -77,6 +85,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 +105,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 +157,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 abc682f817d401ac38506422acf9672f7926837d 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..1fa61f7 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 conf.env.without_ad_dc:
+            raise Utils.WafError('ADDC requires python')
+
     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 b548b990ee7fc91aa9f16e870eb1cc98d65a47ed 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 84168bd5d47f1c66a831c38f4be5b0d2ee8a34f8 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 a3c33157429d10f76698f1051ea4f8410d62d8ce 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 42de78ce3b21732e8cbf57a50013dc697e125c5d 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 ae0a0a5fc010932ee530c354da0a3853b760d72e 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 8b71aac2384622d3b92261591a16fd8db8ad6759 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 9ee4e69acd28efedb0697957bb7cde5102381948 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 471ae34d31e05f529d0782dc55b67f324afa4815 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 3542e646e6d08f5c24deb9013aec70f1c4986c36 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 dffe6312b0eafb380d1fc1ede4c4261ee28fc8e2 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