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 | |
---|
8 | import sys |
---|
9 | import os |
---|
10 | import glob |
---|
11 | |
---|
12 | from distutils.core import setup, Extension |
---|
13 | from distutils.version import LooseVersion |
---|
14 | |
---|
15 | # Strip off the -L it is also added by the python setup tools |
---|
16 | # |
---|
17 | PBS_LIB_COMPILE_LINE='@pbs_library_compile_line@' |
---|
18 | PBS_LIB_DIR='@pbs_library_dir@' |
---|
19 | |
---|
20 | if 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 | |
---|
25 | LIBS = ['torque'] |
---|
26 | |
---|
27 | ### Make symlinks to right torque version |
---|
28 | # |
---|
29 | VERSION = "@pbs_version@" |
---|
30 | |
---|
31 | os.chdir('src') |
---|
32 | |
---|
33 | ## Always unlink previous links |
---|
34 | # |
---|
35 | try: |
---|
36 | os.unlink('pbs.py') |
---|
37 | os.unlink('pbs_wrap.c') |
---|
38 | except OSError: |
---|
39 | pass |
---|
40 | |
---|
41 | if 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' |
---|
57 | elif 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' |
---|
61 | else: |
---|
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 | |
---|
66 | os.chdir('..') |
---|
67 | |
---|
68 | setup ( |
---|
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 | ) |
---|