1 |
|
#!/usr/bin/env python |
2 |
+ |
# |
3 |
+ |
# setup.py - distfiles configuration for pystatgrab |
4 |
+ |
# |
5 |
+ |
# $Id$ |
6 |
+ |
# |
7 |
+ |
"""Python bindings for libstatgrab.""" |
8 |
|
|
9 |
|
from distutils.core import setup, Extension |
10 |
|
from commands import getstatusoutput |
5 |
– |
from sys import exit |
11 |
|
|
12 |
+ |
import sys |
13 |
+ |
import os |
14 |
+ |
|
15 |
+ |
# version of pystatgrab |
16 |
+ |
VERSION = "0.1" |
17 |
+ |
|
18 |
+ |
# required version of libstatgrab |
19 |
+ |
LIBSTATGRAB = "0.9" |
20 |
+ |
|
21 |
+ |
# test for pkg-config presence |
22 |
+ |
if os.system("pkg-config --version >/dev/null 2>&1"): |
23 |
+ |
sys.exit("Error, could not find pkg-config.") |
24 |
+ |
|
25 |
+ |
# test for libstatgrab presence using pkg-config |
26 |
+ |
if os.system("pkg-config --exists libstatgrab"): |
27 |
+ |
sys.exit("Error, libstatgrab is not installed (according to pkg-config).") |
28 |
+ |
|
29 |
+ |
# test for libstatgrab version using pkg-config |
30 |
+ |
if os.system("pkg-config --atleast-version=%s libstatgrab" % LIBSTATGRAB): |
31 |
+ |
sys.exit("Error, need at least libstatgrab version %s." % LIBSTATGRAB) |
32 |
+ |
|
33 |
+ |
# test for statgrab.c, and try to generate if not found |
34 |
+ |
if not os.path.exists("statgrab.c"): |
35 |
+ |
print "statgrab.c doesn't exist, trying to use pyrexc to generate it..." |
36 |
+ |
if os.system("pyrexc --version >/dev/null 2>&1"): |
37 |
+ |
sys.exit("Error, statgrab.c not present, and can't find pyrexc to generate it with.") |
38 |
+ |
else: |
39 |
+ |
if os.system("pyrexc statgrab.pyx"): |
40 |
+ |
sys.exit("Error, pyrexc failed to generate statgrab.c") |
41 |
+ |
|
42 |
+ |
# get cflags and libs for libstatgrab |
43 |
|
cflags = getstatusoutput("pkg-config --cflags libstatgrab") |
44 |
|
libs = getstatusoutput("pkg-config --libs libstatgrab") |
45 |
|
|
46 |
|
if cflags[0] != 0: |
47 |
< |
exit("Failed to get cflags: " + cflags[1]) |
47 |
> |
sys.exit("Failed to get cflags: " + cflags[1]) |
48 |
|
|
49 |
|
if libs[0] != 0: |
50 |
|
exit("Failed to get libs: " + libs[1]) |
51 |
|
|
52 |
< |
setup( name = "statgrab", |
53 |
< |
version = "0.8.2", |
52 |
> |
# setup information |
53 |
> |
setup( name = "pystatgrab", |
54 |
> |
version = VERSION, |
55 |
|
description = "Python bindings for libstatgrab", |
56 |
|
author = "i-scream", |
57 |
|
author_email = "dev@i-scream.org", |
58 |
< |
url = "http://www.i-scream.org/libstatgrab", |
58 |
> |
url = "http://www.i-scream.org/libstatgrab/", |
59 |
|
license = "GNU GPL v2 or later", |
60 |
|
ext_modules=[Extension( |
61 |
|
"statgrab", |