2015-03-28 18:43:29 +03:00
#!/usr/bin/env python
2015-05-18 23:19:23 +03:00
import samba_git
2015-03-28 19:11:51 +03:00
import Utils
2015-03-28 18:43:29 +03:00
import os
2015-03-28 19:11:51 +03:00
import sys
2015-03-28 18:43:29 +03:00
# work out what python external libraries we need to install
2015-03-28 19:11:51 +03:00
external_pkgs = {
2015-03-28 18:43:29 +03:00
"dns.resolver": "dnspython/dns",
"iso8601": "pyiso8601/iso8601",
}
2015-03-28 19:11:51 +03:00
def find_third_party_module(conf, module, package):
conf.COMPOUND_START("Checking for third party Python module %s" % module)
try:
__import__(module)
except ImportError:
pass
else:
# Installed on the system
conf.COMPOUND_END("system")
old_path = sys.path
try:
sys.path.append(os.path.join(conf.curdir, os.path.dirname(package)))
try:
__import__(module)
except ImportError:
2015-05-18 23:19:23 +03:00
if samba_git.has_submodules(conf.srcdir):
2015-03-28 19:11:51 +03:00
raise Utils.WafError("""\
Unable to find Python module '%s'. Please install the system package or check \
2015-05-06 01:05:14 +03:00
out the relevant submodule by running 'git submodule update --init'.
2015-03-28 19:11:51 +03:00
""" % module)
else:
raise Utils.WafError("""\
Unable to find Python module '%s'. Please install the system package or place a copy in
%s.
""" % (module, package))
else:
conf.COMPOUND_END("bundled")
finally:
sys.path = old_path
2015-03-28 18:43:29 +03:00
def configure(conf):
2015-03-28 19:11:51 +03:00
for module, package in external_pkgs.items():
find_third_party_module(conf, module, package)
2017-04-07 16:44:05 +03:00
conf.RECURSE('cmocka')
2015-03-28 18:43:29 +03:00
conf.RECURSE('popt')
conf.RECURSE('zlib')
2017-09-06 19:58:06 +03:00
conf.RECURSE('aesni-intel')
2015-03-28 18:43:29 +03:00
def build(bld):
list = []
2015-03-28 19:11:51 +03:00
for module, package in external_pkgs.items():
2015-03-28 18:43:29 +03:00
try:
__import__(module)
except ImportError:
list.append(package)
for e in list:
bld.INSTALL_WILDCARD('${PYTHONARCHDIR}/samba/third_party', e + '/**/*', flat=False,
exclude='*.pyc', trim_path=os.path.dirname(e))
bld.SAMBA_GENERATOR('third_party_init_py',
rule='touch ${TGT}',
target='empty_file')
bld.INSTALL_FILES('${PYTHONARCHDIR}/samba/third_party', 'empty_file', destname='__init__.py')
2017-04-07 16:44:05 +03:00
bld.RECURSE('cmocka')
2015-03-28 18:43:29 +03:00
bld.RECURSE('zlib')
bld.RECURSE('popt')
2017-09-06 19:58:06 +03:00
bld.RECURSE('aesni-intel')