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 | VERSION = "@pbs_version@" |
---|
28 | SOURCE_DIR='src' |
---|
29 | |
---|
30 | os.chdir(SOURCE_DIR) |
---|
31 | |
---|
32 | try: |
---|
33 | os.unlink('pbs.py') |
---|
34 | except OSError: |
---|
35 | pass |
---|
36 | |
---|
37 | if LooseVersion(VERSION) >= LooseVersion('4.2'): |
---|
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_4' |
---|
51 | SOURCE_FILE='src/C++/pbs_wrap.cxx' |
---|
52 | |
---|
53 | os.symlink('C++/pbs.py', 'pbs.py') |
---|
54 | |
---|
55 | elif LooseVersion(VERSION) >= LooseVersion('2.4'): |
---|
56 | |
---|
57 | TORQUE_VERSION='TORQUE_2' |
---|
58 | SOURCE_FILE='src/C/pbs_wrap.c' |
---|
59 | |
---|
60 | os.symlink('C/pbs.py', 'pbs.py') |
---|
61 | |
---|
62 | else: |
---|
63 | |
---|
64 | print "Version: %s is not supported" %(VERSION) |
---|
65 | sys.exit(1) |
---|
66 | |
---|
67 | |
---|
68 | os.chdir('..') |
---|
69 | |
---|
70 | setup ( |
---|
71 | name = 'pbs_python', |
---|
72 | version = '4.4.1', |
---|
73 | description = 'openpbs/torque python interface', |
---|
74 | license = 'LGPLV3', |
---|
75 | author = 'Bas van der Vlies', |
---|
76 | author_email = 'bas.vandervlies@surfsara.nl', |
---|
77 | url = 'http://oss.trac.surfsara.nl/pbs_python', |
---|
78 | |
---|
79 | |
---|
80 | extra_path = 'pbs', |
---|
81 | package_dir = { '' : SOURCE_DIR }, |
---|
82 | py_modules = [ 'pbs', 'PBSQuery'], |
---|
83 | |
---|
84 | ext_modules = [ |
---|
85 | Extension( '_pbs', [SOURCE_FILE], |
---|
86 | library_dirs = [ PBS_LIB_DIR ], |
---|
87 | extra_link_args = [ PBS_LIB_COMPILE_LINE ], |
---|
88 | define_macros = [ (TORQUE_VERSION, None) ], |
---|
89 | libraries = LIBS, |
---|
90 | ) |
---|
91 | ] |
---|
92 | ) |
---|