Ticket #36: setup.py.in

File setup.py.in, 2.3 KB (added by stijn.deweirdt@…, 11 years ago)

support for 4.2 in setup.py

Line 
1#!/usr/bin/env python
2#
3# $Id: setup.py 434 2005-11-04 15:02:07Z bas $
4#
5# set ts=4
6#
7
8import sys
9import os
10import glob
11
12from distutils.core import setup, Extension
13from distutils.version import LooseVersion
14
15# Strip off the -L it is also added by the python setup tools
16#
17PBS_LIB_COMPILE_LINE='@pbs_library_compile_line@'
18PBS_LIB_DIR='@pbs_library_dir@'
19
20if not PBS_LIB_DIR:
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)
24
25LIBS = ['torque']
26
27### Make symlinks to right torque version
28#
29VERSION = "@pbs_version@"
30
31os.chdir('src')
32
33## Always unlink previous links
34#
35try:
36    os.unlink('pbs.py')
37    os.unlink('pbs_wrap.c')
38except OSError:
39    pass
40
41if LooseVersion(VERSION) >= LooseVersion('4.2'):
42    inc=os.environ.get('PBS_PYTHON_INCLUDEDIR','/usr/include/torque')
43    os.environ['CC']='g++'
44    os.environ['CFLAGS']=' '.join(os.environ.get('CFLAGS','').split(' ')+['-I%s'%inc])
45
46    if not os.path.exists(os.path.join(inc,'log.h')):
47        print 'Failed to find log.h in inlcude dir %s. (Set incude dir via PBS_PYTHON_INCLUDEDIR variable)'%inc
48        sys.exit(2)
49
50    for fn in glob.glob('*.h'):
51        os.remove(fn)
52
53    os.symlink('pbs_wrap_4.2.c', 'pbs_wrap.c')
54    os.symlink('pbs_2.4.py', 'pbs.py')
55   
56    TORQUE_VERSION='TORQUE_4_2'
57elif LooseVersion(VERSION) >= LooseVersion('2.4.7'):
58    os.symlink('pbs_wrap_2.4.c', 'pbs_wrap.c')
59    os.symlink('pbs_2.4.py', 'pbs.py')
60    TORQUE_VERSION='TORQUE_2_4'
61else:
62    os.symlink('pbs_wrap_2.1.c', 'pbs_wrap.c')
63    os.symlink('pbs_2.1.py', 'pbs.py')
64    TORQUE_VERSION='TORQUE_OLD'
65
66os.chdir('..')
67
68setup ( 
69    name = 'pbs_python',
70    version = '4.3.5',
71    description = 'openpbs/torque python interface',
72    license = 'LGPLV3',
73    author = 'Bas van der Vlies',
74    author_email = 'bas.vandervlies@surfsara.nl',
75    url = 'http://oss.trac.surfsara.nl/pbs_python',
76
77
78    extra_path = 'pbs',
79        package_dir = { '' : 'src' }, 
80        py_modules = [ 'pbs', 'PBSQuery', 'PBSAdvancedParser' ], 
81
82    ext_modules = [ 
83        Extension( '_pbs', ['src/pbs_wrap.c'],
84        library_dirs = [ PBS_LIB_DIR ],
85        extra_link_args = [ PBS_LIB_COMPILE_LINE ],
86        define_macros =  [ (TORQUE_VERSION, None) ],
87        libraries = LIBS,
88        ) 
89    ]
90)