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:4] == ("-pie"):
71 pass # Skip linker flags
72 elif lib
[0:2] == "-L":
73 library_dirs
.append(lib
[2:])
74 elif lib
[0:2] in ("-W","-s"):
75 pass # Skip linker flags
76 elif lib
[0:2] == "-z":
77 next_is_flag
= 1 # Skip linker flags
79 print "Unknown entry '%s' in $LIBS variable passed to setup.py" % lib
82 flags_list
= string
.split(samba_cflags
)
84 # Invoke distutils.setup
88 # Overview information
90 name
= "Samba Python Extensions",
92 author
= "Tim Potter",
93 author_email
= "tpot@samba.org",
96 # Get the "samba" directory of Python source. At the moment this
97 # just contains the __init__ file that makes it work as a
98 # subpackage. This is needed even though everything else is an
100 package_dir
= {"samba": os
.path
.join(samba_srcdir
, "python", "samba")},
101 packages
= ["samba"],
104 ext_package
= "samba",
107 # SPOOLSS pipe module
109 Extension(name
= "spoolss",
110 sources
= [samba_srcdir
+ "python/py_spoolss.c",
111 samba_srcdir
+ "python/py_common.c",
112 samba_srcdir
+ "python/py_conv.c",
113 samba_srcdir
+ "python/py_ntsec.c",
114 samba_srcdir
+ "python/py_spoolss_common.c",
115 samba_srcdir
+ "python/py_spoolss_forms.c",
116 samba_srcdir
+ "python/py_spoolss_forms_conv.c",
117 samba_srcdir
+ "python/py_spoolss_drivers.c",
118 samba_srcdir
+ "python/py_spoolss_drivers_conv.c",
119 samba_srcdir
+ "python/py_spoolss_printers.c",
120 samba_srcdir
+ "python/py_spoolss_printers_conv.c",
121 samba_srcdir
+ "python/py_spoolss_printerdata.c",
122 samba_srcdir
+ "python/py_spoolss_ports.c",
123 samba_srcdir
+ "python/py_spoolss_ports_conv.c",
124 samba_srcdir
+ "python/py_spoolss_jobs.c",
125 samba_srcdir
+ "python/py_spoolss_jobs_conv.c",
127 libraries
= libraries
,
128 library_dirs
= ["/usr/kerberos/lib"] + library_dirs
,
129 extra_compile_args
= flags_list
,
130 extra_objects
= obj_list
),
134 Extension(name
= "lsa",
135 sources
= [samba_srcdir
+ "python/py_lsa.c",
136 samba_srcdir
+ "python/py_common.c",
137 samba_srcdir
+ "python/py_ntsec.c"],
138 libraries
= libraries
,
139 library_dirs
= ["/usr/kerberos/lib"] + library_dirs
,
140 extra_compile_args
= flags_list
,
141 extra_objects
= obj_list
),
145 Extension(name
= "samr",
146 sources
= [samba_srcdir
+ "python/py_samr.c",
147 samba_srcdir
+ "python/py_conv.c",
148 samba_srcdir
+ "python/py_samr_conv.c",
149 samba_srcdir
+ "python/py_common.c"],
150 libraries
= libraries
,
151 library_dirs
= ["/usr/kerberos/lib"] + library_dirs
,
152 extra_compile_args
= flags_list
,
153 extra_objects
= obj_list
),
155 # winbind client module
157 Extension(name
= "winbind",
158 sources
= [samba_srcdir
+ "python/py_winbind.c",
159 samba_srcdir
+ "python/py_winbind_conv.c",
160 samba_srcdir
+ "python/py_conv.c",
161 samba_srcdir
+ "python/py_common.c"],
162 libraries
= libraries
,
163 library_dirs
= ["/usr/kerberos/lib"] + library_dirs
,
164 extra_compile_args
= flags_list
,
165 extra_objects
= obj_list
),
169 Extension(name
= "winreg",
170 sources
= [samba_srcdir
+ "python/py_winreg.c",
171 samba_srcdir
+ "python/py_common.c"],
172 libraries
= libraries
,
173 library_dirs
= ["/usr/kerberos/lib"] + library_dirs
,
174 extra_compile_args
= flags_list
,
175 extra_objects
= obj_list
),
179 Extension(name
= "srvsvc",
180 sources
= [samba_srcdir
+ "python/py_srvsvc.c",
181 samba_srcdir
+ "python/py_conv.c",
182 samba_srcdir
+ "python/py_srvsvc_conv.c",
183 samba_srcdir
+ "python/py_common.c"],
184 libraries
= libraries
,
185 library_dirs
= ["/usr/kerberos/lib"] + library_dirs
,
186 extra_compile_args
= flags_list
,
187 extra_objects
= obj_list
),
191 Extension(name
= "tdb",
192 sources
= [samba_srcdir
+ "python/py_tdb.c"],
193 libraries
= libraries
,
194 library_dirs
= ["/usr/kerberos/lib"] + library_dirs
,
195 extra_compile_args
= flags_list
,
196 extra_objects
= obj_list
),
200 Extension(name
= "smb",
201 sources
= [samba_srcdir
+ "python/py_smb.c",
202 samba_srcdir
+ "python/py_common.c",
203 samba_srcdir
+ "python/py_ntsec.c"],
204 libraries
= libraries
,
205 library_dirs
= ["/usr/kerberos/lib"] + library_dirs
,
206 extra_compile_args
= flags_list
,
207 extra_objects
= obj_list
),
209 # tdbpack/unpack extensions. Does not actually link to any Samba
210 # code, although it implements a compatible data format.
212 Extension(name
= "tdbpack",
213 sources
= [os
.path
.join(samba_srcdir
, "python", "py_tdbpack.c")],
214 extra_compile_args
= ["-I."])