Trac / setup.py

#!/usr/bin/env python

import os
import os.path
import sys
from glob import glob
from distutils.core import setup
from distutils.command.install import install
import trac

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

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

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

     def siteconfig(self):
         templates_dir = os.path.join(self.prefix, 'share','trac','templates')
         htdocs_dir = os.path.join(self.prefix, 'share','trac','htdocs')
         wiki_dir = os.path.join(self.prefix, 'share','trac','wiki-default')
         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_templates_dir__ = '%(templates)s'
__default_htdocs_dir__ = '%(htdocs)s'
__default_wiki_dir__ = '%(wiki)s'

""" % {'trac':PACKAGE, 'ver':VERSION, 'templates':_p(templates_dir),
       'htdocs':_p(htdocs_dir), 'wiki':_p(wiki_dir)})
         f.close()

         # Run actual install
         install.run(self)

         print
         print "Thank you for choosing Trac %s. Enjoy your stay!" % VERSION
         print trac.__credits__

setup(name="trac",
      description="Trac - Wiki-based issue tracker and project environment",
      version=VERSION,
      author="Edgewall Software",
      author_email="info@edgewall.com",
      license=LICENSE,
      url=URL,
      packages=['trac'],
      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/wiki-default'), glob(_p('wiki-default/*')))],
      scripts=[_p('scripts/trac-admin')],
      cmdclass = {'install': my_install})
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.