chiark / gitweb /
str: Support mLib's `str' functions.
[mLib-python] / setup.py
index f8c091bd4fb9263b6f86bd4fda11470f6878ecb3..de8e515cf2944fe9af2b99dcdd20e991ca7a1a85 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -51,24 +51,20 @@ def needs_update_p(target, sources):
 
 rx_subst = sre.compile(r'\%(\w+)\%')
 
-def getsource(src):
-  br = src.find('[')
-  if br >= 0:
-    if src[-1] != ']':
-      raise SyntaxError, 'bad auto file'
-    subst = src[br + 1:-1]
-    src = src[:br]
-    x = subst.split(':')
-    infile = x[0]
-    if needs_update_p(src, [infile]):
-      print 'creating %s from %s...' % (src, infile)
-      d = dict([i.split('/', 1) for i in x[1:]])
-      out = file(src + '.new', 'w')
-      for line in file(infile):
-        out.write(rx_subst.sub((lambda m: d[m.group(1)]), line))
+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(src + '.new', src)
-  return src
+      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('!')
@@ -79,11 +75,13 @@ def mlibext(src):
     src = getsource(src)
     mod, hunoz = src.split('.', 1)
     srcs = [src]
-  return Extension('mLib.' + mod, srcs,
-                   ##extra_compile_args = ['-O0'],
-                   include_dirs = uniquify(incdirs),
-                   library_dirs = uniquify(libdirs),
-                   libraries = uniquify(libs))
+
+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',
@@ -91,12 +89,5 @@ setup(name = 'mLib-python',
       author = 'Straylight/Edgeware',
       author_email = 'mdw@distorted.org.uk',
       license = 'GNU General Public License',
-      packages = ['mLib'],
-      ext_modules = [mlibext(x) for x in '''
-        select.pyx crc32.pyx unihash.pyx report.pyx
-        base64.pyx[codec.pyx.in:PREFIX/base64]
-        base32.pyx[codec.pyx.in:PREFIX/base32]
-        hex.pyx[codec.pyx.in:PREFIX/hex]
-        array.c sym.pyx atom!atom-base.c,atom.pyx
-        '''.split()],
+      ext_modules = [mlib],
       cmdclass = {'build_ext': build_ext})