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 | |
---|
7 | import sys |
---|
8 | import os |
---|
9 | |
---|
10 | from distutils.core import setup, Extension |
---|
11 | from distutils.spawn import spawn |
---|
12 | |
---|
13 | ## Always unlink previous links |
---|
14 | # |
---|
15 | try: |
---|
16 | os.unlink('pbs.py') |
---|
17 | os.unlink('pbs_wrap.c') |
---|
18 | except OSError: |
---|
19 | pass |
---|
20 | |
---|
21 | swig_cmd = [ 'swig', "-python", "-shadow" , 'pbs.i' ] |
---|
22 | spawn(swig_cmd, verbose=2) |
---|
23 | os.rename('pbs_wrap.c', 'pbs_wrap_2.1.c') |
---|
24 | os.rename('pbs.py', 'pbs_2.1.py') |
---|
25 | |
---|
26 | swig_cmd = [ 'swig', "-DTORQUE_2_4","-python", "-shadow" , 'pbs.i' ] |
---|
27 | spawn(swig_cmd, verbose=2) |
---|
28 | os.rename('pbs_wrap.c', 'pbs_wrap_2.4.c') |
---|
29 | os.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 | # |
---|
35 | PBS_LIB_DIR='' |
---|
36 | NEW_BUILD_SYSTEM=1 |
---|
37 | |
---|
38 | if 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 | |
---|
50 | if 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 | # |
---|
56 | if NEW_BUILD_SYSTEM: |
---|
57 | LIBS = ['torque'] |
---|
58 | else: |
---|
59 | LIBS = ['log', 'net', 'pbs'] |
---|
60 | |
---|
61 | cmd = 'pbs-config --version' |
---|
62 | output = os.popen(cmd).readline() |
---|
63 | l = output.split('.') |
---|
64 | major_version = '.'.join(l[0:2]) |
---|
65 | print major_version |
---|
66 | |
---|
67 | |
---|
68 | if 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') |
---|
72 | else: |
---|
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 | |
---|
77 | setup ( 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 | |
---|