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 | |
---|
11 | from distutils.core import setup, Extension |
---|
12 | |
---|
13 | # Try some usefule defaults if not set |
---|
14 | # |
---|
15 | PBS_LIB_DIR='@pbs_library_dir@' |
---|
16 | NEW_BUILD_SYSTEM=1 |
---|
17 | |
---|
18 | if not PBS_LIB_DIR: |
---|
19 | for dir in ['/usr/lib', '/usr/local/lib', '/opt/pbs/usr/lib', '/usr/lib/torque', '/opt/pbs/lib', '/opt/torque/lib' ]: |
---|
20 | dummy_new = os.path.join(dir, 'libtorque.so') |
---|
21 | dummy_old = os.path.join(dir, 'libpbs.a') |
---|
22 | if os.path.exists(dummy_new): |
---|
23 | PBS_LIB_DIR=dir |
---|
24 | break |
---|
25 | elif os.path.exists(dummy_old): |
---|
26 | PBS_LIB_DIR=dir |
---|
27 | NEW_BUILD_SYSTEM=0 |
---|
28 | break |
---|
29 | |
---|
30 | if not PBS_LIB_DIR: |
---|
31 | print 'Please specify where the PBS libraries are!!' |
---|
32 | print 'edit setup.py and fill in the PBS_LIB_DIR variable' |
---|
33 | sys.exit(1) |
---|
34 | |
---|
35 | # Test if we have all the libs: |
---|
36 | # |
---|
37 | if NEW_BUILD_SYSTEM: |
---|
38 | LIBS = ['torque'] |
---|
39 | else: |
---|
40 | LIBS = ['log', 'net', 'pbs'] |
---|
41 | for lib in LIBS: |
---|
42 | library = 'lib%s.a' %(lib) |
---|
43 | dummy = os.path.join(PBS_LIB_DIR, library) |
---|
44 | if not os.path.exists(dummy): |
---|
45 | print 'You need to install "%s" in %s' %(library, PBS_LIB_DIR) |
---|
46 | sys.exit(1) |
---|
47 | |
---|
48 | ### Make symlinks to right torque version |
---|
49 | # |
---|
50 | VERSION = "@pbs_version@" |
---|
51 | tmp = VERSION.split('.') |
---|
52 | major_version = '.'.join( tmp[0:2] ) |
---|
53 | |
---|
54 | |
---|
55 | |
---|
56 | os.chdir('src') |
---|
57 | |
---|
58 | ## Always unlink previous links |
---|
59 | # |
---|
60 | try: |
---|
61 | os.unlink('pbs.py') |
---|
62 | os.unlink('pbs_wrap.c') |
---|
63 | except OSError: |
---|
64 | pass |
---|
65 | |
---|
66 | if major_version in [ '2.3', '2.4']: |
---|
67 | os.symlink('pbs_wrap_2.4.c', 'pbs_wrap.c') |
---|
68 | os.symlink('pbs_2.4.py', 'pbs.py') |
---|
69 | else: |
---|
70 | os.symlink('pbs_wrap_2.1.c', 'pbs_wrap.c') |
---|
71 | os.symlink('pbs_2.1.py', 'pbs.py') |
---|
72 | os.chdir('..') |
---|
73 | |
---|
74 | setup ( name = 'pbs_python', |
---|
75 | version = '3.8.0', |
---|
76 | description = 'openpbs/torque python interface', |
---|
77 | author = 'Bas van der Vlies', |
---|
78 | author_email = 'basv@sara.nl', |
---|
79 | url = 'http://subtrac.sara.nl/oss/pbs_python', |
---|
80 | |
---|
81 | |
---|
82 | extra_path = 'pbs', |
---|
83 | package_dir = { '' : 'src' }, |
---|
84 | py_modules = [ 'pbs', 'PBSQuery' ], |
---|
85 | |
---|
86 | ext_modules = [ |
---|
87 | Extension( '_pbs', ['src/pbs_wrap.c'], |
---|
88 | library_dirs = [ PBS_LIB_DIR ], |
---|
89 | libraries = LIBS) |
---|
90 | ] |
---|
91 | ) |
---|