1 #! /usr/bin/env python
2 #
3 # Copyright (c) 2001 Bizar Software Pty Ltd (http://www.bizarsoftware.com.au/)
4 # This module is free software, and you may redistribute it and/or modify
5 # under the same terms as Python, so long as this copyright message and
6 # disclaimer are retained in their original form.
7 #
8 # IN NO EVENT SHALL BIZAR SOFTWARE PTY LTD BE LIABLE TO ANY PARTY FOR
9 # DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING
10 # OUT OF THE USE OF THIS CODE, EVEN IF THE AUTHOR HAS BEEN ADVISED OF THE
11 # POSSIBILITY OF SUCH DAMAGE.
12 #
13 # BIZAR SOFTWARE PTY LTD SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
14 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
15 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS"
16 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
17 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
18 #
19 # $Id: setup.py,v 1.61 2004-04-17 01:47:15 richard Exp $
21 from distutils.core import setup, Extension
22 from distutils.util import get_platform
23 from distutils.command.build_scripts import build_scripts
24 from distutils.command.build import build
26 import sys, os, string
27 from glob import glob
29 # patch distutils if it can't cope with the "classifiers" keyword
30 from distutils.dist import DistributionMetadata
31 if not hasattr(DistributionMetadata, 'classifiers'):
32 DistributionMetadata.classifiers = None
33 DistributionMetadata.download_url = None
36 #############################################################################
37 ### Build script files
38 #############################################################################
40 class build_scripts_create(build_scripts):
41 """ Overload the build_scripts command and create the scripts
42 from scratch, depending on the target platform.
44 You have to define the name of your package in an inherited
45 class (due to the delayed instantiation of command classes
46 in distutils, this cannot be passed to __init__).
48 The scripts are created in an uniform scheme: they start the
49 run() function in the module
51 <packagename>.scripts.<mangled_scriptname>
53 The mangling of script names replaces '-' and '/' characters
54 with '-' and '.', so that they are valid module paths.
55 """
56 package_name = None
58 def copy_scripts(self):
59 """ Create each script listed in 'self.scripts'
60 """
61 if not self.package_name:
62 raise Exception("You have to inherit build_scripts_create and"
63 " provide a package name")
65 to_module = string.maketrans('-/', '_.')
67 self.mkpath(self.build_dir)
68 for script in self.scripts:
69 outfile = os.path.join(self.build_dir, os.path.basename(script))
71 #if not self.force and not newer(script, outfile):
72 # self.announce("not copying %s (up-to-date)" % script)
73 # continue
75 if self.dry_run:
76 self.announce("would create %s" % outfile)
77 continue
79 module = os.path.splitext(os.path.basename(script))[0]
80 module = string.translate(module, to_module)
81 cmdopt=self.distribution.command_options
82 if (cmdopt.has_key('install') and
83 cmdopt['install'].has_key('prefix')):
84 prefix = cmdopt['install']['prefix'][1]
85 version = '%d.%d'%sys.version_info[:2]
86 prefix = '''
87 import sys
88 sys.path.insert(1, "%s/lib/python%s/site-packages")
89 '''%(prefix, version)
90 else:
91 prefix = ''
92 script_vars = {
93 'python': os.path.normpath(sys.executable),
94 'package': self.package_name,
95 'module': module,
96 'prefix': prefix,
97 }
99 self.announce("creating %s" % outfile)
100 file = open(outfile, 'w')
102 try:
103 if sys.platform == "win32":
104 file.write('@echo off\n'
105 'if NOT "%%_4ver%%" == "" "%(python)s" -O -c "from %(package)s.scripts.%(module)s import run; run()" %%$\n'
106 'if "%%_4ver%%" == "" "%(python)s" -O -c "from %(package)s.scripts.%(module)s import run; run()" %%*\n'
107 % script_vars)
108 else:
109 file.write('#! %(python)s -O\n%(prefix)s'
110 'from %(package)s.scripts.%(module)s import run\n'
111 'run()\n'
112 % script_vars)
113 finally:
114 file.close()
115 os.chmod(outfile, 0755)
118 class build_scripts_roundup(build_scripts_create):
119 package_name = 'roundup'
122 def scriptname(path):
123 """ Helper for building a list of script names from a list of
124 module files.
125 """
126 script = os.path.splitext(os.path.basename(path))[0]
127 script = string.replace(script, '_', '-')
128 if sys.platform == "win32":
129 script = script + ".bat"
130 return script
132 def check_manifest():
133 """Check that the files listed in the MANIFEST are present when the
134 source is unpacked.
135 """
136 try:
137 f = open('MANIFEST')
138 except:
139 print '\n*** SOURCE ERROR: The MANIFEST file is missing!'
140 sys.exit(1)
141 try:
142 manifest = [l.strip() for l in f.readlines()]
143 finally:
144 f.close()
145 err = [line for line in manifest if not os.path.exists(line)]
146 if err:
147 n = len(manifest)
148 print '\n*** SOURCE ERROR: There are files missing (%d/%d found)!'%(
149 n-len(err), n)
150 sys.exit(1)
153 class build_roundup(build):
154 def run(self):
155 check_manifest()
156 build.run(self)
158 #############################################################################
159 ### Main setup stuff
160 #############################################################################
162 def main():
163 # build list of scripts from their implementation modules
164 roundup_scripts = map(scriptname, glob('roundup/scripts/[!_]*.py'))
166 # template munching
167 packagelist = [
168 'roundup',
169 'roundup.cgi',
170 'roundup.cgi.PageTemplates',
171 'roundup.cgi.TAL',
172 'roundup.cgi.ZTUtils',
173 'roundup.backends',
174 'roundup.scripts'
175 ]
176 installdatafiles = [
177 ('share/roundup/cgi-bin', ['cgi-bin/roundup.cgi']),
178 ]
180 # install man pages on POSIX platforms
181 if os.name == 'posix':
182 installdatafiles.append(('man/man1', ['doc/roundup-admin.1',
183 'doc/roundup-mailgw.1', 'doc/roundup-server.1']))
185 # add the templates to the data files lists
186 from roundup.init import listTemplates
187 templates = [t['path'] for t in listTemplates('templates').values()]
188 for tdir in templates:
189 # scan for data files
190 for idir in '. detectors html'.split():
191 idir = os.path.join(tdir, idir)
192 tfiles = []
193 for f in os.listdir(idir):
194 if f.startswith('.'):
195 continue
196 ifile = os.path.join(idir, f)
197 if os.path.isfile(ifile):
198 tfiles.append(ifile)
199 installdatafiles.append(
200 (os.path.join('share', 'roundup', idir), tfiles)
201 )
203 # perform the setup action
204 from roundup import __version__
205 setup(
206 name = "roundup",
207 version = __version__,
208 description = "A simple-to-use and -install issue-tracking system"
209 " with command-line, web and e-mail interfaces. Highly"
210 " customisable.",
211 long_description =
212 '''Roundup is a simple-to-use and -install issue-tracking system with
213 command-line, web and e-mail interfaces. It is based on the winning design
214 from Ka-Ping Yee in the Software Carpentry "Track" design competition.
216 If you're upgrading from an older version of Roundup you *must* follow
217 the "Software Upgrade" guidelines given in the maintenance documentation.
219 No, really, this is a BETA and if you don't follow the upgrading steps,
220 particularly the bit about BACKING UP YOUR DATA, I'm NOT GOING TO BE HELD
221 RESPONSIBLE. This release is NOT FOR GENERAL USE.
223 I would *greatly* appreciate people giving this release a whirl with a
224 copy of their existing setup. It's only through real-world testing of
225 beta releases that we can ensure that older trackers will be OK.
227 This release introduces far too many features to list here. Some
228 highlights:
230 - added postgresql backend (originally from sf patch 761740, many changes
231 since)
232 - RDBMS backends implement their session and one-time-key stores and
233 full-text indexers; thus they are now performing their own locking
234 internally
235 - added new "actor" automatic property (indicates user who cause the last
236 "activity")
237 - all RDBMS backends have sensible data typed columns and indexes on
238 several columns
239 - we support confirming registration by replying to the email (sf bug
240 763668)
241 - all HTML templating methods now automatically check for permissions
242 (either view or edit as appropriate), greatly simplifying templates
243 ''',
244 author = "Richard Jones",
245 author_email = "richard@users.sourceforge.net",
246 url = 'http://roundup.sourceforge.net/',
247 download_url = 'http://sourceforge.net/project/showfiles.php?group_id=31577',
248 packages = packagelist,
249 classifiers = [
250 'Development Status :: 4 - Beta',
251 'Environment :: Console',
252 'Environment :: Web Environment',
253 'Intended Audience :: End Users/Desktop',
254 'Intended Audience :: Developers',
255 'Intended Audience :: System Administrators',
256 'License :: OSI Approved :: Python Software Foundation License',
257 'Operating System :: MacOS :: MacOS X',
258 'Operating System :: Microsoft :: Windows',
259 'Operating System :: POSIX',
260 'Programming Language :: Python',
261 'Topic :: Communications :: Email',
262 'Topic :: Office/Business',
263 'Topic :: Software Development :: Bug Tracking',
264 ],
266 # Override certain command classes with our own ones
267 cmdclass = {
268 'build_scripts': build_scripts_roundup,
269 'build': build_roundup,
270 },
271 scripts = roundup_scripts,
273 data_files = installdatafiles
274 )
276 if __name__ == '__main__':
277 main()
279 # vim: set filetype=python ts=4 sw=4 et si