3 from distutils
.core
import setup
, Extension
8 from sys
import stdin
, stdout
, stderr
13 if p
.read() != '': raise 'extra junk from %s' % cmd
15 return out
.rstrip('\n')
21 def libconfig(lib
, ver
):
22 config
= lib
+ '-config'
23 if system('%s --check %s' %
(config
, ver
)):
24 raise '%s version %s not found' %
(lib
, ver
)
25 version
= progoutput('%s --version' % config
)
26 for i
in progoutput('%s --cflags' % config
).split():
27 if i
[:2] == '-I': incdirs
.append(i
[2:])
28 else: raise 'strange cflags item %s' % i
29 for i
in progoutput('%s --libs' % config
).split():
30 if i
[:2] == '-L': libdirs
.append(i
[2:])
31 elif i
[:2] == '-l': libs
.append(i
[2:])
32 else: raise 'strange libs item %s' % i
43 libconfig('catacomb', '2.1.0')
44 libconfig('mLib', '2.0.3')
46 class SubprocessFailure (Exception):
47 def __init__(me
, file, rc
):
53 return '%s failed (rc = %d)' %
(me
.file, WEXITSTATUS(me
.rc
))
54 elif WIFSIGNALED(me
.rc
):
55 return '%s died (signal %d)' %
(me
.file, WTERMSIG(me
.rc
))
57 return '%s died inexplicably' %
(me
.file)
59 for g
in ['algorithms.h']:
63 root
, ext
= path
.splitext(g
)
69 updatep
= stin
.st_mtime
> stout
.st_mtime
71 if err
.errno
== ENOENT
:
77 print 'running %s to create %s' %
(fin
, fout
)
82 dup2(out
.fileno(), stdout
.fileno())
84 execl(sys
.executable
, sys
.executable
, fin
)
86 stderr
.write('error running %s -> %s: %s\n' %
87 (fin
, fout
, sys
.exc_info()[1]))
89 _
, rc
= waitpid(kid
, 0)
91 raise SubprocessFailure
, (fin
, rc
)
94 cat
= Extension('catacomb._base',
95 ['catacomb.c', 'bytestring.c', 'buffer.c',
96 'rand.c', 'algorithms.c', 'pubkey.c', 'pgen.c',
97 'mp.c', 'field.c', 'ec.c', 'group.c', 'passphrase.c',
98 'share.c', 'key.c', 'util.c'],
99 ##extra_compile_args = ['-O0'],
100 include_dirs
= uniquify(incdirs
),
101 library_dirs
= uniquify(libdirs
),
102 libraries
= uniquify(libs
))
104 setup(name
= 'catacomb-python',
106 description
= 'Interface to Catacomb cryptographic library',
107 url
= 'http://www.distorted.org.uk/~mdw/Catacomb-2.1.0',
108 author
= 'Straylight/Edgeware',
109 author_email
= 'mdw@distorted.org.uk',
110 license
= 'GNU General Public License',
111 packages
= ['catacomb'],
112 scripts
= ['pwsafe'],