source: trunk/setup.py.in

Last change on this file was 363, checked in by martijk, 6 years ago

use system python

File size: 2.7 KB
RevLine 
[363]1#!@PYTHON@
[95]2#
3# $Id: setup.py 434 2005-11-04 15:02:07Z bas $
[110]4#
5# set ts=4
6#
[95]7
8import sys
9import os
[300]10import glob
[95]11
12from distutils.core import setup, Extension
[300]13from distutils.version import LooseVersion
[95]14
[230]15# Strip off the -L it is also added by the python setup tools
[97]16#
[236]17PBS_LIB_COMPILE_LINE='@pbs_library_compile_line@'
[216]18PBS_LIB_DIR='@pbs_library_dir@'
[110]19
[95]20if not PBS_LIB_DIR:
[290]21    print 'Please specify where the PBS libraries are!!'
22    print 'edit setup.py and fill in the PBS_LIB_DIR variable'
23    sys.exit(1)
[95]24
[221]25LIBS = ['torque']
[95]26
[216]27VERSION = "@pbs_version@"
[300]28SOURCE_DIR='src'
[215]29
[300]30os.chdir(SOURCE_DIR)
[216]31
32try:
[290]33    os.unlink('pbs.py')
[216]34except OSError:
[290]35    pass
[216]36
[336]37if LooseVersion(VERSION) >= LooseVersion('5.0'):
38
39    inc=os.environ.get('PBS_PYTHON_INCLUDEDIR','/usr/include/torque')
40    os.environ['CC']='g++'
41    os.environ['CFLAGS']=' '.join(os.environ.get('CFLAGS','').split(' ')+['-I%s'%inc])
42   
43    if not os.path.exists(os.path.join(inc,'log.h')):
44        print 'Failed to find log.h in include dir %s. (Set include dir via PBS_PYTHON_INCLUDEDIR variable)'%inc
45        sys.exit(2)
46 
47    for fn in glob.glob('*.h'):
48        os.remove(fn)
49     
50    TORQUE_VERSION='TORQUE_5'
51    SOURCE_FILE='src/5.x/pbs_wrap.cxx'
52
[337]53    os.symlink('5.x/pbs.py', 'pbs.py')
[336]54
[338]55elif LooseVersion(VERSION) >= LooseVersion('4.2'):
[300]56
57    inc=os.environ.get('PBS_PYTHON_INCLUDEDIR','/usr/include/torque')
58    os.environ['CC']='g++'
59    os.environ['CFLAGS']=' '.join(os.environ.get('CFLAGS','').split(' ')+['-I%s'%inc])
60   
61    if not os.path.exists(os.path.join(inc,'log.h')):
[313]62        print 'Failed to find log.h in include dir %s. (Set include dir via PBS_PYTHON_INCLUDEDIR variable)'%inc
[300]63        sys.exit(2)
64 
65    for fn in glob.glob('*.h'):
66        os.remove(fn)
67     
68    TORQUE_VERSION='TORQUE_4'
69    SOURCE_FILE='src/C++/pbs_wrap.cxx'
70
71    os.symlink('C++/pbs.py', 'pbs.py')
72
73elif LooseVersion(VERSION) >= LooseVersion('2.4'):
74
75    TORQUE_VERSION='TORQUE_2'
76    SOURCE_FILE='src/C/pbs_wrap.c'
77
[305]78    os.symlink('C/pbs.py', 'pbs.py')
[300]79
[216]80else:
[218]81
[300]82    print "Version: %s is not supported" %(VERSION)
83    sys.exit(1)
84
85
[216]86os.chdir('..')
87
[241]88setup (
[290]89    name = 'pbs_python',
[353]90    version = '@pbs_python_version@',
[290]91    description = 'openpbs/torque python interface',
92    license = 'LGPLV3',
93    author = 'Bas van der Vlies',
94    author_email = 'bas.vandervlies@surfsara.nl',
95    url = 'http://oss.trac.surfsara.nl/pbs_python',
[95]96
[173]97
[290]98    extra_path = 'pbs',
[300]99        package_dir = { '' : SOURCE_DIR },
100        py_modules = [ 'pbs',  'PBSQuery'],
[95]101
[290]102    ext_modules = [
[300]103        Extension( '_pbs', [SOURCE_FILE],
[290]104        library_dirs = [ PBS_LIB_DIR ],
105        extra_link_args = [ PBS_LIB_COMPILE_LINE ],
106        define_macros =  [ (TORQUE_VERSION, None) ],
107        libraries = LIBS,
108        )
109    ]
[95]110)
Note: See TracBrowser for help on using the repository browser.