Code

check MANIFEST against the files actually unpacked
[roundup.git] / setup.py
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.60 2004-04-16 10:43:51 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
25 import sys, os, string
26 from glob import glob
28 # patch distutils if it can't cope with the "classifiers" keyword
29 from distutils.dist import DistributionMetadata
30 if not hasattr(DistributionMetadata, 'classifiers'):
31     DistributionMetadata.classifiers = None
32     DistributionMetadata.download_url = None
35 #############################################################################
36 ### Build script files
37 #############################################################################
39 class build_scripts_create(build_scripts):
40     """ Overload the build_scripts command and create the scripts
41         from scratch, depending on the target platform.
43         You have to define the name of your package in an inherited
44         class (due to the delayed instantiation of command classes
45         in distutils, this cannot be passed to __init__).
47         The scripts are created in an uniform scheme: they start the
48         run() function in the module
50             <packagename>.scripts.<mangled_scriptname>
52         The mangling of script names replaces '-' and '/' characters
53         with '-' and '.', so that they are valid module paths. 
54     """
55     package_name = None
57     def copy_scripts(self):
58         """ Create each script listed in 'self.scripts'
59         """
60         if not self.package_name:
61             raise Exception("You have to inherit build_scripts_create and"
62                 " provide a package name")
63         
64         to_module = string.maketrans('-/', '_.')
66         self.mkpath(self.build_dir)
67         for script in self.scripts:
68             outfile = os.path.join(self.build_dir, os.path.basename(script))
70             #if not self.force and not newer(script, outfile):
71             #    self.announce("not copying %s (up-to-date)" % script)
72             #    continue
74             if self.dry_run:
75                 self.announce("would create %s" % outfile)
76                 continue
78             module = os.path.splitext(os.path.basename(script))[0]
79             module = string.translate(module, to_module)
80             cmdopt=self.distribution.command_options
81             if (cmdopt.has_key('install') and
82                 cmdopt['install'].has_key('prefix')):
83                 prefix = cmdopt['install']['prefix'][1]
84                 version = '%d.%d'%sys.version_info[:2]
85                 prefix = '''
86 import sys
87 sys.path.insert(1, "%s/lib/python%s/site-packages")
88 '''%(prefix, version)
89             else:
90                 prefix = ''
91             script_vars = {
92                 'python': os.path.normpath(sys.executable),
93                 'package': self.package_name,
94                 'module': module,
95                 'prefix': prefix,
96             }
98             self.announce("creating %s" % outfile)
99             file = open(outfile, 'w')
101             try:
102                 if sys.platform == "win32":
103                     file.write('@echo off\n'
104                         'if NOT "%%_4ver%%" == "" "%(python)s" -O -c "from %(package)s.scripts.%(module)s import run; run()" %%$\n'
105                         'if     "%%_4ver%%" == "" "%(python)s" -O -c "from %(package)s.scripts.%(module)s import run; run()" %%*\n'
106                         % script_vars)
107                 else:
108                     file.write('#! %(python)s -O\n%(prefix)s'
109                         'from %(package)s.scripts.%(module)s import run\n'
110                         'run()\n'
111                         % script_vars)
112             finally:
113                 file.close()
114                 os.chmod(outfile, 0755)
117 class build_scripts_roundup(build_scripts_create):
118     package_name = 'roundup'
121 def scriptname(path):
122     """ Helper for building a list of script names from a list of
123         module files.
124     """
125     script = os.path.splitext(os.path.basename(path))[0]
126     script = string.replace(script, '_', '-')
127     if sys.platform == "win32":
128         script = script + ".bat"
129     return script
131 def check_manifest():
132     """Check that the files listed in the MANIFEST are present when the
133     source is unpacked.
134     """
135     try:
136         f = open('MANIFEST')
137     except:
138         print '\n*** SOURCE ERROR: The MANIFEST file is missing!'
139         sys.exit(1)
140     try:
141         manifest = [l.strip() for l in f.readlines()]
142     finally:
143         f.close()
144     err = [line for line in manifest if not os.path.exists(line)]
145     if err:
146         n = len(manifest)
147         print '\n*** SOURCE ERROR: There are files missing (%d/%d found)!'%(
148             n-len(err), n)
149         sys.exit(1)
152 #############################################################################
153 ### Main setup stuff
154 #############################################################################
156 def main():
157     # build list of scripts from their implementation modules
158     roundup_scripts = map(scriptname, glob('roundup/scripts/[!_]*.py'))
160     # template munching
161     packagelist = [
162         'roundup',
163         'roundup.cgi',
164         'roundup.cgi.PageTemplates',
165         'roundup.cgi.TAL',
166         'roundup.cgi.ZTUtils',
167         'roundup.backends',
168         'roundup.scripts'
169     ]
170     installdatafiles = [
171         ('share/roundup/cgi-bin', ['cgi-bin/roundup.cgi']),
172     ] 
174     # install man pages on POSIX platforms
175     if os.name == 'posix':
176         installdatafiles.append(('man/man1', ['doc/roundup-admin.1',
177             'doc/roundup-mailgw.1', 'doc/roundup-server.1']))
179     # add the templates to the data files lists
180     from roundup.init import listTemplates
181     templates = [t['path'] for t in listTemplates('templates').values()]
182     for tdir in templates:
183         # scan for data files
184         for idir in '. detectors html'.split():
185             idir = os.path.join(tdir, idir)
186             tfiles = []
187             for f in os.listdir(idir):
188                 if f.startswith('.'):
189                     continue
190                 ifile = os.path.join(idir, f)
191                 if os.path.isfile(ifile):
192                     tfiles.append(ifile)
193             installdatafiles.append(
194                 (os.path.join('share', 'roundup', idir), tfiles)
195             )
197     # perform the setup action
198     from roundup import __version__
199     setup(
200         name = "roundup", 
201         version = __version__,
202         description = "A simple-to-use and -install issue-tracking system"
203             " with command-line, web and e-mail interfaces. Highly"
204             " customisable.",
205         long_description = 
206 '''Roundup is a simple-to-use and -install issue-tracking system with
207 command-line, web and e-mail interfaces. It is based on the winning design
208 from Ka-Ping Yee in the Software Carpentry "Track" design competition.
210 If you're upgrading from an older version of Roundup you *must* follow
211 the "Software Upgrade" guidelines given in the maintenance documentation.
213 No, really, this is a BETA and if you don't follow the upgrading steps,
214 particularly the bit about BACKING UP YOUR DATA, I'm NOT GOING TO BE HELD
215 RESPONSIBLE. This release is NOT FOR GENERAL USE.
217 I would *greatly* appreciate people giving this release a whirl with a
218 copy of their existing setup. It's only through real-world testing of
219 beta releases that we can ensure that older trackers will be OK.
221 This release introduces far too many features to list here. Some
222 highlights:
224 - added postgresql backend (originally from sf patch 761740, many changes
225   since)
226 - RDBMS backends implement their session and one-time-key stores and
227   full-text indexers; thus they are now performing their own locking
228   internally
229 - added new "actor" automatic property (indicates user who cause the last
230   "activity")
231 - all RDBMS backends have sensible data typed columns and indexes on
232   several columns
233 - we support confirming registration by replying to the email (sf bug
234   763668)
235 - all HTML templating methods now automatically check for permissions
236   (either view or edit as appropriate), greatly simplifying templates
237 ''',
238         author = "Richard Jones",
239         author_email = "richard@users.sourceforge.net",
240         url = 'http://roundup.sourceforge.net/',
241         download_url = 'http://sourceforge.net/project/showfiles.php?group_id=31577',
242         packages = packagelist,
243         classifiers = [
244             'Development Status :: 4 - Beta',
245             'Environment :: Console',
246             'Environment :: Web Environment',
247             'Intended Audience :: End Users/Desktop',
248             'Intended Audience :: Developers',
249             'Intended Audience :: System Administrators',
250             'License :: OSI Approved :: Python Software Foundation License',
251             'Operating System :: MacOS :: MacOS X',
252             'Operating System :: Microsoft :: Windows',
253             'Operating System :: POSIX',
254             'Programming Language :: Python',
255             'Topic :: Communications :: Email',
256             'Topic :: Office/Business',
257             'Topic :: Software Development :: Bug Tracking',
258         ],
260         # Override certain command classes with our own ones
261         cmdclass = {
262             'build_scripts': build_scripts_roundup,
263         },
264         scripts = roundup_scripts,
266         data_files =  installdatafiles
267     )
269 if __name__ == '__main__':
270     main()
272 # vim: set filetype=python ts=4 sw=4 et si