From 338e52e2ecc67db2f378f86b5d7791b80c28064e Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Fri, 5 Apr 2013 21:14:06 +0100 Subject: Add manpage to .deb and check/clean commands to setup.py --- debian/rules | 2 +- setup.py | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) 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, + }, ) -- cgit v1.2.1