version: Remove shebang (Python modules are not scripts)
[catalyst.git] / setup.py
1 #!/usr/bin/python2 -OO
2
3 # Copyright (C) 2013 W. Trevor King <wking@tremily.us>
4 #
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
18 """Catalyst is a release building tool used by Gentoo Linux"""
19
20 # py2.6 compatibility
21 from __future__ import print_function
22
23 import codecs as _codecs
24 from distutils.core import setup as _setup, Command as _Command
25 import os as _os
26
27 from catalyst import __version__
28 from catalyst.version import set_release_version as _set_release_version
29 from catalyst.version import get_version as _get_version
30
31
32 _this_dir = _os.path.dirname(__file__)
33 package_name = 'catalyst'
34 tag = '{0}-{1}'.format(package_name, __version__)
35
36
37 if _os.path.sep != '/':
38         raise NotImplementedError('Non-POSIX paths are not supported')
39
40 def files(root, target):
41         """Iterate through all the file paths under `root`
42
43         Distutils wants all paths to be written in the Unix convention
44         (i.e. slash-separated) [1], so that's what we'll do here.
45
46         [1]: http://docs.python.org/2/distutils/setupscript.html#writing-the-setup-script
47         """
48         for dirpath, dirnames, filenames in _os.walk(root):
49                 key = _os.path.join(target, dirpath)
50                 filepaths = [_os.path.join(dirpath, filename)
51                              for filename in filenames]
52                 yield (key, filepaths)
53
54
55 _data_files = [('/etc/catalyst', ['etc/catalyst.conf','etc/catalystrc']),
56         ('/usr/share/man/man1', ['files/catalyst.1']),
57         ('/usr/share/man/man5', ['files/catalyst-config.5', 'files/catalyst-spec.5'])
58         ]
59 _data_files.extend(files('livecd', 'lib/catalyst/'))
60 _data_files.extend(files('targets', 'lib/catalyst/'))
61
62
63 class set_version(_Command):
64         '''Saves the specified release version information
65         '''
66         global __version__
67         description = "hardcode script's version using VERSION from environment"
68         user_options = []  # [(long_name, short_name, desc),]
69
70         def initialize_options (self):
71                 pass
72
73         def finalize_options (self):
74                 pass
75
76         def run(self):
77                 try:
78                         version = _os.environ['VERSION']
79                 except KeyError:
80                         print("Try setting 'VERSION=x.y.z' on the command line... Aborting")
81                         return
82                 _set_release_version(version)
83                 __version__ = _get_version()
84                 print("Version set to:\n", __version__)
85
86
87 _setup(
88         name=package_name,
89         version=__version__,
90         maintainer='Gentoo Release Engineering',
91         maintainer_email='releng@gentoo.org',
92         url='http://www.gentoo.org/proj/en/releng/{0}/'.format(package_name),
93         download_url='http://git.overlays.gentoo.org/gitweb/?p=proj/{0}.git;a=snapshot;h={1};sf=tgz'.format(package_name, tag),
94         license='GNU General Public License (GPL)',
95         platforms=['all'],
96         description=__doc__,
97         long_description=_codecs.open(
98                 _os.path.join(_this_dir, 'README'), 'r', 'utf-8').read(),
99         classifiers=[
100                 'Development Status :: 5 - Production/Stable',
101                 'License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)',
102                 'Intended Audience :: System Administrators',
103                 'Operating System :: POSIX',
104                 'Topic :: System :: Archiving :: Packaging',
105                 'Topic :: System :: Installation/Setup',
106                 'Topic :: System :: Software Distribution',
107                 'Programming Language :: Python :: 2',
108                 'Programming Language :: Python :: 2.6',
109                 'Programming Language :: Python :: 2.7',
110                 ],
111         scripts=['bin/{0}'.format(package_name)],
112         packages=[
113                 package_name,
114                 '{0}.arch'.format(package_name),
115                 '{0}.base'.format(package_name),
116                 '{0}.targets'.format(package_name),
117                 ],
118         data_files=_data_files,
119         provides=[package_name],
120         cmdclass={
121                 'set_version': set_version
122                 },
123         )