summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xdebian/rules2
-rw-r--r--setup.py49
2 files changed, 50 insertions, 1 deletions
diff --git a/debian/rules b/debian/rules
index 374df7b..87c455c 100755
--- a/debian/rules
+++ b/debian/rules
@@ -4,4 +4,4 @@
dh $@ --with=python2 --buildsystem=python_distutils
override_auto_test:
- cmdtest tests
+ python setup.py check
diff --git a/setup.py b/setup.py
index 79333f5..74d5556 100644
--- a/setup.py
+++ b/setup.py
@@ -16,7 +16,51 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
from distutils.core import setup
+from distutils.cmd import Command
+from distutils.command.build import build
+from distutils.command.clean import clean
import glob
+import os
+import shutil
+import cliapp
+
+
+
+class GenerateManpage(build):
+
+ def run(self):
+ build.run(self)
+ print 'building manpage'
+ with open('cachedir.1', 'w') as f:
+ cliapp.runcmd(
+ ['./cachedir', '--generate-manpage=cachedir.1.in'],
+ stdout=f)
+
+
+class CleanMore(clean):
+
+ def run(self):
+ clean.run(self)
+ dirty = ['cachedir.1']
+ for x in dirty:
+ if os.path.exists(x):
+ os.remove(x)
+ if os.path.isdir('build'):
+ shutil.rmtree('build')
+
+
+class Check(Command):
+
+ user_options = []
+
+ def initialize_options(self):
+ pass
+
+ def finalize_options(self):
+ pass
+
+ def run(self):
+ cliapp.runcmd(['cmdtest', 'tests'])
setup(name='cachedir',
@@ -27,4 +71,9 @@ setup(name='cachedir',
url='http://liw.fi/cachedir/',
scripts=['cachedir'],
data_files=[('share/man/man1', glob.glob('*.1'))],
+ cmdclass={
+ 'build': GenerateManpage,
+ 'check': Check,
+ 'clean': CleanMore,
+ },
)