f8c091bd4fb9263b6f86bd4fda11470f6878ecb3
1 from distutils
.core
import setup
, Extension
2 from Pyrex
.Distutils
import build_ext
7 from sys
import stdin
, stdout
, stderr
16 if p
.read() != '': raise 'extra junk from %s' % cmd
18 return out
.rstrip('\n')
20 def libconfig(lib
, ver
):
21 config
= lib
+ '-config'
22 if system('%s --check %s' %
(config
, ver
)):
23 raise '%s version %s not found' %
(lib
, ver
)
24 version
= progoutput('%s --version' % config
)
25 for i
in progoutput('%s --cflags' % config
).split():
26 if i
[:2] == '-I': incdirs
.append(i
[2:])
27 else: raise 'strange cflags item %s' % i
28 for i
in progoutput('%s --libs' % config
).split():
29 if i
[:2] == '-L': libdirs
.append(i
[2:])
30 elif i
[:2] == '-l': libs
.append(i
[2:])
31 else: raise 'strange libs item %s' % i
42 libconfig('catacomb', '2.1.0')
43 libconfig('mLib', '2.0.3')
45 def needs_update_p(target
, sources
):
46 if not path
.exists(target
): return True
47 t_target
= stat(target
).st_mtime
49 if stat(s
).st_mtime
> t_target
: return True
52 rx_subst
= sre
.compile(r
'\%(\w+)\%')
58 raise SyntaxError, 'bad auto file'
59 subst
= src
[br
+ 1:-1]
63 if needs_update_p(src
, [infile
]):
64 print 'creating %s from %s...' %
(src
, infile
)
65 d
= dict([i
.split('/', 1) for i
in x
[1:]])
66 out
= file(src
+ '.new', 'w')
67 for line
in file(infile
):
68 out
.write(rx_subst
.sub((lambda m
: d
[m
.group(1)]), line
))
70 rename(src
+ '.new', src
)
77 srcs
= [getsource(s
) for s
in src
[col
+ 1:].split(',')]
80 mod
, hunoz
= src
.split('.', 1)
82 return Extension('mLib.' + mod
, srcs
,
83 ##extra_compile_args = ['-O0'],
84 include_dirs
= uniquify(incdirs
),
85 library_dirs
= uniquify(libdirs
),
86 libraries
= uniquify(libs
))
88 setup(name
= 'mLib-python',
90 description
= 'Python interface to mLib utilities library',
91 author
= 'Straylight/Edgeware',
92 author_email
= 'mdw@distorted.org.uk',
93 license
= 'GNU General Public License',
95 ext_modules
= [mlibext(x
) for x
in '''
96 select.pyx crc32.pyx unihash.pyx report.pyx
97 base64.pyx[codec.pyx.in:PREFIX/base64]
98 base32.pyx[codec.pyx.in:PREFIX/base32]
99 hex.pyx[codec.pyx.in:PREFIX/hex]
100 array.c sym.pyx atom!atom-base.c,atom.pyx
102 cmdclass
= {'build_ext': build_ext
})