Mercurial > genshi > genshi-test
comparison examples/trac/setup.py @ 39:71ecbe90aafc
Copy Trac to main branch.
author | cmlenz |
---|---|
date | Mon, 03 Jul 2006 18:53:27 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
38:fec9f4897415 | 39:71ecbe90aafc |
---|---|
1 #!/usr/bin/env python | |
2 | |
3 import os | |
4 import os.path | |
5 import sys | |
6 import string | |
7 from glob import glob | |
8 from distutils.core import setup | |
9 from distutils.command.install import install | |
10 from distutils.command.install_data import install_data | |
11 from distutils.command.install_scripts import install_scripts | |
12 from stat import ST_MODE, S_ISDIR | |
13 | |
14 import trac | |
15 | |
16 PACKAGE = 'Trac' | |
17 VERSION = str(trac.__version__) | |
18 URL = trac.__url__ | |
19 LICENSE = trac.__license__ | |
20 | |
21 if sys.version_info < (2, 3): | |
22 print >>sys.stderr, 'You need at least Python 2.3 for %s %s' \ | |
23 % (PACKAGE, VERSION) | |
24 sys.exit(3) | |
25 | |
26 def _p(unix_path): | |
27 return os.path.normpath(unix_path) | |
28 | |
29 class my_install (install): | |
30 def run (self): | |
31 self.siteconfig() | |
32 | |
33 def siteconfig(self): | |
34 path = self.prefix or self.home | |
35 path = os.path.expanduser(path) | |
36 conf_dir = os.path.join(path, 'share', 'trac', 'conf') | |
37 templates_dir = os.path.join(path, 'share', 'trac', 'templates') | |
38 htdocs_dir = os.path.join(path, 'share', 'trac', 'htdocs') | |
39 wiki_dir = os.path.join(path, 'share', 'trac', 'wiki-default') | |
40 macros_dir = os.path.join(path, 'share', 'trac', 'wiki-macros') | |
41 plugins_dir = os.path.join(path, 'share', 'trac', 'plugins') | |
42 f = open(_p('trac/siteconfig.py'), 'w') | |
43 f.write(""" | |
44 # PLEASE DO NOT EDIT THIS FILE! | |
45 # This file was autogenerated when installing %(trac)s %(ver)s. | |
46 # | |
47 __default_conf_dir__ = %(conf)r | |
48 __default_templates_dir__ = %(templates)r | |
49 __default_htdocs_dir__ = %(htdocs)r | |
50 __default_wiki_dir__ = %(wiki)r | |
51 __default_macros_dir__ = %(macros)r | |
52 __default_plugins_dir__ = %(plugins)r | |
53 | |
54 """ % {'trac': PACKAGE, 'ver': VERSION, 'conf': _p(conf_dir), | |
55 'templates': _p(templates_dir), 'htdocs': _p(htdocs_dir), | |
56 'wiki': _p(wiki_dir), 'macros': _p(macros_dir), | |
57 'plugins': _p(plugins_dir)}) | |
58 f.close() | |
59 | |
60 # Run actual install | |
61 install.run(self) | |
62 print | |
63 print "Thank you for choosing Trac %s. Enjoy your stay!" % VERSION | |
64 print | |
65 | |
66 class my_install_scripts (install_scripts): | |
67 def initialize_options (self): | |
68 install_scripts.initialize_options(self) | |
69 self.install_data = None | |
70 | |
71 def finalize_options (self): | |
72 install_scripts.finalize_options(self) | |
73 self.set_undefined_options('install', | |
74 ('install_data', 'install_data')) | |
75 | |
76 def run (self): | |
77 if not self.skip_build: | |
78 self.run_command('build_scripts') | |
79 | |
80 self.outfiles = [] | |
81 | |
82 self.mkpath(os.path.normpath(self.install_dir)) | |
83 ofile, copied = self.copy_file(os.path.join(self.build_dir, | |
84 'trac-admin'), | |
85 self.install_dir) | |
86 if copied: | |
87 self.outfiles.append(ofile) | |
88 ofile, copied = self.copy_file(os.path.join(self.build_dir, | |
89 'tracd'), | |
90 self.install_dir) | |
91 if copied: | |
92 self.outfiles.append(ofile) | |
93 ofile, copied = self.copy_file(os.path.join(self.build_dir, | |
94 'tracdb2env'), | |
95 self.install_dir) | |
96 if copied: | |
97 self.outfiles.append(ofile) | |
98 | |
99 cgi_dir = os.path.join(self.install_data, 'share', 'trac', 'cgi-bin') | |
100 if not os.path.exists(cgi_dir): | |
101 os.makedirs(cgi_dir) | |
102 | |
103 ofile, copied = self.copy_file(os.path.join(self.build_dir, | |
104 'trac.cgi'), cgi_dir) | |
105 if copied: | |
106 self.outfiles.append(ofile) | |
107 | |
108 ofile, copied = self.copy_file(os.path.join(self.build_dir, | |
109 'trac.fcgi'), cgi_dir) | |
110 if copied: | |
111 self.outfiles.append(ofile) | |
112 | |
113 for path in ('plugins', 'conf'): | |
114 full_path = os.path.join(self.install_data, 'share', 'trac', path) | |
115 if not os.path.exists(full_path): | |
116 os.makedirs(full_path) | |
117 | |
118 if os.name == 'posix': | |
119 # Set the executable bits (owner, group, and world) on | |
120 # all the scripts we just installed. | |
121 for file in self.get_outputs(): | |
122 if not self.dry_run: | |
123 mode = ((os.stat(file)[ST_MODE]) | 0555) & 07777 | |
124 os.chmod(file, mode) | |
125 elif os.name == 'nt': | |
126 # Install post-install script on windows | |
127 ofile, copied = self.copy_file(os.path.join(self.build_dir, | |
128 'trac-postinstall.py'), | |
129 self.install_dir) | |
130 if copied: | |
131 self.outfiles.append(ofile) | |
132 | |
133 | |
134 class my_install_data (install_data): | |
135 def run (self): | |
136 install_data.run(self) | |
137 | |
138 if os.name == 'posix' and not self.dry_run: | |
139 # Make the data files we just installed world-readable, | |
140 # and the directories world-executable as well. | |
141 for path in self.get_outputs(): | |
142 mode = os.stat(path)[ST_MODE] | |
143 if S_ISDIR(mode): | |
144 mode |= 011 | |
145 mode |= 044 | |
146 os.chmod(path, mode) | |
147 | |
148 # Our custom bdist_wininst | |
149 import distutils.command.bdist_wininst | |
150 from distutils.command.bdist_wininst import bdist_wininst | |
151 class my_bdist_wininst(bdist_wininst): | |
152 def initialize_options(self): | |
153 bdist_wininst.initialize_options(self) | |
154 self.title = 'Trac %s' % VERSION | |
155 self.bitmap = 'setup_wininst.bmp' | |
156 self.install_script = 'trac-postinstall.py' | |
157 distutils.command.bdist_wininst.bdist_wininst = my_bdist_wininst | |
158 | |
159 | |
160 # parameters for various rpm distributions | |
161 rpm_distros = { | |
162 'suse_options': { 'version_suffix': 'SuSE', | |
163 'requires': """python >= 2.3 | |
164 subversion >= 1.0.0 | |
165 pysqlite >= 0.4.3 | |
166 clearsilver >= 0.9.3 | |
167 httpd""" }, | |
168 | |
169 'fedora_options': { 'version_suffix': 'fc'} | |
170 } | |
171 | |
172 | |
173 # Our custom bdist_rpm | |
174 import distutils.command.bdist_rpm | |
175 from distutils.command.bdist_rpm import bdist_rpm | |
176 class generic_bdist_rpm(bdist_rpm): | |
177 | |
178 def __init__(self, dist, distro): | |
179 self.distro = distro | |
180 bdist_rpm.__init__(self, dist) | |
181 | |
182 def initialize_options(self): | |
183 bdist_rpm.initialize_options(self) | |
184 self.title = "Trac %s" % VERSION | |
185 self.packager = "Edgewall Software <info@edgewall.com>" | |
186 for x in rpm_distros[self.distro].keys(): | |
187 setattr(self, x, rpm_distros[self.distro][x]) | |
188 self.install_script = "scripts/rpm-install.sh" | |
189 | |
190 def run(self): | |
191 bdist_rpm.run(self) | |
192 if hasattr(self, 'version_suffix'): | |
193 prefix = os.path.join(self.dist_dir, string.lower(PACKAGE)+'-'+VERSION+'-1') | |
194 os.rename(prefix+'.noarch.rpm', prefix+self.version_suffix+'.noarch.rpm') | |
195 os.rename(prefix+'.src.rpm', prefix+self.version_suffix+'.src.rpm') | |
196 | |
197 class proxy_bdist_rpm(bdist_rpm): | |
198 | |
199 def __init__(self, dist): | |
200 bdist_rpm.__init__(self, dist) | |
201 self.dist = dist | |
202 | |
203 def initialize_options(self): | |
204 bdist_rpm.initialize_options(self) | |
205 | |
206 def run(self): | |
207 for distro in rpm_distros.keys(): | |
208 r = generic_bdist_rpm(self.dist, distro) | |
209 r.initialize_options() | |
210 self.dist._set_command_options(r, self.dist.command_options['bdist_rpm']) | |
211 r.finalize_options() | |
212 r.run() | |
213 | |
214 distutils.command.bdist_rpm.bdist_rpm = proxy_bdist_rpm | |
215 | |
216 setup(name="trac", | |
217 description="Integrated scm, wiki, issue tracker and project environment", | |
218 long_description=\ | |
219 """ | |
220 Trac is a minimalistic web-based software project management and bug/issue | |
221 tracking system. It provides an interface to the Subversion revision control | |
222 systems, an integrated wiki, flexible issue tracking and convenient report | |
223 facilities. | |
224 """, | |
225 version=VERSION, | |
226 author="Edgewall Software", | |
227 author_email="info@edgewall.com", | |
228 license=LICENSE, | |
229 url=URL, | |
230 packages=['trac', 'trac.db', 'trac.mimeview', 'trac.scripts', | |
231 'trac.ticket', 'trac.upgrades', 'trac.util', 'trac.web', | |
232 'trac.versioncontrol', 'trac.versioncontrol.web_ui', | |
233 'trac.wiki'], | |
234 data_files=[(_p('share/trac/templates'), glob('templates/*')), | |
235 (_p('share/trac/htdocs'), glob(_p('htdocs/*.*')) + [_p('htdocs/README')]), | |
236 (_p('share/trac/htdocs/css'), glob(_p('htdocs/css/*'))), | |
237 (_p('share/trac/htdocs/js'), glob(_p('htdocs/js/*'))), | |
238 (_p('share/man/man1'), glob(_p('scripts/*.1'))), | |
239 (_p('share/trac/wiki-default'), glob(_p('wiki-default/[A-Z]*'))), | |
240 (_p('share/trac/wiki-macros'), glob(_p('wiki-macros/*.py')))], | |
241 scripts=[_p('scripts/trac-admin'), | |
242 _p('scripts/trac-postinstall.py'), | |
243 _p('scripts/tracd'), | |
244 _p('scripts/tracdb2env'), | |
245 _p('cgi-bin/trac.cgi'), | |
246 _p('cgi-bin/trac.fcgi')], | |
247 cmdclass = {'install': my_install, | |
248 'install_scripts': my_install_scripts, | |
249 'install_data': my_install_data}) |