File: setup.py

package info (click to toggle)
trac 0.10.3-1
  • links: PTS
  • area: main
  • in suites: etch-m68k
  • size: 2,692 kB
  • ctags: 2,972
  • sloc: python: 22,683; cs: 3,174; sh: 30; makefile: 10
file content (243 lines) | stat: -rwxr-xr-x 9,089 bytes parent folder | download | duplicates (2)
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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
#!/usr/bin/env python

import os
import os.path
import sys
import string
from glob import glob
from distutils.core import setup
from distutils.command.install import install
from distutils.command.install_data import install_data
from distutils.command.install_scripts import install_scripts
from stat import ST_MODE, S_ISDIR

import trac

PACKAGE = 'Trac'
VERSION = str(trac.__version__)
URL = trac.__url__
LICENSE = trac.__license__

if sys.version_info < (2, 3):
    print >>sys.stderr, 'You need at least Python 2.3 for %s %s' \
                        % (PACKAGE, VERSION)
    sys.exit(3)

def _p(unix_path):
     return os.path.normpath(unix_path)

class my_install (install):
     def run (self):
         self.siteconfig()

     def siteconfig(self):
         path = self.prefix or self.home
         path = os.path.expanduser(path)
         conf_dir = os.path.join(path, 'share', 'trac', 'conf')
         templates_dir = os.path.join(path, 'share', 'trac', 'templates')
         htdocs_dir = os.path.join(path, 'share', 'trac', 'htdocs')
         wiki_dir = os.path.join(path, 'share', 'trac', 'wiki-default')
         macros_dir = os.path.join(path, 'share', 'trac', 'wiki-macros')
         plugins_dir = os.path.join(path, 'share', 'trac', 'plugins')
         f = open(_p('trac/siteconfig.py'), 'w')
         f.write("""
# PLEASE DO NOT EDIT THIS FILE!
# This file was autogenerated when installing %(trac)s %(ver)s.
#
__default_conf_dir__ = %(conf)r
__default_templates_dir__ = %(templates)r
__default_htdocs_dir__ = %(htdocs)r
__default_wiki_dir__ = %(wiki)r
__default_macros_dir__ = %(macros)r
__default_plugins_dir__ = %(plugins)r

""" % {'trac': PACKAGE, 'ver': VERSION, 'conf': _p(conf_dir),
       'templates': _p(templates_dir), 'htdocs': _p(htdocs_dir),
       'wiki': _p(wiki_dir), 'macros': _p(macros_dir),
       'plugins': _p(plugins_dir)})
         f.close()

         # Run actual install
         install.run(self)
         print
         print "Thank you for choosing Trac %s. Enjoy your stay!" % VERSION
         print

class my_install_scripts (install_scripts):
    def initialize_options (self):
        install_scripts.initialize_options(self)
        self.install_data = None
        
    def finalize_options (self):
        install_scripts.finalize_options(self)
        self.set_undefined_options('install',
                                   ('install_data', 'install_data'))
          
    def run (self):
        if not self.skip_build:
            self.run_command('build_scripts')

        self.outfiles = []

        self.mkpath(os.path.normpath(self.install_dir))
        ofile, copied = self.copy_file(os.path.join(self.build_dir,
                                                     'trac-admin'),
                                        self.install_dir)
        if copied:
            self.outfiles.append(ofile)
        ofile, copied = self.copy_file(os.path.join(self.build_dir,
                                                     'tracd'),
                                        self.install_dir)
        if copied:
            self.outfiles.append(ofile)
            
        cgi_dir = os.path.join(self.install_data, 'share', 'trac', 'cgi-bin')
        if not os.path.exists(cgi_dir):
            os.makedirs(cgi_dir)
            
        ofile, copied = self.copy_file(os.path.join(self.build_dir,
                                                    'trac.cgi'), cgi_dir)
        if copied:
            self.outfiles.append(ofile)

        ofile, copied = self.copy_file(os.path.join(self.build_dir,
                                                    'trac.fcgi'), cgi_dir)
        if copied:
            self.outfiles.append(ofile)
         
        for path in ('plugins', 'conf'):
            full_path = os.path.join(self.install_data, 'share', 'trac', path)
            if not os.path.exists(full_path):
                os.makedirs(full_path)
            
        if os.name == 'posix':
            # Set the executable bits (owner, group, and world) on
            # all the scripts we just installed.
            for file in self.get_outputs():
                if not self.dry_run:
                    mode = ((os.stat(file)[ST_MODE]) | 0555) & 07777
                    os.chmod(file, mode)
        elif os.name == 'nt':
            # Install post-install script on windows
            ofile, copied = self.copy_file(os.path.join(self.build_dir,
                                                        'trac-postinstall.py'),
                                            self.install_dir)
            if copied:
                self.outfiles.append(ofile)


