diff options
author | Lars Wirzenius <liw@liw.fi> | 2011-08-23 17:23:42 +0100 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2011-08-23 17:23:42 +0100 |
commit | 18d6acaefce11db36874e20f4915236daae92c11 (patch) | |
tree | ae65a4d29d9943b93e71efecf16dbaaa157aa6fe | |
parent | a599217dc6d0230ab9e95d77d2bf43dd2a0811d8 (diff) | |
download | obnam-18d6acaefce11db36874e20f4915236daae92c11.tar.gz |
Move Makefile functionality into setup.py.
I sigh at this, because it replaces a language-agnostic
tool with a language-specific one, but it seems to be
the easiest way to get magic Debian Python build helpers
to work correctly.
-rw-r--r-- | setup.py | 64 |
1 files changed, 64 insertions, 0 deletions
@@ -16,7 +16,66 @@ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. from distutils.core import setup, Extension +from distutils.cmd import Command +from distutils.command.build import build +from distutils.command.clean import clean import glob +import os +import subprocess + +class GenerateManpage(build): + + def run(self): + build.run(self) + print 'building manpages' + for x in ['obnam', 'obnam-benchmark']: + with open('%s.1' % x, 'w') as f: + subprocess.check_call(['python', x, + '--generate-manpage=%s.1.in' % x, + '--output=%s.1' % x], stdout=f) + + +class CleanMore(clean): + + def run(self): + clean.run(self) + for x in ['blackboxtest.log', 'blackboxtest-obnam.log', + 'obnam.1', 'obnam-benchmark.1']: + if os.path.exists(x): + os.remove(x) + + +class Check(Command): + + user_options = [ + ('fast', 'f', 'run fast tests only?'), + ('network', 'n', 'run network tests to localhost?'), + ] + + def initialize_options(self): + self.fast = False + self.network = False + + def finalize_options(self): + pass + + def run(self): + subprocess.check_call(['python', '-m', 'CoverageTestRunner', + '--ignore-missing-from=without-tests']) + os.remove('.coverage') + if self.fast: + return + + subprocess.check_call(['python', 'blackboxtest']) + + if self.network: + subprocess.check_call(['./test-sftpfs']) + + env = dict(os.environ) + env['OBNAM_TEST_SFTP_ROOT'] = 'yes' + env['OBNAM_TEST_SFTP_REPOSITORY'] = 'yes' + subprocess.check_call(['./blackboxtest'], env=env) + setup(name='obnam', version='0.21', @@ -28,4 +87,9 @@ setup(name='obnam', packages=['obnamlib', 'obnamlib.plugins'], ext_modules=[Extension('_obnam', sources=['_obnammodule.c'])], data_files=[('share/man/man1', glob.glob('*.1'))], + cmdclass={ + 'build': GenerateManpage, + 'check': Check, + 'clean': CleanMore, + }, ) |