2002-03-19 22:55:21 +00:00
# -*- mode: python -*-
#
# Unix SMB/CIFS implementation.
# Module packaging setup for Samba python extensions
#
2003-02-19 22:47:49 +00:00
# Copyright (C) Tim Potter, 2002-2003
2002-09-09 08:34:35 +00:00
# Copyright (C) Martin Pool, 2002
2002-03-19 22:55:21 +00:00
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
2007-07-09 19:46:27 +00:00
# the Free Software Foundation; either version 3 of the License, or
2002-03-19 22:55:21 +00:00
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
2007-07-10 05:23:25 +00:00
# along with this program; if not, see <http://www.gnu.org/licenses/>.
2002-03-19 22:55:21 +00:00
#
from distutils . core import setup
from distutils . extension import Extension
import sys , string , os
# The Makefile passes in environment variable $PYTHON_OBJ as being the
# list of Samba objects. This kind of goes against the distutils.cmd
# method of adding setup commands and will also confuse people who are
# familiar with the python Distutils module.
2002-09-09 07:49:25 +00:00
samba_objs = os . environ . get ( " PYTHON_OBJS " , " " )
2002-03-19 22:55:21 +00:00
2002-09-09 07:49:25 +00:00
samba_cflags = os . environ . get ( " PYTHON_CFLAGS " , " " )
2002-03-19 22:55:21 +00:00
2002-09-09 07:49:25 +00:00
samba_srcdir = os . environ . get ( " SRCDIR " , " " )
2002-03-26 06:23:28 +00:00
2005-07-18 08:25:21 +00:00
compiler = os . environ . get ( " CC " , " " )
2002-03-19 22:55:21 +00:00
# These variables are filled in by configure
2002-09-09 07:49:25 +00:00
samba_libs = os . environ . get ( " LIBS " , " " )
2002-03-19 22:55:21 +00:00
obj_list = string . split ( samba_objs )
2003-05-05 06:21:26 +00:00
# Unfortunately the samba_libs variable contains both shared libraries
# and linker flags. The python distutils doesn't like this so we have
# to split $samba_libs into a flags component and a library component.
libraries = [ ]
library_dirs = [ ]
2002-03-19 22:55:21 +00:00
2005-10-07 12:14:25 +00:00
next_is_path = 0
next_is_flag = 0
2002-03-19 22:55:21 +00:00
for lib in string . split ( samba_libs ) :
2005-10-07 12:14:25 +00:00
if next_is_path != 0 :
library_dirs . append ( lib ) ;
next_is_path = 0 ;
elif next_is_flag != 0 :
next_is_flag = 0 ;
elif lib == " -Wl,-rpath " :
next_is_path = 1 ;
2006-01-31 10:39:45 +00:00
elif lib [ 0 : 2 ] == ( " -l " ) :
2005-09-02 09:06:33 +00:00
libraries . append ( lib [ 2 : ] )
2006-01-31 10:39:45 +00:00
elif lib [ 0 : 8 ] == ( " -pthread " ) :
2005-12-22 22:15:52 +00:00
pass # Skip linker flags
2007-05-14 09:47:58 +00:00
elif lib [ 0 : 4 ] == ( " -pie " ) :
pass # Skip linker flags
2005-10-07 12:14:25 +00:00
elif lib [ 0 : 2 ] == " -L " :
2003-05-05 06:21:26 +00:00
library_dirs . append ( lib [ 2 : ] )
2005-10-07 12:14:25 +00:00
elif lib [ 0 : 2 ] in ( " -W " , " -s " ) :
pass # Skip linker flags
elif lib [ 0 : 2 ] == " -z " :
next_is_flag = 1 # Skip linker flags
else :
print " Unknown entry ' %s ' in $LIBS variable passed to setup.py " % lib
sys . exit ( 1 )
2002-03-19 22:55:21 +00:00
2002-03-20 06:29:23 +00:00
flags_list = string . split ( samba_cflags )
2002-03-19 22:55:21 +00:00
# Invoke distutils.setup
setup (
# Overview information
name = " Samba Python Extensions " ,
version = " 0.1 " ,
author = " Tim Potter " ,
author_email = " tpot@samba.org " ,
license = " GPL " ,
2002-09-09 08:34:35 +00:00
# Get the "samba" directory of Python source. At the moment this
# just contains the __init__ file that makes it work as a
# subpackage. This is needed even though everything else is an
# extension module.
package_dir = { " samba " : os . path . join ( samba_srcdir , " python " , " samba " ) } ,
packages = [ " samba " ] ,
2002-03-19 22:55:21 +00:00
# Module list
2002-09-09 08:34:35 +00:00
ext_package = " samba " ,
2002-03-20 06:29:23 +00:00
ext_modules = [
# SPOOLSS pipe module
Extension ( name = " spoolss " ,
2002-03-26 06:23:28 +00:00
sources = [ samba_srcdir + " python/py_spoolss.c " ,
2002-03-26 11:09:07 +00:00
samba_srcdir + " python/py_common.c " ,
2002-03-28 04:14:43 +00:00
samba_srcdir + " python/py_conv.c " ,
2002-04-14 09:04:12 +00:00
samba_srcdir + " python/py_ntsec.c " ,
2003-02-19 22:47:49 +00:00
samba_srcdir + " python/py_spoolss_common.c " ,
2002-03-28 04:14:43 +00:00
samba_srcdir + " python/py_spoolss_forms.c " ,
2002-04-05 05:55:23 +00:00
samba_srcdir + " python/py_spoolss_forms_conv.c " ,
2002-03-28 04:14:43 +00:00
samba_srcdir + " python/py_spoolss_drivers.c " ,
2002-04-05 05:55:23 +00:00
samba_srcdir + " python/py_spoolss_drivers_conv.c " ,
2002-03-28 04:14:43 +00:00
samba_srcdir + " python/py_spoolss_printers.c " ,
2002-04-05 04:57:06 +00:00
samba_srcdir + " python/py_spoolss_printers_conv.c " ,
2002-05-13 07:30:41 +00:00
samba_srcdir + " python/py_spoolss_printerdata.c " ,
2002-03-28 04:14:43 +00:00
samba_srcdir + " python/py_spoolss_ports.c " ,
2002-04-05 05:55:23 +00:00
samba_srcdir + " python/py_spoolss_ports_conv.c " ,
2002-05-07 07:06:10 +00:00
samba_srcdir + " python/py_spoolss_jobs.c " ,
samba_srcdir + " python/py_spoolss_jobs_conv.c " ,
2002-03-28 04:14:43 +00:00
] ,
2003-05-05 06:21:26 +00:00
libraries = libraries ,
library_dirs = [ " /usr/kerberos/lib " ] + library_dirs ,
2002-09-19 05:49:14 +00:00
extra_compile_args = flags_list ,
2002-03-20 06:29:23 +00:00
extra_objects = obj_list ) ,
# LSA pipe module
Extension ( name = " lsa " ,
2002-03-26 06:23:28 +00:00
sources = [ samba_srcdir + " python/py_lsa.c " ,
2002-04-14 09:04:12 +00:00
samba_srcdir + " python/py_common.c " ,
samba_srcdir + " python/py_ntsec.c " ] ,
2003-05-05 06:21:26 +00:00
libraries = libraries ,
library_dirs = [ " /usr/kerberos/lib " ] + library_dirs ,
2002-09-19 05:49:14 +00:00
extra_compile_args = flags_list ,
2002-03-20 06:29:23 +00:00
extra_objects = obj_list ) ,
2002-04-15 07:29:47 +00:00
# SAMR pipe module
Extension ( name = " samr " ,
sources = [ samba_srcdir + " python/py_samr.c " ,
2003-04-14 01:15:11 +00:00
samba_srcdir + " python/py_conv.c " ,
2002-08-27 01:49:51 +00:00
samba_srcdir + " python/py_samr_conv.c " ,
2002-04-15 07:29:47 +00:00
samba_srcdir + " python/py_common.c " ] ,
2003-05-05 06:21:26 +00:00
libraries = libraries ,
library_dirs = [ " /usr/kerberos/lib " ] + library_dirs ,
2002-09-19 05:49:14 +00:00
extra_compile_args = flags_list ,
2002-04-15 07:29:47 +00:00
extra_objects = obj_list ) ,
2002-03-20 06:29:23 +00:00
# winbind client module
Extension ( name = " winbind " ,
2002-03-26 06:23:28 +00:00
sources = [ samba_srcdir + " python/py_winbind.c " ,
2002-09-11 04:55:45 +00:00
samba_srcdir + " python/py_winbind_conv.c " ,
samba_srcdir + " python/py_conv.c " ,
2002-03-26 06:23:28 +00:00
samba_srcdir + " python/py_common.c " ] ,
2003-05-05 06:21:26 +00:00
libraries = libraries ,
library_dirs = [ " /usr/kerberos/lib " ] + library_dirs ,
2002-09-19 05:49:14 +00:00
extra_compile_args = flags_list ,
extra_objects = obj_list ) ,
2002-05-13 07:30:41 +00:00
# WINREG pipe module
Extension ( name = " winreg " ,
sources = [ samba_srcdir + " python/py_winreg.c " ,
samba_srcdir + " python/py_common.c " ] ,
2003-05-05 06:21:26 +00:00
libraries = libraries ,
library_dirs = [ " /usr/kerberos/lib " ] + library_dirs ,
2002-09-19 05:49:14 +00:00
extra_compile_args = flags_list ,
2002-05-13 07:30:41 +00:00
extra_objects = obj_list ) ,
2002-05-21 07:43:35 +00:00
2003-02-19 22:47:49 +00:00
# SRVSVC pipe module
Extension ( name = " srvsvc " ,
sources = [ samba_srcdir + " python/py_srvsvc.c " ,
samba_srcdir + " python/py_conv.c " ,
samba_srcdir + " python/py_srvsvc_conv.c " ,
samba_srcdir + " python/py_common.c " ] ,
2003-05-05 06:21:26 +00:00
libraries = libraries ,
library_dirs = [ " /usr/kerberos/lib " ] + library_dirs ,
2003-02-19 22:47:49 +00:00
extra_compile_args = flags_list ,
extra_objects = obj_list ) ,
2002-05-21 07:43:35 +00:00
# tdb module
Extension ( name = " tdb " ,
sources = [ samba_srcdir + " python/py_tdb.c " ] ,
2003-05-05 06:21:26 +00:00
libraries = libraries ,
library_dirs = [ " /usr/kerberos/lib " ] + library_dirs ,
2002-09-19 05:49:14 +00:00
extra_compile_args = flags_list ,
2002-05-21 07:43:35 +00:00
extra_objects = obj_list ) ,
2002-07-29 03:50:35 +00:00
# libsmb module
Extension ( name = " smb " ,
sources = [ samba_srcdir + " python/py_smb.c " ,
2002-11-04 20:33:16 +00:00
samba_srcdir + " python/py_common.c " ,
samba_srcdir + " python/py_ntsec.c " ] ,
2003-05-05 06:21:26 +00:00
libraries = libraries ,
library_dirs = [ " /usr/kerberos/lib " ] + library_dirs ,
2002-09-19 05:49:14 +00:00
extra_compile_args = flags_list ,
2002-07-29 03:50:35 +00:00
extra_objects = obj_list ) ,
2002-09-09 08:06:17 +00:00
# tdbpack/unpack extensions. Does not actually link to any Samba
# code, although it implements a compatible data format.
2003-03-20 01:03:11 +00:00
2002-09-09 08:06:17 +00:00
Extension ( name = " tdbpack " ,
2002-12-05 23:05:28 +00:00
sources = [ os . path . join ( samba_srcdir , " python " , " py_tdbpack.c " ) ] ,
2002-12-12 00:08:55 +00:00
extra_compile_args = [ " -I. " ] )
2002-05-13 07:30:41 +00:00
] ,
2002-03-19 22:55:21 +00:00
)