#! /usr/bin/python
-from distutils.core import setup, Extension
-import os as OS
+import subprocess as SUB
-def needs_update_p(target, deps):
- if not OS.path.exists(target): return True
- ts = OS.stat(target)
- for d in deps:
- s = OS.stat(d)
- if ts.st_mtime < s.st_mtime: return True
- return False
+import distutils.core as DC
+import mdwsetup as MS
-if needs_update_p('getdate.c', ['getdate.y']):
- OS.system('bison -o getdate.c getdate.y')
+if MS.needs_update_p('getdate.c', ['getdate.y']):
+ rc = SUB.call(['bison', '-o', 'getdate.c', 'getdate.y'])
+ if rc:
+ raise MS.SubprocessFailure, ('bison', rc)
-setup(name = 'getdate',
- version = '1.0.0',
- description = 'Date/time parser',
- author = 'Mark Wooding',
- author_email = 'mdw@distorted.org.uk',
- license = 'GNU General Public License',
- ext_modules = [Extension('getdate', ['module.c', 'getdate.c'])])
+getdate = DC.Extension('getdate',
+ ['module.c', 'getdate.c'])
+
+DC.setup(name = 'getdate-python',
+ version = MS.auto_version(),
+ description = 'Date/time parser',
+ author = 'Mark Wooding',
+ author_email = 'mdw@distorted.org.uk',
+ license = 'GNU General Public License',
+ ext_modules = [getdate])