From 2286c78891bca3d23a645363277b6725afb2ab47 Mon Sep 17 00:00:00 2001 Message-Id: <2286c78891bca3d23a645363277b6725afb2ab47.1715980931.git.mdw@distorted.org.uk> From: Mark Wooding Date: Sun, 4 Oct 2009 14:18:01 +0100 Subject: [PATCH] build: Use mdwsetup.py from new CFD. Announce 1.0.2. Organization: Straylight/Edgeware From: Mark Wooding --- .gitignore | 4 ++ .links | 1 + Makefile | 4 +- debian/changelog | 6 +++ setup.py | 138 +++++++++++------------------------------------ 5 files changed, 45 insertions(+), 108 deletions(-) diff --git a/.gitignore b/.gitignore index 7770be2..678cbf1 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,8 @@ deb-build build-stamp COPYING algorithms.h +RELEASE +auto-version +mdwsetup.py +*.pyc python-build-stamp-* diff --git a/.links b/.links index 5ecd9c6..89b2d6f 100644 --- a/.links +++ b/.links @@ -1 +1,2 @@ COPYING +auto-version diff --git a/Makefile b/Makefile index b0564e4..7a24b27 100644 --- a/Makefile +++ b/Makefile @@ -3,12 +3,14 @@ PYTHON = python prefix = /usr/local +GEN = algorithms.h + all: setup.py $(PYTHON) setup.py build clean: setup.py $(PYTHON) setup.py clean - rm -rf build + rm -rf build $(GEN) dist: setup.py $(PYTHON) setup.py sdist diff --git a/debian/changelog b/debian/changelog index a75775a..a549415 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +catacomb-python (1.0.2) experimental; urgency=low + + * Overhaul build system with new support module. + + -- Mark Wooding Sun, 04 Oct 2009 14:17:20 +0100 + catacomb-python (1.0.1) experimental; urgency=low * Make it work with Python 2.6. Also switched over to the (increasingly diff --git a/setup.py b/setup.py index cf12885..927d1d2 100644 --- a/setup.py +++ b/setup.py @@ -1,109 +1,33 @@ #! /usr/bin/python -from distutils.core import setup, Extension -from os import * -from os import _exit -from errno import * -import sys -from sys import stdin, stdout, stderr - -def progoutput(cmd): - p = popen(cmd) - out = p.readline() - if p.read() != '': raise 'extra junk from %s' % cmd - p.close() - return out.rstrip('\n') - -incdirs = [] -libdirs = [] -libs = [] - -def libconfig(lib, ver): - for i in progoutput('pkg-config "%s >= %s" --cflags' % (lib, ver)).split(): - if i[:2] == '-I': incdirs.append(i[2:]) - else: raise 'strange cflags item %s' % i - for i in progoutput('pkg-config "%s >= %s" --libs' % (lib, ver)).split(): - if i[:2] == '-L': libdirs.append(i[2:]) - elif i[:2] == '-l': libs.append(i[2:]) - else: raise 'strange libs item %s' % i - -def uniquify(l): - u = {} - o = [] - for i in l: - if i not in u: - o.append(i) - u[i] = 1 - return o - -libconfig('catacomb', '2.1.1') -libconfig('mLib', '2.0.4') - -class SubprocessFailure (Exception): - def __init__(me, file, rc): - me.args = (file, rc) - me.file = file - me.rc = rc - def __str__(me): - if WIFEXITED(me.rc): - return '%s failed (rc = %d)' % (me.file, WEXITSTATUS(me.rc)) - elif WIFSIGNALED(me.rc): - return '%s died (signal %d)' % (me.file, WTERMSIG(me.rc)) - else: - return '%s died inexplicably' % (me.file) - -for g in ['algorithms.h']: - if type(g) == tuple: - fin, fout = g - else: - root, ext = path.splitext(g) - fin = root + '.py' - fout = g - stin = stat(fin) - try: - stout = stat(fout) - updatep = stin.st_mtime > stout.st_mtime - except OSError, err: - if err.errno == ENOENT: - updatep = True - else: - raise - if updatep: - kid = fork() - print 'running %s to create %s' % (fin, fout) - fnew = fout + '.new' - if kid == 0: - try: - out = file(fnew, 'w') - dup2(out.fileno(), stdout.fileno()) - out.close() - execl(sys.executable, sys.executable, fin) - except: - stderr.write('error running %s -> %s: %s\n' % - (fin, fout, sys.exc_info()[1])) - _exit(127) - _, rc = waitpid(kid, 0) - if rc: - raise SubprocessFailure, (fin, rc) - rename(fnew, fout) - -cat = Extension('catacomb._base', - ['catacomb.c', 'bytestring.c', 'buffer.c', - 'rand.c', 'algorithms.c', 'pubkey.c', 'pgen.c', - 'mp.c', 'field.c', 'ec.c', 'group.c', 'passphrase.c', - 'share.c', 'key.c', 'util.c'], - ##extra_compile_args = ['-O0'], - include_dirs = uniquify(incdirs), - library_dirs = uniquify(libdirs), - libraries = uniquify(libs)) - -setup(name = 'catacomb-python', - version = '1.0.0', - description = 'Interface to Catacomb cryptographic library', - url = 'http://www.distorted.org.uk/~mdw/Catacomb-2.1.0', - author = 'Straylight/Edgeware', - author_email = 'mdw@distorted.org.uk', - license = 'GNU General Public License', - packages = ['catacomb'], - scripts = ['pwsafe'], - ext_modules = [cat]) +import os as OS +import subprocess as SUB + +import distutils.core as DC +import mdwsetup as MS + +MS.pkg_config('catacomb', '2.1.1') +MS.pkg_config('mLib', '2.0.4') + +MS.generate('algorithms.h') + +cat = DC.Extension('catacomb._base', + ['catacomb.c', 'bytestring.c', 'buffer.c', + 'rand.c', 'algorithms.c', 'pubkey.c', 'pgen.c', + 'mp.c', 'field.c', 'ec.c', 'group.c', 'passphrase.c', + 'share.c', 'key.c', 'util.c'], + ##extra_compile_args = ['-O0'], + include_dirs = MS.uniquify(MS.INCLUDEDIRS), + library_dirs = MS.uniquify(MS.LIBDIRS), + libraries = MS.uniquify(MS.LIBS)) + +DC.setup(name = 'catacomb-python', + version = MS.auto_version(), + description = 'Interface to Catacomb cryptographic library', + url = 'http://www.distorted.org.uk/~mdw/Catacomb-2.1.0', + author = 'Straylight/Edgeware', + author_email = 'mdw@distorted.org.uk', + license = 'GNU General Public License', + packages = ['catacomb'], + scripts = ['pwsafe'], + ext_modules = [cat]) -- [mdw]