From a510e264770430077bb4dbacd104c6aae19bcdd6 Mon Sep 17 00:00:00 2001 Message-Id: From: Mark Wooding Date: Sun, 4 Oct 2009 14:12:43 +0100 Subject: [PATCH] Build system: use new CFD's mdwsetup.py. Organization: Straylight/Edgeware From: Mark Wooding --- .gitignore | 4 ++ .links | 2 + MANIFEST.in | 2 +- setup.py | 119 +++++++++++++--------------------------------------- 4 files changed, 37 insertions(+), 90 deletions(-) mode change 100644 => 100755 setup.py diff --git a/.gitignore b/.gitignore index a982f44..359d09e 100644 --- a/.gitignore +++ b/.gitignore @@ -18,4 +18,8 @@ MANIFEST dist mLib.c COPYING +mdwsetup.py +*.pyc +auto-version +RELEASE python-build-stamp-* diff --git a/.links b/.links index 5ecd9c6..e25ac67 100644 --- a/.links +++ b/.links @@ -1 +1,3 @@ COPYING +auto-version +mdwsetup.py diff --git a/MANIFEST.in b/MANIFEST.in index 17e28c4..9bd6611 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,4 +1,4 @@ -include COPYING +include COPYING RELEASE auto-version mdwsetup.py include mLib.pyx defs.pxi utils.pyx include codec.pyx.in grim.h atom.h array.h atom-base.c array.c Makefile include lbuf.pyx pkbuf.pyx mapping.pyx mdup.pyx diff --git a/setup.py b/setup.py old mode 100644 new mode 100755 index d59471f..34ea95f --- a/setup.py +++ b/setup.py @@ -1,89 +1,30 @@ -from distutils.core import setup, Extension -from Pyrex.Distutils import build_ext -from os import * -from errno import * -import re -import sys -from sys import stdin, stdout, stderr - -incdirs = [] -libdirs = [] -libs = [] - -def progoutput(cmd): - p = popen(cmd) - out = p.readline() - if p.read() != '': raise 'extra junk from %s' % cmd - p.close() - return out.rstrip('\n') - -def libconfig(lib, ver): - for i in progoutput('pkg-config --cflags "%s >= %s"' % (lib, ver)).split(): - if i[:2] == '-I': incdirs.append(i[2:]) - else: raise 'strange cflags item %s' % i - for i in progoutput('pkg-config --libs "%s >= %s"' % (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.0') -libconfig('mLib', '2.1.0') - -def needs_update_p(target, sources): - if not path.exists(target): return True - t_target = stat(target).st_mtime - for s in sources: - if stat(s).st_mtime > t_target: return True - return False - -rx_subst = re.compile(r'\%(\w+)\%') - -def derive(target, src, subs): - if needs_update_p(target, [src]): - out = file(target + '.new', 'w') - for line in file(src): - out.write(rx_subst.sub((lambda m: subs[m.group(1)]), line)) - out.close() - rename(target + '.new', target) - -derive('base64.pyx', 'codec.pyx.in', - {'CLASS': 'Base64', 'PREFIX': 'base64'}) -derive('base32.pyx', 'codec.pyx.in', - {'CLASS': 'Base32', 'PREFIX': 'base32'}) -derive('hex.pyx', 'codec.pyx.in', - {'CLASS': 'Hex', 'PREFIX': 'hex'}) - -def mlibext(src): - col = src.find('!') - if col >= 0: - mod = src[:col] - srcs = [getsource(s) for s in src[col + 1:].split(',')] - else: - src = getsource(src) - mod, hunoz = src.split('.', 1) - srcs = [src] - -mlib = Extension('mLib', ['mLib.pyx', 'atom-base.c', 'array.c'], - - ##extra_compile_args = ['-O0'], - include_dirs = uniquify(incdirs), - library_dirs = uniquify(libdirs), - libraries = uniquify(libs)) - -setup(name = 'mLib-python', - version = '1.0.0', - description = 'Python interface to mLib utilities library', - author = 'Straylight/Edgeware', - author_email = 'mdw@distorted.org.uk', - license = 'GNU General Public License', - ext_modules = [mlib], - cmdclass = {'build_ext': build_ext}) +#! /usr/bin/python + +import distutils.core as DC +import Pyrex.Distutils as PXD +import mdwsetup as MS + +MS.pkg_config('catacomb', '2.1.0') +MS.pkg_config('mLib', '2.1.0') + +MS.derive('base64.pyx', 'codec.pyx.in', + {'CLASS': 'Base64', 'PREFIX': 'base64'}) +MS.derive('base32.pyx', 'codec.pyx.in', + {'CLASS': 'Base32', 'PREFIX': 'base32'}) +MS.derive('hex.pyx', 'codec.pyx.in', + {'CLASS': 'Hex', 'PREFIX': 'hex'}) + +mLib = DC.Extension('mLib', ['mLib.pyx', 'atom-base.c', 'array.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 = 'mLib-python', + version = MS.auto_version(), + description = 'Python interface to mLib utilities library', + author = 'Straylight/Edgeware', + author_email = 'mdw@distorted.org.uk', + license = 'GNU General Public License', + ext_modules = [mLib], + cmdclass = { 'build_ext': PXD.build_ext }) -- [mdw]