Merge branch 'master' of git://gitorious.org/opensuse/osc
[opensuse:osc.git] / setup.py
1 #!/usr/bin/env python
2
3 from distutils.core import setup
4 import distutils.command.build
5 import distutils.command.install_data
6 import os.path
7 import osc.core
8 import sys
9 from osc import commandline
10 from osc import babysitter
11 # optional support for py2exe
12 try:
13     import py2exe
14     HAVE_PY2EXE = True
15 except:
16     HAVE_PY2EXE = False
17
18 class build_osc(distutils.command.build.build, object):
19     """
20     Custom build command which generates man page.
21     """
22
23     def build_man_page(self):
24         """
25         """
26         import gzip
27         man_path = os.path.join('build', 'osc.1.gz')
28         distutils.log.info('generating %s' % man_path)
29         outfile = gzip.open(man_path, 'w')
30         osccli = commandline.Osc(stdout = outfile)
31         # FIXME: we cannot call the main method because osc expects an ~/.oscrc file
32         # (this would break builds in environments like the obs)
33         #osccli.main(argv = ['osc','man'])
34         osccli.optparser = osccli.get_optparser()
35         osccli.do_man(None)
36         outfile.close()
37
38     def run(self):
39         super(build_osc, self).run()
40         self.build_man_page()
41
42 addparams = {}
43 if HAVE_PY2EXE:
44     addparams['console'] = [{'script': 'osc-wrapper.py', 'dest_base': 'osc', 'icon_resources': [(1, 'osc.ico')]}]
45     addparams['zipfile'] = 'shared.lib'
46     addparams['options'] = {'py2exe': { 'optimize': 0, 'compressed': True, 'packages': ['xml.etree', 'StringIO', 'gzip'] }}
47
48 data_files = []
49 if sys.platform[:3] != 'win':
50     data_files.append((os.path.join('share','man','man1'), [os.path.join('build', 'osc.1.gz')]))
51
52 setup(name='osc',
53       version = osc.core.__version__,
54       description = 'openSUSE commander',
55       long_description = 'Command-line client for the openSUSE Build Service, which allows to access repositories in the openSUSE Build Service in similar way as Subversion repositories.',
56       author = 'openSUSE project',
57       author_email = 'opensuse-buildservice@opensuse.org',
58       license = 'GPL',
59       platforms = ['Linux','Mac OSX','Windows XP/2000/NT','Windows 95/98/ME'],
60       keywords = ['openSUSE', 'SUSE', 'RPM', 'build', 'buildservice'],
61       url = 'http://en.opensuse.org/Build_Service/CLI',
62       download_url = 'http://gitorious.org/opensuse/osc',
63
64       packages = ['osc', 'osc.util'],
65       scripts = ['osc_hotshot.py', 'osc-wrapper.py'],
66       data_files = data_files,
67
68       # Override certain command classes with our own ones
69       cmdclass = {
70         'build': build_osc,
71         },
72       **addparams
73      )