smbd:vfs: fix mis-spellings of hierarchy in comments
[samba.git] / third_party / wscript
1 #!/usr/bin/env python
2
3 import os
4 import sys
5 import samba_git
6 from waflib import Options, Utils
7
8 # work out what python external libraries we need to install
9 external_pkgs = {
10     "dns.resolver": "dnspython/dns",
11     "iso8601": "pyiso8601/iso8601",
12     }
13
14
15 def find_third_party_module(conf, module, package):
16     conf.COMPOUND_START("Checking for third party Python module %s" % module)
17     try:
18         __import__(module)
19     except ImportError:
20         pass
21     else:
22         # Installed on the system
23         conf.COMPOUND_END("system")
24
25     old_path = sys.path
26     try:
27         sys.path.append(os.path.join(conf.path.abspath(), os.path.dirname(package)))
28         try:
29             __import__(module)
30         except ImportError:
31             if samba_git.has_submodules(conf.srcnode.abspath()):
32                 raise Utils.WafError("""\
33 Unable to find Python module '%s'. Please install the system package or check \
34 out the relevant submodule by running 'git submodule update --init'.
35 """ % module)
36             else:
37                 raise Utils.WafError("""\
38 Unable to find Python module '%s'. Please install the system package or place a copy in
39 %s.
40 """ % (module, package))
41         else:
42             conf.COMPOUND_END("bundled")
43     finally:
44         sys.path = old_path
45
46
47 def configure(conf):
48     for module, package in external_pkgs.items():
49         find_third_party_module(conf, module, package)
50     conf.RECURSE('cmocka')
51     conf.RECURSE('popt')
52     conf.RECURSE('zlib')
53     conf.RECURSE('aesni-intel')
54     if conf.CONFIG_GET('ENABLE_SELFTEST'):
55         conf.RECURSE('socket_wrapper')
56         conf.RECURSE('nss_wrapper')
57         conf.RECURSE('resolv_wrapper')
58         conf.RECURSE('uid_wrapper')
59         if Options.options.with_pam:
60             conf.RECURSE('pam_wrapper')
61
62
63 def build(bld):
64     list = []
65
66     for module, package in external_pkgs.items():
67         try:
68             __import__(module)
69         except ImportError:
70             list.append(package)
71
72     for e in list:
73         bld.INSTALL_WILDCARD('${PYTHONARCHDIR}/samba/third_party', e + '/**/*', flat=False,
74                              exclude='*.pyc', trim_path=os.path.dirname(e))
75
76     bld.SAMBA_GENERATOR('third_party_init_py',
77                         rule='touch ${TGT}',
78                         target='empty_file')
79
80     bld.INSTALL_FILES('${PYTHONARCHDIR}/samba/third_party', 'empty_file', destname='__init__.py')
81     bld.RECURSE('cmocka')
82     bld.RECURSE('zlib')
83     bld.RECURSE('popt')
84     bld.RECURSE('aesni-intel')
85     if bld.CONFIG_GET('SOCKET_WRAPPER'):
86         bld.RECURSE('socket_wrapper')
87     if bld.CONFIG_GET('NSS_WRAPPER'):
88         bld.RECURSE('nss_wrapper')
89     if bld.CONFIG_GET('RESOLV_WRAPPER'):
90         bld.RECURSE('resolv_wrapper')
91     if bld.CONFIG_GET('UID_WRAPPER'):
92         bld.RECURSE('uid_wrapper')
93     if bld.CONFIG_GET('PAM_WRAPPER'):
94         bld.RECURSE('pam_wrapper')