3 # Unix SMB/CIFS implementation.
4 # Module packaging setup for Samba python extensions
6 # Copyright (C) Tim Potter, 2002-2003
7 # Copyright (C) Martin Pool, 2002
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.
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.
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.
24 from distutils
.core
import setup
25 from distutils
.extension
import Extension
27 import sys
, string
, os
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.
34 samba_objs
= os
.environ
.get("PYTHON_OBJS", "")
36 samba_cflags
= os
.environ
.get("PYTHON_CFLAGS", "")
38 samba_srcdir
= os
.environ
.get("SRCDIR", "")
40 compiler
= os
.environ
.get("CC", "")
42 # These variables are filled in by configure
44 samba_libs
= os
.environ
.get("LIBS", "")
46 obj_list
= string
.split(samba_objs
)
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.
58 for lib
in string
.split(samba_libs
):
60 library_dirs
.append(lib
);
62 elif next_is_flag
!= 0:
64 elif lib
== "-Wl,-rpath":
66 elif lib
[0:2] == ("-l"):
67 libraries
.append(lib
[2:])
68 elif lib
[0:8] == ("-pthread"):
69 pass # Skip linker flags
70 elif lib
[0:2] == "-L":
71 library_dirs
.append(lib
[2:])
72 elif lib
[0:2] in ("-W","-s"):
73 pass # Skip linker flags
74 elif lib
[0:2] == "-z":
75 next_is_flag
= 1 # Skip linker flags
77 print "Unknown entry '%s' in $LIBS variable passed to setup.py" % lib
80 flags_list
= string
.split(samba_cflags
)
82 # Invoke distutils.setup
86 # Overview information
88 name
= "Samba Python Extensions",
90 author
= "Tim Potter",
91 author_email
= "tpot@samba.org",
94 # Get the "samba" directory of Python source. At the moment this
95 # just contains the __init__ file that makes it work as a
96 # subpackage. This is needed even though everything else is an
98 package_dir
= {"samba": os
.path
.join(samba_srcdir
, "python", "samba")},
102 ext_package
= "samba",
105 # SPOOLSS pipe module
107 Extension(name
= "spoolss",
108 sources
= [samba_srcdir
+ "python/py_spoolss.c",
109 samba_srcdir
+ "python/py_common.c",
110 samba_srcdir
+ "python/py_conv.c",
111 samba_srcdir
+ "python/py_ntsec.c",
112 samba_srcdir
+ "python/py_spoolss_common.c",
113 samba_srcdir
+ "python/py_spoolss_forms.c",
114 samba_srcdir
+ "python/py_spoolss_forms_conv.c",
115 samba_srcdir
+ "python/py_spoolss_drivers.c",
116 samba_srcdir
+ "python/py_spoolss_drivers_conv.c",
117 samba_srcdir
+ "python/py_spoolss_printers.c",
118 samba_srcdir
+ "python/py_spoolss_printers_conv.c",
119 samba_srcdir
+ "python/py_spoolss_printerdata.c",
120 samba_srcdir
+ "python/py_spoolss_ports.c",
121 samba_srcdir
+ "python/py_spoolss_ports_conv.c",
122 samba_srcdir
+ "python/py_spoolss_jobs.c",
123 samba_srcdir
+ "python/py_spoolss_jobs_conv.c",
125 libraries
= libraries
,
126 library_dirs
= ["/usr/kerberos/lib"] + library_dirs
,
127 extra_compile_args
= flags_list
,
128 extra_objects
= obj_list
),
132 Extension(name
= "lsa",
133 sources
= [samba_srcdir
+ "python/py_lsa.c",
134 samba_srcdir
+ "python/py_common.c",
135 samba_srcdir
+ "python/py_ntsec.c"],
136 libraries
= libraries
,
137 library_dirs
= ["/usr/kerberos/lib"] + library_dirs
,
138 extra_compile_args
= flags_list
,
139 extra_objects
= obj_list
),
143 Extension(name
= "samr",
144 sources
= [samba_srcdir
+ "python/py_samr.c",
145 samba_srcdir
+ "python/py_conv.c",
146 samba_srcdir
+ "python/py_samr_conv.c",
147 samba_srcdir
+ "python/py_common.c"],
148 libraries
= libraries
,
149 library_dirs
= ["/usr/kerberos/lib"] + library_dirs
,
150 extra_compile_args
= flags_list
,
151 extra_objects
= obj_list
),
153 # winbind client module
155 Extension(name
= "winbind",
156 sources
= [samba_srcdir
+ "python/py_winbind.c",
157 samba_srcdir
+ "python/py_winbind_conv.c",
158 samba_srcdir
+ "python/py_conv.c",
159 samba_srcdir
+ "python/py_common.c"],
160 libraries
= libraries
,
161 library_dirs
= ["/usr/kerberos/lib"] + library_dirs
,
162 extra_compile_args
= flags_list
,
163 extra_objects
= obj_list
),
167 Extension(name
= "winreg",
168 sources
= [samba_srcdir
+ "python/py_winreg.c",
169 samba_srcdir
+ "python/py_common.c"],
170 libraries
= libraries
,
171 library_dirs
= ["/usr/kerberos/lib"] + library_dirs
,
172 extra_compile_args
= flags_list
,
173 extra_objects
= obj_list
),
177 Extension(name
= "srvsvc",
178 sources
= [samba_srcdir
+ "python/py_srvsvc.c",
179 samba_srcdir
+ "python/py_conv.c",
180 samba_srcdir
+ "python/py_srvsvc_conv.c",
181 samba_srcdir
+ "python/py_common.c"],
182 libraries
= libraries
,
183 library_dirs
= ["/usr/kerberos/lib"] + library_dirs
,
184 extra_compile_args
= flags_list
,
185 extra_objects
= obj_list
),
189 Extension(name
= "tdb",
190 sources
= [samba_srcdir
+ "python/py_tdb.c"],
191 libraries
= libraries
,
192 library_dirs
= ["/usr/kerberos/lib"] + library_dirs
,
193 extra_compile_args
= flags_list
,
194 extra_objects
= obj_list
),
198 Extension(name
= "smb",
199 sources
= [samba_srcdir
+ "python/py_smb.c",
200 samba_srcdir
+ "python/py_common.c",
201 samba_srcdir
+ "python/py_ntsec.c"],
202 libraries
= libraries
,
203 library_dirs
= ["/usr/kerberos/lib"] + library_dirs
,
204 extra_compile_args
= flags_list
,
205 extra_objects
= obj_list
),
207 # tdbpack/unpack extensions. Does not actually link to any Samba
208 # code, although it implements a compatible data format.
210 Extension(name
= "tdbpack",
211 sources
= [os
.path
.join(samba_srcdir
, "python", "py_tdbpack.c")],
212 extra_compile_args
= ["-I."])