libndr: Avoid assigning duplicate versions to symbols
[amitay/samba.git] / python / wscript
1 #!/usr/bin/env python
2
3 import os
4 from waflib import Options, Errors
5
6 # work out what python external libraries we need to be successful
7 selftest_pkgs = {
8     'iso8601': 'python3-iso8601',
9     'cryptography': 'python3-cryptography',
10     'pyasn1': 'python3-asn1'
11 }
12
13 ad_dc_pkgs = {
14     'markdown': 'python3-markdown',
15     'dns': 'python3-dnspython (python3-dns on some systems)'
16 }
17
18
19 def find_third_party_module(conf, module, package):
20     conf.COMPOUND_START("Checking for system installation of Python module %s" % module)
21     try:
22         __import__(module)
23     except ImportError:
24         conf.COMPOUND_END(False)
25         raise Errors.WafError("""\
26         Unable to find Python module '%s'. Please install the system package: %s'.
27 """ % (module, package))
28     else:
29         # Installed on the system
30         conf.COMPOUND_END("system")
31
32
33 def configure(conf):
34     if conf.env.disable_python:
35         return
36
37     kerberos_py = conf.srcnode.abspath() + "/python/samba/provision/kerberos_implementation.py"
38
39     f = open(kerberos_py, 'w')
40     try:
41         header = """#
42 # Copyright (c) 2016      Andreas Schneider <asn@samba.org>
43 #
44 # This program is free software; you can redistribute it and/or modify
45 # it under the terms of the GNU General Public License as published by
46 # the Free Software Foundation; either version 3 of the License, or
47 # (at your option) any later version.
48 #
49 # This program is distributed in the hope that it will be useful,
50 # but WITHOUT ANY WARRANTY; without even the implied warranty of
51 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
52 # GNU General Public License for more details.
53 #
54 # You should have received a copy of the GNU General Public License
55 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
56 #
57 """
58         f.write(header)
59
60         data = """kdb_modules_dir = "{0}"
61 """
62
63         if conf.env.HEIMDAL_KRB5_CONFIG:
64             f.write(data.format("", ""))
65         else:
66             modulesdir = "%s/krb5/plugins/kdb" % conf.env.LIBDIR
67
68             f.write(data.format(modulesdir))
69     finally:
70         f.close()
71
72     if conf.CONFIG_GET('ENABLE_SELFTEST'):
73         for module, package in selftest_pkgs.items():
74             find_third_party_module(conf, module, package)
75
76     if not Options.options.without_ad_dc:
77         for module, package in ad_dc_pkgs.items():
78             find_third_party_module(conf, module, package)
79
80
81 def build(bld):
82
83
84     pytalloc_util = bld.pyembed_libname('pytalloc-util')
85     pyparam_util = bld.pyembed_libname('pyparam_util')
86     libpython = bld.pyembed_libname('LIBPYTHON')
87     pyrpc_util = bld.pyembed_libname('pyrpc_util')
88     samba_python = bld.pyembed_libname('samba_python')
89     bld.SAMBA_LIBRARY(samba_python,
90                       source=[],
91                       deps='%s %s %s' % (libpython, pytalloc_util, pyrpc_util),
92                       grouping_library=True,
93                       private_library=True,
94                       pyembed=True,
95                       enabled=bld.PYTHON_BUILD_IS_ENABLED())
96     bld.SAMBA_PYTHON('python_glue',
97                      source='pyglue.c',
98                      deps='''
99                               %s
100                               samba-util
101                               netif
102                               %s
103                               ''' % (pyparam_util, pytalloc_util),
104                      realname='samba/_glue.so')
105
106     bld.SAMBA_SUBSYSTEM(libpython,
107                         source='modules.c',
108                         public_deps='',
109                         init_function_sentinel='{NULL,NULL}',
110                         deps='talloc',
111                         pyext=True,
112                         enabled=bld.PYTHON_BUILD_IS_ENABLED())
113
114     if bld.PYTHON_BUILD_IS_ENABLED():
115         # install out various python scripts for use by make test
116         bld.SAMBA_SCRIPT('samba_python_files',
117                          pattern='samba/**/*.py',
118                          installdir='python')
119         
120         bld.INSTALL_WILDCARD('${PYTHONARCHDIR}', 'samba/**/*.py', flat=False)