Sync up with 3.0 version.
[samba.git] / source / python / setup.py
1 # -*- mode: python -*-
2 #
3 # Unix SMB/CIFS implementation.
4 # Module packaging setup for Samba python extensions
5 #
6 # Copyright (C) Tim Potter, 2002-2003
7 # Copyright (C) Martin Pool, 2002
8 #
9 # This program is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 2 of the License, or
12 # (at your option) any later version.
13 #   
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 # GNU General Public License for more details.
18 #   
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, write to the Free Software
21 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 #
23
24 from distutils.core import setup
25 from distutils.extension import Extension
26
27 import sys, string, os
28
29 # The Makefile passes in environment variable $PYTHON_OBJ as being the
30 # list of Samba objects.  This kind of goes against the distutils.cmd
31 # method of adding setup commands and will also confuse people who are
32 # familiar with the python Distutils module.
33
34 samba_objs = os.environ.get("PYTHON_OBJS", "")
35
36 samba_cflags = os.environ.get("PYTHON_CFLAGS", "")
37
38 samba_srcdir = os.environ.get("SRCDIR", "")
39
40 # These variables are filled in by configure
41
42 samba_libs = os.environ.get("LIBS", "")
43
44 obj_list = string.split(samba_objs)
45
46 # Unfortunately the samba_libs variable contains both shared libraries
47 # and linker flags.  The python distutils doesn't like this so we have
48 # to split $samba_libs into a flags component and a library component.
49
50 libraries = []
51 library_dirs = []
52
53 for lib in string.split(samba_libs):
54     if lib[0:2] == "-l":
55         libraries.append(lib[2:])
56         continue
57     if lib[0:2] == "-L":
58         library_dirs.append(lib[2:])
59         continue
60     print "Unknown entry '%s' in $LIBS variable passed to setup.py" % lib
61     sys.exit(1)
62
63 flags_list = string.split(samba_cflags)
64
65 # Invoke distutils.setup
66
67 setup(
68
69     # Overview information
70     
71     name = "Samba Python Extensions",
72     version = "0.1",
73     author = "Tim Potter",
74     author_email = "tpot@samba.org",
75     license = "GPL",
76
77     # Get the "samba" directory of Python source.  At the moment this
78     # just contains the __init__ file that makes it work as a
79     # subpackage.  This is needed even though everything else is an
80     # extension module.
81     package_dir = {"samba": os.path.join(samba_srcdir, "python", "samba")},
82     packages = ["samba"],
83     
84     # Module list
85     ext_package = "samba", 
86     ext_modules = [
87
88     # SPOOLSS pipe module
89
90     Extension(name = "spoolss",
91               sources = [samba_srcdir + "python/py_spoolss.c",
92                          samba_srcdir + "python/py_common.c",
93                          samba_srcdir + "python/py_conv.c",
94                          samba_srcdir + "python/py_ntsec.c",
95                          samba_srcdir + "python/py_spoolss_common.c",
96                          samba_srcdir + "python/py_spoolss_forms.c",
97                          samba_srcdir + "python/py_spoolss_forms_conv.c",
98                          samba_srcdir + "python/py_spoolss_drivers.c",
99                          samba_srcdir + "python/py_spoolss_drivers_conv.c",
100                          samba_srcdir + "python/py_spoolss_printers.c",
101                          samba_srcdir + "python/py_spoolss_printers_conv.c",
102                          samba_srcdir + "python/py_spoolss_printerdata.c",
103                          samba_srcdir + "python/py_spoolss_ports.c",
104                          samba_srcdir + "python/py_spoolss_ports_conv.c",
105                          samba_srcdir + "python/py_spoolss_jobs.c",
106                          samba_srcdir + "python/py_spoolss_jobs_conv.c",
107                          ],
108               libraries = libraries,
109               library_dirs = ["/usr/kerberos/lib"] + library_dirs,
110               extra_compile_args = flags_list,
111               extra_objects = obj_list),
112
113     # LSA pipe module
114
115     Extension(name = "lsa",
116               sources = [samba_srcdir + "python/py_lsa.c",
117                          samba_srcdir + "python/py_common.c",
118                          samba_srcdir + "python/py_ntsec.c"],
119               libraries = libraries,
120               library_dirs = ["/usr/kerberos/lib"] + library_dirs,
121               extra_compile_args = flags_list,
122               extra_objects = obj_list),
123
124     # SAMR pipe module
125
126     Extension(name = "samr",
127               sources = [samba_srcdir + "python/py_samr.c",
128                          samba_srcdir + "python/py_conv.c",
129                          samba_srcdir + "python/py_samr_conv.c",
130                          samba_srcdir + "python/py_common.c"],
131               libraries = libraries,
132               library_dirs = ["/usr/kerberos/lib"] + library_dirs,
133               extra_compile_args = flags_list,
134               extra_objects = obj_list),
135
136     # winbind client module
137
138     Extension(name = "winbind",
139               sources = [samba_srcdir + "python/py_winbind.c",
140                          samba_srcdir + "python/py_winbind_conv.c",
141                          samba_srcdir + "python/py_conv.c",
142                          samba_srcdir + "python/py_common.c"],
143               libraries = libraries,
144               library_dirs = ["/usr/kerberos/lib"] + library_dirs,
145               extra_compile_args = flags_list,
146               extra_objects = obj_list),
147
148     # WINREG pipe module
149
150     Extension(name = "winreg",
151               sources = [samba_srcdir + "python/py_winreg.c",
152                          samba_srcdir + "python/py_common.c"],
153               libraries = libraries,
154               library_dirs = ["/usr/kerberos/lib"] + library_dirs,
155               extra_compile_args = flags_list,
156               extra_objects = obj_list),
157
158     # SRVSVC pipe module
159
160     Extension(name = "srvsvc",
161               sources = [samba_srcdir + "python/py_srvsvc.c",
162                          samba_srcdir + "python/py_conv.c",
163                          samba_srcdir + "python/py_srvsvc_conv.c",
164                          samba_srcdir + "python/py_common.c"],
165               libraries = libraries,
166               library_dirs = ["/usr/kerberos/lib"] + library_dirs,
167               extra_compile_args = flags_list,
168               extra_objects = obj_list),
169
170     # tdb module
171
172     Extension(name = "tdb",
173               sources = [samba_srcdir + "python/py_tdb.c"],
174               libraries = libraries,
175               library_dirs = ["/usr/kerberos/lib"] + library_dirs,
176               extra_compile_args = flags_list,
177               extra_objects = obj_list),
178
179     # libsmb module
180
181     Extension(name = "smb",
182               sources = [samba_srcdir + "python/py_smb.c",
183                          samba_srcdir + "python/py_common.c",
184                          samba_srcdir + "python/py_ntsec.c"],
185               libraries = libraries,
186               library_dirs = ["/usr/kerberos/lib"] + library_dirs,
187               extra_compile_args = flags_list,
188               extra_objects = obj_list),
189
190     # tdbpack/unpack extensions.  Does not actually link to any Samba
191     # code, although it implements a compatible data format.
192     
193     Extension(name = "tdbpack",
194               sources = [os.path.join(samba_srcdir, "python", "py_tdbpack.c")],
195               extra_compile_args = ["-I."])
196     ],
197 )