-
Notifications
You must be signed in to change notification settings - Fork 11
/
setup.py
104 lines (84 loc) · 3 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
"""
PyLSF: Python/Pyrex interface module to LSF Batch Scheduler
"""
from distutils.core import setup
from distutils.extension import Extension
from distutils.command import clean
from distutils.sysconfig import get_python_lib
from Pyrex.Distutils import build_ext
import os, re
import sys, platform
from string import *
from stat import *
# Mininmum of Python 2.3 required because that's what Pyrex-0.9.5 requires
if not hasattr(sys, 'version_info') or sys.version_info < (2,3,0,'final'):
raise SystemExit, "Python 2.3+ or later required to build PyLSF."
# Retrieve the LSF environment variables and work out include dir
lsf_major = 0
lsf_incdir = ""
lsf_libdir = os.getenv("LSF_LIBDIR")
try:
lsf_major = int(os.getenv("LSF_VERSION").split('.')[0])
except AttributeError:
lsf_major = 0
if (lsf_libdir):
LSF_VERSION = re.compile(r'^(?P<lsf_dir>.*lsf|.*lsfhpc)/(?P<lsf_major>\d+).(?P<lsf_minor>\d+)/.*lib$')
LSF_INCDIR = re.compile(r'^(?P<lsf_dir>.*)/(?P<lsf_os>.*)/lib$')
line = LSF_INCDIR.match(lsf_libdir)
if line:
lsf_incdir = line.group("lsf_dir") + "/include"
if not lsf_major:
line = LSF_VERSION.match(lsf_libdir)
if line:
if line.group("lsf_major"):
lsf_major = int(line.group("lsf_major"))
else:
raise SystemExit, "PyLSF: Unable to detect LSF environment......exiting"
print lsf_incdir
include_dirs = [lsf_incdir, '/usr/include']
library_dirs = [lsf_libdir, '/usr/lib64', '/usr/lib']
extra_link_args = [ '']
extra_objects = [ '']
if lsf_major == 7:
libraries = ['bat', 'lsf', 'lsbstream', 'nsl', 'dl', 'crypt' ]
elif lsf_major == 6:
libraries = ['bat','lsf','nsl']
elif lsf_major == 0:
raise SystemExit, "PyLSF: cannot detect any LSF version.....exiting"
else:
raise SystemExit, "PyLSF: detected unsupported LSF version %d.....exiting" % lsf_major
print "PyLSF: detected LSF version %d" % lsf_major
compiler_dir = os.path.join(get_python_lib(prefix=''), 'pylsf/')
# Trove classifiers
classifiers = """\
Development Status :: 4 - Beta
Intended Audience :: Developers
License :: OSI Approved :: GNU General Public License (GPL)
Natural Language :: English
Operating System :: POSIX :: Linux
Programming Language :: Python
Topic :: Software Development :: Libraries :: Python Modules
"""
doclines = __doc__.split("\n")
setup(
name = "PyLSF",
version = "0.0.1",
description = doclines[0],
long_description = "\n".join(doclines[2:]),
author = "Mark Roberts",
author_email = "mark at gingergeeks co uk",
url = "http://www.gingergeeks.co.uk/pylsf/",
classifiers = filter(None, classifiers.split("\n")),
platforms = ["Linux"],
keywords = ["Batch Scheduler", "LSF"],
packages = ["pylsf"],
ext_modules = [
Extension( "pylsf/pylsf",["pylsf/pylsf.pyx"],
libraries = libraries,
library_dirs = library_dirs,
include_dirs = include_dirs,
extra_compile_args = [],
extra_link_args = [] )
],
cmdclass = {"build_ext": build_ext}
)