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 for i
in progoutput('pkg-config "%s >= %s" --cflags' %
(lib
, ver
)).split():
23 if i
[:2] == '-I': incdirs
.append(i
[2:])
24 else: raise 'strange cflags item %s' % i
25 for i
in progoutput('pkg-config "%s >= %s" --libs' %
(lib
, ver
)).split():
26 if i
[:2] == '-L': libdirs
.append(i
[2:])
27 elif i
[:2] == '-l': libs
.append(i
[2:])
28 else: raise 'strange libs item %s' % i
39 libconfig('catacomb', '2.1.1')
40 libconfig('mLib', '2.0.4')
42 class SubprocessFailure (Exception):
43 def __init__(me
, file, rc
):
49 return '%s failed (rc = %d)' %
(me
.file, WEXITSTATUS(me
.rc
))
50 elif WIFSIGNALED(me
.rc
):
51 return '%s died (signal %d)' %
(me
.file, WTERMSIG(me
.rc
))
53 return '%s died inexplicably' %
(me
.file)
55 for g
in ['algorithms.h']:
59 root
, ext
= path
.splitext(g
)
65 updatep
= stin
.st_mtime
> stout
.st_mtime
67 if err
.errno
== ENOENT
:
73 print 'running %s to create %s' %
(fin
, fout
)
78 dup2(out
.fileno(), stdout
.fileno())
80 execl(sys
.executable
, sys
.executable
, fin
)
82 stderr
.write('error running %s -> %s: %s\n' %
83 (fin
, fout
, sys
.exc_info()[1]))
85 _
, rc
= waitpid(kid
, 0)
87 raise SubprocessFailure
, (fin
, rc
)
90 cat
= Extension('catacomb._base',
91 ['catacomb.c', 'bytestring.c', 'buffer.c',
92 'rand.c', 'algorithms.c', 'pubkey.c', 'pgen.c',
93 'mp.c', 'field.c', 'ec.c', 'group.c', 'passphrase.c',
94 'share.c', 'key.c', 'util.c'],
95 ##extra_compile_args = ['-O0'],
96 include_dirs
= uniquify(incdirs
),
97 library_dirs
= uniquify(libdirs
),
98 libraries
= uniquify(libs
))
100 setup(name
= 'catacomb-python',
102 description
= 'Interface to Catacomb cryptographic library',
103 url
= 'http://www.distorted.org.uk/~mdw/Catacomb-2.1.0',
104 author
= 'Straylight/Edgeware',
105 author_email
= 'mdw@distorted.org.uk',
106 license
= 'GNU General Public License',
107 packages
= ['catacomb'],
108 scripts
= ['pwsafe'],