source: trunk/samba/source/python/setup.py@ 17

Last change on this file since 17 was 1, checked in by Paul Smedley, 18 years ago

Initial code import

File size: 7.7 KB
Line 
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
24from distutils.core import setup
25from distutils.extension import Extension
26
27import 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
34samba_objs = os.environ.get("PYTHON_OBJS", "")
35
36samba_cflags = os.environ.get("PYTHON_CFLAGS", "")
37
38samba_srcdir = os.environ.get("SRCDIR", "")
39
40compiler = os.environ.get("CC", "")
41
42# These variables are filled in by configure
43
44samba_libs = os.environ.get("LIBS", "")
45
46obj_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
52libraries = []
53library_dirs = []
54
55next_is_path = 0
56next_is_flag = 0
57
58for lib in string.split(samba_libs):
59 if next_is_path != 0:
60 library_dirs.append(lib);
61 next_is_path = 0;
62 elif next_is_flag != 0:
63 next_is_flag = 0;
64 elif lib == "-Wl,-rpath":
65 next_is_path = 1;
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
76 else:
77 print "Unknown entry '%s' in $LIBS variable passed to setup.py" % lib
78 sys.exit(1)
79
80flags_list = string.split(samba_cflags)
81
82# Invoke distutils.setup
83
84setup(
85
86 # Overview information
87
88 name = "Samba Python Extensions",
89 version = "0.1",
90 author = "Tim Potter",
91 author_email = "tpot@samba.org",
92 license = "GPL",
93
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
97 # extension module.
98 package_dir = {"samba": os.path.join(samba_srcdir, "python", "samba")},
99 packages = ["samba"],
100
101 # Module list
102 ext_package = "samba",
103 ext_modules = [
104
105 # SPOOLSS pipe module
106
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",
124 ],
125 libraries = libraries,
126 library_dirs = ["/usr/kerberos/lib"] + library_dirs,
127 extra_compile_args = flags_list,
128 extra_objects = obj_list),
129
130 # LSA pipe module
131
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),
140
141 # SAMR pipe module
142
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),
152
153 # winbind client module
154
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),
164
165 # WINREG pipe module
166
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),
174
175 # SRVSVC pipe module
176
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),
186
187 # tdb module
188
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),
195
196 # libsmb module
197
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),
206
207 # tdbpack/unpack extensions. Does not actually link to any Samba
208 # code, although it implements a compatible data format.
209
210 Extension(name = "tdbpack",
211 sources = [os.path.join(samba_srcdir, "python", "py_tdbpack.c")],
212 extra_compile_args = ["-I."])
213 ],
214)
Note: See TracBrowser for help on using the repository browser.