class my_install_data (install_data):
    def run (self):
        install_data.run(self)

        if os.name == 'posix' and not self.dry_run:
            # Make the data files we just installed world-readable,
            # and the directories world-executable as well.
            for path in self.get_outputs():
                mode = os.stat(path)[ST_MODE]
                if S_ISDIR(mode):
                    mode |= 011
                mode |= 044
                os.chmod(path, mode)

# Our custom bdist_wininst
import distutils.command.bdist_wininst
from distutils.command.bdist_wininst import bdist_wininst
class my_bdist_wininst(bdist_wininst):
    def initialize_options(self):
        bdist_wininst.initialize_options(self)
        self.title = 'Trac %s' % VERSION
        self.bitmap = 'setup_wininst.bmp'
        self.install_script = 'trac-postinstall.py'
distutils.command.bdist_wininst.bdist_wininst = my_bdist_wininst


# parameters for various rpm distributions
rpm_distros = {
    'suse_options': { 'version_suffix': 'SuSE',
                      'requires': """python >= 2.3
                        subversion >= 1.0.0
                        pysqlite >= 0.4.3
                        clearsilver >= 0.9.3
                        httpd""" },

    'fedora_options': { 'version_suffix': 'fc'}
    }


# Our custom bdist_rpm
import distutils.command.bdist_rpm
from distutils.command.bdist_rpm import bdist_rpm
class generic_bdist_rpm(bdist_rpm):

    def __init__(self, dist, distro):
        self.distro = distro
        bdist_rpm.__init__(self, dist)

    def initialize_options(self):
        bdist_rpm.initialize_options(self)
        self.title = "Trac %s" % VERSION
        self.packager = "Edgewall Software <info@edgewall.com>"
        for x in rpm_distros[self.distro].keys():
            setattr(self, x, rpm_distros[self.distro][x])
        self.install_script = "scripts/rpm-install.sh"

    def run(self):
        bdist_rpm.run(self)
        if hasattr(self, 'version_suffix'):
            prefix = os.path.join(self.dist_dir, string.lower(PACKAGE)+'-'+VERSION+'-1')
            os.rename(prefix+'.noarch.rpm', prefix+self.version_suffix+'.noarch.rpm')
            os.rename(prefix+'.src.rpm', prefix+self.version_suffix+'.src.rpm')

class proxy_bdist_rpm(bdist_rpm):

    def __init__(self, dist):
        bdist_rpm.__init__(self, dist)
        self.dist = dist

    def initialize_options(self):
        bdist_rpm.initialize_options(self)

    def run(self):
        for distro in rpm_distros.keys():
            r = generic_bdist_rpm(self.dist, distro)
            r.initialize_options()
            self.dist._set_command_options(r, self.dist.command_options['bdist_rpm'])
            r.finalize_options()
            r.run()

distutils.command.bdist_rpm.bdist_rpm = proxy_bdist_rpm

setup(name="trac",
      description="Integrated scm, wiki, issue tracker and project environment",
      long_description=\
"""
Trac is a minimalistic web-based software project management and bug/issue
tracking system. It provides an interface to the Subversion revision control
systems, an integrated wiki, flexible issue tracking and convenient report
facilities.
""",
      version=VERSION,
      author="Edgewall Software",
      author_email="info@edgewall.com",
      license=LICENSE,
      url=URL,
      packages=['trac', 'trac.db', 'trac.mimeview', 'trac.scripts',
                'trac.ticket', 'trac.upgrades', 'trac.util', 'trac.web',
                'trac.versioncontrol', 'trac.versioncontrol.web_ui', 
                'trac.wiki'],
      data_files=[(_p('share/trac/templates'), glob('templates/*')),
                  (_p('share/trac/htdocs'), glob(_p('htdocs/*.*')) + [_p('htdocs/README')]),
                  (_p('share/trac/htdocs/css'), glob(_p('htdocs/css/*'))),
                  (_p('share/trac/htdocs/js'), glob(_p('htdocs/js/*'))),
                  (_p('share/man/man1'), glob(_p('scripts/*.1'))),
                  (_p('share/trac/wiki-default'), glob(_p('wiki-default/[A-Z]*'))),
                  (_p('share/trac/wiki-macros'), glob(_p('wiki-macros/*.py')))],
      scripts=[_p('scripts/trac-admin'),
               _p('scripts/trac-postinstall.py'),
               _p('scripts/tracd'),
               _p('cgi-bin/trac.cgi'),
               _p('cgi-bin/trac.fcgi')],
      cmdclass = {'install': my_install,
                  'install_scripts': my_install_scripts,
                  'install_data': my_install_data})