Debianization.
[checkpath-python] / setup.py
CommitLineData
ab147f75 1#! /usr/bin/python
2
3from distutils.core import setup, Extension
936ed019 4from Pyrex.Distutils import build_ext
ab147f75 5from os import *
6from errno import *
7
8incdirs = []
9libdirs = []
10libs = []
11
12def 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
19def 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
32def 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
41libconfig('mLib', '2.0.3')
42libconfig('checkpath', '1.1.0')
43
ab147f75 44chk = Extension('checkpath',
936ed019 45 ['checkpath.pyx'],
46 ##extra_compile_args = ['-O0'],
ab147f75 47 include_dirs = uniquify(incdirs),
48 library_dirs = uniquify(libdirs),
49 libraries = uniquify(libs))
936ed019 50setup(name = 'checkpath-python',
ab147f75 51 version = '1.1.0',
52 description = 'Checking paths for security',
53 author = 'Straylight/Edgeware',
936ed019 54 author_email = 'mdw@distorted.org.uk',
ab147f75 55 license = 'GNU General Public License',
936ed019 56 ext_modules = [chk],
57 cmdclass = {'build_ext': build_ext})