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