ab147f75 |
1 | #! /usr/bin/python |
2 | |
3 | from distutils.core import setup, Extension |
936ed019 |
4 | from Pyrex.Distutils import build_ext |
ab147f75 |
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 | |
ab147f75 |
44 | chk = 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 |
50 | setup(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}) |