-
Notifications
You must be signed in to change notification settings - Fork 2
/
setup.py
183 lines (150 loc) · 5.85 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# crunchyfrog - a database schema browser and query tool
# Copyright (C) 2008 Andi Albrecht <albrecht.andi@gmail.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from distutils.command.build import build
from distutils.command.clean import clean
from distutils.command.install import install as _install
from distutils.core import setup
from glob import glob
import os
import shutil
import sys
CMD_CLASS = {}
try:
from sphinx.setup_command import BuildDoc
CMD_CLASS['build_manual'] = BuildDoc
CMD_CLASS['build_devguide'] = BuildDoc
except ImportError:
pass
from utils.command.build_api import build_api
from utils.command.build_manpage import build_manpage
from utils.command.build_mo import build_mo
from utils.command.clean_docs import clean_docs
from utils.command.clean_mo import clean_mo
from cf import release
def find_packages(base):
"""Helper function to find subpackages in base.
:param base: Directory holding the main package.
Returns a list of subpackages suitable for setup() packages keyword.
base is already included in the returned list.
"""
ret = [base]
for path in os.listdir(base):
if path.startswith('.'):
continue
full_path = os.path.join(base, path)
if os.path.isdir(full_path):
ret += find_packages(full_path)
return ret
class install(_install):
"""install command -- generates a local_config.py"""
def run(self):
if sys.platform == 'linux2':
destdir = os.getenv('DESTDIR', '')
if destdir and self.install_data.startswith(destdir):
prefix = self.install_data[len(destdir):]
else:
prefix = self.install_data
if prefix[0] != '/':
prefix = '/%s' % prefix
else:
prefix = self.install_data
f = open('cf/local_config.py', 'w')
f.write('# -*- coding: utf-8 -*-\n\n')
f.write('PREFIX = \'%s\'\n' % prefix)
f.close()
_install.run(self)
CMD_CLASS['install'] = install
class clean_with_subcommands(clean):
def run(self):
for cmd_name in self.get_sub_commands():
self.run_command(cmd_name)
clean.run(self)
CMD_CLASS['clean'] = clean_with_subcommands
CMD_CLASS['clean_docs'] = clean_docs
CMD_CLASS['build_api'] = build_api
CMD_CLASS['build_manpage'] = build_manpage
CMD_CLASS['build_mo'] = build_mo
CMD_CLASS['clean_mo'] = clean_mo
if 'build_manual' in CMD_CLASS:
build.sub_commands.append(('build_manual', None))
DATA_FILES = []
# Glade
DATA_FILES += [('share/crunchyfrog/glade', glob('data/glade/*.glade'))]
# Plugins
# Expects that each directory in data/plugins is a plugin and that
# the plugin directories contain Python files only.
for dirname in os.listdir('data/plugins'):
if dirname[0] in ('.', '_'):
continue
DATA_FILES += [(os.path.join('share/crunchyfrog/plugins', dirname),
glob(os.path.join('data/plugins', dirname, '*.py')))]
# Pixmaps
DATA_FILES += [('share/crunchyfrog/pixmaps', glob('data/pixmaps/*.png'))]
# Data
DATA_FILES += [('share/applications', ['data/crunchyfrog.desktop'])]
DATA_FILES += [('share/icons/hicolor/scalable/apps', ['data/crunchyfrog.svg'])]
DATA_FILES += [('share/pixmaps', ['data/crunchyfrog.svg'])]
DATA_FILES += [('share/icons/hicolor/24x24/apps', ['data/crunchyfrog.png'])]
# Manpage
DATA_FILES += [('share/man/man1', ['data/crunchyfrog.1'])]
# Documentation
DATA_FILES += [('share/doc/crunchyfrog', ['README', 'CHANGES', 'COPYING'])]
DATA_FILES += [('share/doc/crunchyfrog/manual',
glob('docs/manual/build/html/*.*')),
('share/doc/crunchyfrog/manual/_images',
glob('docs/manual/build/html/_images/*.*')),
('share/doc/crunchyfrog/manual/_sources',
glob('docs/manual/build/html/_sources/*.*')),
('share/doc/crunchyfrog/manual/_static',
glob('docs/manual/build/html/_static/*.*'))]
# Locales
for lang in os.listdir('po/'):
path = os.path.join('po/', lang)
if not os.path.isdir(path) or lang[0] in ['.', '_']:
continue
DATA_FILES += [('share/locale/%s/LC_MESSAGES' % lang,
['po/%s/LC_MESSAGES/crunchyfrog.mo' % lang])]
setup(
name=release.appname,
version=release.version,
description=release.description,
author=release.author,
author_email=release.author_email,
long_description=release.long_description,
license='GPL',
url=release.url,
download_url='http://crunchyfrog.googlecode.com/files/crunchyfrog-%s.tar.gz' % release.version,
classifiers = [
'Development Status :: 4 - Beta',
'Environment :: X11 Applications :: GTK',
'Environment :: X11 Applications :: Gnome',
'Environment :: MacOS X',
'Environment :: Win32 (MS Windows)',
'Intended Audience :: Developers',
'Intended Audience :: End Users/Desktop',
'License :: OSI Approved :: GNU General Public License (GPL)',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Topic :: Database :: Front-Ends',
],
packages=find_packages('cf'),
package_data={'cf': ['config/default.cfg']},
scripts=['crunchyfrog'],
data_files=DATA_FILES,
cmdclass=CMD_CLASS,
)