r9944: fix python build
[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 compiler = os.environ.get("CC", "")
41
42 # These variables are filled in by configure
43
44 samba_libs = os.environ.get("LIBS", "")
45
46 obj_list = string.split(samba_objs)
47
48 # Unfortunately the samba_libs variable contains both shared libraries
49 # and linker flags.  The python distutils doesn't like this so we have
50 # to split $samba_libs into a flags component and a library component.
51
52 libraries = []
53 library_dirs = []
54
55 for lib in string.split(samba_libs):
56     if lib[0:2] == "-l":
57         libraries.append(lib[2:])
58         continue
59     if lib[0:8] == "-pthread":
60         libraries.append(lib[2:])
61         continue
62     if lib[0:2] == "-L":
63         library_dirs.append(lib[2:])
64         continue
65     if lib[0:2] == "-W":
66         # Skip linker flags
67         continue
68     print "Unknown entry '%s' in $LIBS variable passed to setup.py" % lib
69     sys.exit(1)
70
71 flags_list = string.split(samba_cflags)
72
73 # Invoke distutils.setup
74
75 setup(
76
77     # Overview information
78     
79     name = "Samba Python Extensions",
80     version = "0.1",
81     author = "Tim Potter",
82     author_email = "tpot@samba.org",
83     license = "GPL",
84
85     # Get the "samba" directory of Python source.  At the moment this
86     # just contains the __init__ file that makes it work as a
87     # subpackage.  This is needed even though everything else is an
88     # extension module.
89     package_dir = {"samba": os.path.join(samba_srcdir, "python", "samba")},
90     packages = ["samba"],
91     
92     # Module list
93     ext_package = "samba", 
94     ext_modules = [
95
96     # SPOOLSS pipe module
97
98     Extension(name = "spoolss",
99               sources = [samba_srcdir + "python/py_spoolss.c",
100                          samba_srcdir + "python/py_common.c",
101                          samba_srcdir + "python/py_conv.c",
102                          samba_srcdir + "python/py_ntsec.c",
103                          samba_srcdir + "python/py_spoolss_common.c",
104                          samba_srcdir + "python/py_spoolss_forms.c",
105                          samba_srcdir + "python/py_spoolss_forms_conv.c",
106                          samba_srcdir + "python/py_spoolss_drivers.c",
107                          samba_srcdir + "python/py_spoolss_drivers_conv.c",
108                          samba_srcdir + "python/py_spoolss_printers.c",
109                          samba_srcdir + "python/py_spoolss_printers_conv.c",
110                          samba_srcdir + "python/py_spoolss_printerdata.c",
111                          samba_srcdir + "python/py_spoolss_ports.c",
112                          samba_srcdir + "python/py_spoolss_ports_conv.c",
113                          samba_srcdir + "python/py_spoolss_jobs.c",
114                          samba_srcdir + "python/py_spoolss_jobs_conv.c",
115                          ],
116               libraries = libraries,
117               library_dirs = ["/usr/kerberos/lib"] + library_dirs,
118               extra_compile_args = flags_list,
119               extra_objects = obj_list),
120
121     # LSA pipe module
122
123     Extension(name = "lsa",
124               sources = [samba_srcdir + "python/py_lsa.c",
125                          samba_srcdir + "python/py_common.c",
126                          samba_srcdir + "python/py_ntsec.c"],
127               libraries = libraries,
128               library_dirs = ["/usr/kerberos/lib"] + library_dirs,
129               extra_compile_args = flags_list,
130               extra_objects = obj_list),
131
132     # SAMR pipe module
133
134     Extension(name = "samr",
135               sources = [samba_srcdir + "python/py_samr.c",
136                          samba_srcdir + "python/py_conv.c",
137                          samba_srcdir + "python/py_samr_conv.c",
138                          samba_srcdir + "python/py_common.c"],
139               libraries = libraries,
140               library_dirs = ["/usr/kerberos/lib"] + library_dirs,
141               extra_compile_args = flags_list,
142               extra_objects = obj_list),
143
144     # winbind client module
145
146     Extension(name = "winbind",
147               sources = [samba_srcdir + "python/py_winbind.c",
148                          samba_srcdir + "python/py_winbind_conv.c",
149                          samba_srcdir + "python/py_conv.c",
150                          samba_srcdir + "python/py_common.c"],
151               libraries = libraries,
152               library_dirs = ["/usr/kerberos/lib"] + library_dirs,
153               extra_compile_args = flags_list,
154               extra_objects = obj_list),
155
156     # WINREG pipe module
157
158     Extension(name = "winreg",
159               sources = [samba_srcdir + "python/py_winreg.c",
160                          samba_srcdir + "python/py_common.c"],
161               libraries = libraries,
162               library_dirs = ["/usr/kerberos/lib"] + library_dirs,
163               extra_compile_args = flags_list,
164               extra_objects = obj_list),
165
166     # SRVSVC pipe module
167
168     Extension(name = "srvsvc",
169               sources = [samba_srcdir + "python/py_srvsvc.c",
170                          samba_srcdir + "python/py_conv.c",
171                          samba_srcdir + "python/py_srvsvc_conv.c",
172                          samba_srcdir + "python/py_common.c"],
173               libraries = libraries,
174               library_dirs = ["/usr/kerberos/lib"] + library_dirs,
175               extra_compile_args = flags_list,
176               extra_objects = obj_list),
177
178     # tdb module
179
180     Extension(name = "tdb",
181               sources = [samba_srcdir + "python/py_tdb.c"],
182               libraries = libraries,
183               library_dirs = ["/usr/kerberos/lib"] + library_dirs,
184               extra_compile_args = flags_list,
185               extra_objects = obj_list),
186
187     # libsmb module
188
189     Extension(name = "smb",
190               sources = [samba_srcdir + "python/py_smb.c",
191                          samba_srcdir + "python/py_common.c",
192                          samba_srcdir + "python/py_ntsec.c"],
193               libraries = libraries,
194               library_dirs = ["/usr/kerberos/lib"] + library_dirs,
195               extra_compile_args = flags_list,
196               extra_objects = obj_list),
197
198     # tdbpack/unpack extensions.  Does not actually link to any Samba
199     # code, although it implements a compatible data format.
200     
201     Extension(name = "tdbpack",
202               sources = [os.path.join(samba_srcdir, "python", "py_tdbpack.c")],
203               extra_compile_args = ["-I."])
204     ],
205 )