#!/usr/bin/env python
import os
+from waflib import Options, Errors
+
+# work out what python external libraries we need to be successful
+selftest_pkgs = {
+ 'iso8601': 'python3-iso8601',
+ 'cryptography': 'python3-cryptography',
+ 'pyasn1': 'python3-asn1'
+}
+
+ad_dc_pkgs = {
+ 'markdown': 'python3-markdown',
+ 'dns': 'python3-dnspython (python3-dns on some systems)'
+}
+
+
+def find_third_party_module(conf, module, package):
+ conf.COMPOUND_START("Checking for system installation of Python module %s" % module)
+ try:
+ __import__(module)
+ except ImportError:
+ conf.COMPOUND_END(False)
+ raise Errors.WafError("""\
+ Unable to find Python module '%s'. Please install the system package: %s'.
+""" % (module, package))
+ else:
+ # Installed on the system
+ conf.COMPOUND_END("system")
+
def configure(conf):
- kerberos_py = conf.srcdir + "/python/samba/provision/kerberos_implementation.py"
+ if conf.env.disable_python:
+ return
+
+ kerberos_py = conf.srcnode.abspath() + "/python/samba/provision/kerberos_implementation.py"
f = open(kerberos_py, 'w')
try:
finally:
f.close()
+ if conf.CONFIG_GET('ENABLE_SELFTEST'):
+ for module, package in selftest_pkgs.items():
+ find_third_party_module(conf, module, package)
+
+ if not Options.options.without_ad_dc:
+ for module, package in ad_dc_pkgs.items():
+ find_third_party_module(conf, module, package)
+
+
def build(bld):
- for env in bld.gen_python_environments():
- pytalloc_util = bld.pyembed_libname('pytalloc-util')
- pyparam_util = bld.pyembed_libname('pyparam_util')
- libpython = bld.pyembed_libname('LIBPYTHON')
- pyrpc_util = bld.pyembed_libname('pyrpc_util')
- samba_python = bld.pyembed_libname('samba_python')
- bld.SAMBA_LIBRARY(samba_python,
+ pytalloc_util = bld.pyembed_libname('pytalloc-util')
+ pyparam_util = bld.pyembed_libname('pyparam_util')
+ libpython = bld.pyembed_libname('LIBPYTHON')
+ pyrpc_util = bld.pyembed_libname('pyrpc_util')
+ samba_python = bld.pyembed_libname('samba_python')
+ bld.SAMBA_LIBRARY(samba_python,
source=[],
deps='%s %s %s' % (libpython, pytalloc_util, pyrpc_util),
grouping_library=True,
private_library=True,
pyembed=True,
enabled=bld.PYTHON_BUILD_IS_ENABLED())
- bld.SAMBA_PYTHON('python_glue',
- source='pyglue.c',
- deps='''
+ bld.SAMBA_PYTHON('python_glue',
+ source='pyglue.c',
+ deps='''
%s
samba-util
netif
%s
''' % (pyparam_util, pytalloc_util),
- realname='samba/_glue.so')
+ realname='samba/_glue.so')
- bld.SAMBA_SUBSYSTEM(libpython,
- source='modules.c',
- public_deps='',
- init_function_sentinel='{NULL,NULL}',
- deps='talloc',
- pyext=True,
- enabled=bld.PYTHON_BUILD_IS_ENABLED())
+ bld.SAMBA_SUBSYSTEM(libpython,
+ source='modules.c',
+ public_deps='',
+ init_function_sentinel='{NULL,NULL}',
+ deps='talloc',
+ pyext=True,
+ enabled=bld.PYTHON_BUILD_IS_ENABLED())
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',
- installdir='python')
-
- bld.INSTALL_WILDCARD('${PYTHONARCHDIR}', 'samba/**/*.py', flat=False)
+ # install out various python scripts for use by make test
+ bld.SAMBA_SCRIPT('samba_python_files',
+ pattern='samba/**/*.py',
+ installdir='python')
+
+ bld.INSTALL_WILDCARD('${PYTHONARCHDIR}', 'samba/**/*.py', flat=False)