debian: Just build for the default version.
[checkpath-python] / setup.py
1 #! /usr/bin/python
2
3 from distutils.core import setup, Extension
4 from Pyrex.Distutils import build_ext
5 from os import *
6 from errno import *
7
8 incdirs = []
9 libdirs = []
10 libs = []
11
12 def progoutput(cmd):
13 p = popen(cmd)
14 out = p.readline()
15 if p.read() != '': raise 'extra junk from %s' % cmd
16 p.close()
17 return out.rstrip('\n')
18
19 def libconfig(lib, ver):
20 config = lib + '-config'
21 if system('%s --check %s' % (config, ver)):
22 raise '%s version %s not found' % (lib, ver)
23 version = progoutput('%s --version' % config)
24 for i in progoutput('%s --cflags' % config).split():
25 if i[:2] == '-I': incdirs.append(i[2:])
26 else: raise 'strange cflags item %s' % i
27 for i in progoutput('%s --libs' % config).split():
28 if i[:2] == '-L': libdirs.append(i[2:])
29 elif i[:2] == '-l': libs.append(i[2:])
30 else: raise 'strange libs item %s' % i
31
32 def uniquify(l):
33 u = {}
34 o = []
35 for i in l:
36 if i not in u:
37 o.append(i)
38 u[i] = 1
39 return o
40
41 libconfig('mLib', '2.0.3')
42 libconfig('checkpath', '1.1.0')
43
44 chk = Extension('checkpath',
45 ['checkpath.pyx'],
46 ##extra_compile_args = ['-O0'],
47 include_dirs = uniquify(incdirs),
48 library_dirs = uniquify(libdirs),
49 libraries = uniquify(libs))
50 setup(name = 'checkpath-python',
51 version = '1.1.0',
52 description = 'Checking paths for security',
53 author = 'Straylight/Edgeware',
54 author_email = 'mdw@distorted.org.uk',
55 license = 'GNU General Public License',
56 ext_modules = [chk],
57 cmdclass = {'build_ext': build_ext})