source: devel/C/setup.py

Last change on this file was 309, checked in by bas, 10 years ago

Checkin the pbs swig development files

File size: 2.2 KB
Line 
1#!/usr/bin/env python
2#
3# Author: Bas van der Vlies <bas.vandervlies@surfsara.nl>
4#
5# $Id: setup.py 531 2010-04-07 13:13:29Z bas $
6
7import sys
8import os
9
10from distutils.core import setup, Extension
11from distutils.spawn import spawn
12
13## Always unlink previous links
14#
15try:
16    os.unlink('pbs.py')
17    os.unlink('pbs_wrap.c')
18except OSError:
19    pass
20
21swig_cmd = [ 'swig', "-python", "-shadow" , 'pbs.i' ]
22spawn(swig_cmd, verbose=2)
23os.rename('pbs_wrap.c', 'pbs_wrap_2.1.c')
24os.rename('pbs.py', 'pbs_2.1.py')
25
26swig_cmd = [ 'swig', "-DTORQUE_2_4","-python", "-shadow" , 'pbs.i' ]
27spawn(swig_cmd, verbose=2)
28os.rename('pbs_wrap.c', 'pbs_wrap_2.4.c')
29os.rename('pbs.py', 'pbs_2.4.py')
30
31
32# The location of the pbs libraries. If left blank
33# then we try to find out where the libraries are
34#
35PBS_LIB_DIR=''
36NEW_BUILD_SYSTEM=1
37
38if not PBS_LIB_DIR:
39  for dir in ['/usr/local/lib', '/opt/pbs/usr/lib', '/usr/lib/torque', '/usr/lib' ]:
40    dummy_new = os.path.join(dir, 'libtorque.so')
41    dummy_old = os.path.join(dir, 'libpbs.a')
42    if os.path.exists(dummy_new):
43      PBS_LIB_DIR=dir
44      break
45    elif os.path.exists(dummy_old):
46      PBS_LIB_DIR=dir
47      NEW_BUILD_SYSTEM=0
48      break
49
50if not PBS_LIB_DIR:
51  print 'Please specify where the PBS libraries are!!'
52  print 'edit setup.py and fill in the PBS_LIB_DIR variable'
53
54# Do we use the old or new build system
55#
56if NEW_BUILD_SYSTEM:
57  LIBS = ['torque']
58else:
59  LIBS = ['log', 'net', 'pbs']
60
61cmd = 'pbs-config --version'
62output = os.popen(cmd).readline()
63l = output.split('.')
64major_version = '.'.join(l[0:2])
65print major_version
66
67
68if major_version in [ '2.3', '2.4']:
69        has_new_functions = '1'
70        os.symlink('pbs_wrap_2.4.c', 'pbs_wrap.c')
71        os.symlink('pbs_2.4.py', 'pbs.py')
72else:
73        has_new_functions = '0'
74        os.symlink('pbs_wrap_2.1.c', 'pbs_wrap.c')
75        os.symlink('pbs_2.1.py', 'pbs.py')
76       
77setup ( name = 'pbs_python',
78        version = '2.9.8-beta',
79        description = 'pbs python interface',
80        author = 'Bas van der Vlies',
81        author_email = 'basv@sara.nl',
82        url = 'http://www.sara.nl/beowulf',
83
84        # extra_path = 'pbs',
85        # package_dir = { '' : 'src' },
86        py_modules = [ 'pbs' ],
87       
88        ext_modules = [ 
89          Extension( '_pbs', ['pbs_wrap.c'] ,
90          library_dirs = [ PBS_LIB_DIR ], 
91          define_macros =  [ ('TORQUE_2_4', None) ],
92          libraries = LIBS
93          ) 
94        ]
95)
96
Note: See TracBrowser for help on using the repository browser.