1 |
#!/usr/bin/env python |
2 |
# |
3 |
# i-scream pystatgrab |
4 |
# http://www.i-scream.org/pystatgrab/ |
5 |
# Copyright (C) 2000-2004 i-scream |
6 |
# |
7 |
# This program is free software; you can redistribute it and/or |
8 |
# modify it under the terms of the GNU General Public License |
9 |
# as published by the Free Software Foundation; either version 2 |
10 |
# of the License, or (at your option) any later version. |
11 |
# |
12 |
# This program is distributed in the hope that it will be useful, |
13 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 |
# GNU General Public License for more details. |
16 |
# |
17 |
# You should have received a copy of the GNU General Public License |
18 |
# along with this program; if not, write to the Free Software |
19 |
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
20 |
# |
21 |
# $Id: setup.py,v 1.22 2007/07/13 22:19:56 tdb Exp $ |
22 |
# |
23 |
"""Python bindings for libstatgrab.""" |
24 |
|
25 |
from distutils.core import setup, Extension |
26 |
from commands import getstatusoutput |
27 |
|
28 |
import sys |
29 |
import os |
30 |
|
31 |
# version of pystatgrab |
32 |
VERSION = "0.6" |
33 |
|
34 |
# required version of libstatgrab |
35 |
LIBSTATGRAB = "0.13" |
36 |
|
37 |
# test for pkg-config presence |
38 |
if os.system("pkg-config --version >/dev/null 2>&1"): |
39 |
sys.exit("Error, could not find pkg-config.") |
40 |
|
41 |
# test for libstatgrab presence using pkg-config |
42 |
if os.system("pkg-config --exists libstatgrab"): |
43 |
sys.exit("Error, libstatgrab is not installed (according to pkg-config).") |
44 |
|
45 |
# test for libstatgrab version using pkg-config |
46 |
if os.system("pkg-config --atleast-version=%s libstatgrab" % LIBSTATGRAB): |
47 |
sys.exit("Error, need at least libstatgrab version %s." % LIBSTATGRAB) |
48 |
|
49 |
# test for _statgrab.c, and try to generate if not found |
50 |
if not os.path.exists("_statgrab.c"): |
51 |
print "_statgrab.c doesn't exist, trying to use pyrexc to generate it..." |
52 |
if os.system("pyrexc --version >/dev/null 2>&1"): |
53 |
sys.exit("Error, _statgrab.c not present, and can't find pyrexc to generate it with.") |
54 |
else: |
55 |
if os.system("pyrexc _statgrab.pyx"): |
56 |
sys.exit("Error, pyrexc failed to generate _statgrab.c") |
57 |
|
58 |
# get cflags and libs for libstatgrab |
59 |
cflags = getstatusoutput("pkg-config --cflags libstatgrab") |
60 |
libs = getstatusoutput("pkg-config --libs libstatgrab") |
61 |
|
62 |
if cflags[0] != 0: |
63 |
sys.exit("Failed to get cflags: " + cflags[1]) |
64 |
|
65 |
if libs[0] != 0: |
66 |
sys.exit("Failed to get libs: " + libs[1]) |
67 |
|
68 |
# setup information |
69 |
setup( name = "pystatgrab", |
70 |
version = VERSION, |
71 |
description = "Python bindings for libstatgrab", |
72 |
author = "i-scream", |
73 |
author_email = "support@i-scream.org", |
74 |
url = "http://www.i-scream.org/pystatgrab/", |
75 |
license = "GNU GPL v2 or later", |
76 |
ext_modules=[Extension( |
77 |
"_statgrab", |
78 |
["_statgrab.c"], |
79 |
extra_compile_args = cflags[1].split(), |
80 |
extra_link_args = libs[1].split(), |
81 |
)], |
82 |
py_modules=["statgrab"], |
83 |
) |