cmlenz@39: #!/usr/bin/env python cmlenz@39: cmlenz@39: import os cmlenz@39: import os.path cmlenz@39: import sys cmlenz@39: import string cmlenz@39: from glob import glob cmlenz@39: from distutils.core import setup cmlenz@39: from distutils.command.install import install cmlenz@39: from distutils.command.install_data import install_data cmlenz@39: from distutils.command.install_scripts import install_scripts cmlenz@39: from stat import ST_MODE, S_ISDIR cmlenz@39: cmlenz@39: import trac cmlenz@39: cmlenz@39: PACKAGE = 'Trac' cmlenz@39: VERSION = str(trac.__version__) cmlenz@39: URL = trac.__url__ cmlenz@39: LICENSE = trac.__license__ cmlenz@39: cmlenz@39: if sys.version_info < (2, 3): cmlenz@39: print >>sys.stderr, 'You need at least Python 2.3 for %s %s' \ cmlenz@39: % (PACKAGE, VERSION) cmlenz@39: sys.exit(3) cmlenz@39: cmlenz@39: def _p(unix_path): cmlenz@39: return os.path.normpath(unix_path) cmlenz@39: cmlenz@39: class my_install (install): cmlenz@39: def run (self): cmlenz@39: self.siteconfig() cmlenz@39: cmlenz@39: def siteconfig(self): cmlenz@39: path = self.prefix or self.home cmlenz@39: path = os.path.expanduser(path) cmlenz@39: conf_dir = os.path.join(path, 'share', 'trac', 'conf') cmlenz@39: templates_dir = os.path.join(path, 'share', 'trac', 'templates') cmlenz@39: htdocs_dir = os.path.join(path, 'share', 'trac', 'htdocs') cmlenz@39: wiki_dir = os.path.join(path, 'share', 'trac', 'wiki-default') cmlenz@39: macros_dir = os.path.join(path, 'share', 'trac', 'wiki-macros') cmlenz@39: plugins_dir = os.path.join(path, 'share', 'trac', 'plugins') cmlenz@39: f = open(_p('trac/siteconfig.py'), 'w') cmlenz@39: f.write(""" cmlenz@39: # PLEASE DO NOT EDIT THIS FILE! cmlenz@39: # This file was autogenerated when installing %(trac)s %(ver)s. cmlenz@39: # cmlenz@39: __default_conf_dir__ = %(conf)r cmlenz@39: __default_templates_dir__ = %(templates)r cmlenz@39: __default_htdocs_dir__ = %(htdocs)r cmlenz@39: __default_wiki_dir__ = %(wiki)r cmlenz@39: __default_macros_dir__ = %(macros)r cmlenz@39: __default_plugins_dir__ = %(plugins)r cmlenz@39: cmlenz@39: """ % {'trac': PACKAGE, 'ver': VERSION, 'conf': _p(conf_dir), cmlenz@39: 'templates': _p(templates_dir), 'htdocs': _p(htdocs_dir), cmlenz@39: 'wiki': _p(wiki_dir), 'macros': _p(macros_dir), cmlenz@39: 'plugins': _p(plugins_dir)}) cmlenz@39: f.close() cmlenz@39: cmlenz@39: # Run actual install cmlenz@39: install.run(self) cmlenz@39: print cmlenz@39: print "Thank you for choosing Trac %s. Enjoy your stay!" % VERSION cmlenz@39: print cmlenz@39: cmlenz@39: class my_install_scripts (install_scripts): cmlenz@39: def initialize_options (self): cmlenz@39: install_scripts.initialize_options(self) cmlenz@39: self.install_data = None cmlenz@39: cmlenz@39: def finalize_options (self): cmlenz@39: install_scripts.finalize_options(self) cmlenz@39: self.set_undefined_options('install', cmlenz@39: ('install_data', 'install_data')) cmlenz@39: cmlenz@39: def run (self): cmlenz@39: if not self.skip_build: cmlenz@39: self.run_command('build_scripts') cmlenz@39: cmlenz@39: self.outfiles = [] cmlenz@39: cmlenz@39: self.mkpath(os.path.normpath(self.install_dir)) cmlenz@39: ofile, copied = self.copy_file(os.path.join(self.build_dir, cmlenz@39: 'trac-admin'), cmlenz@39: self.install_dir) cmlenz@39: if copied: cmlenz@39: self.outfiles.append(ofile) cmlenz@39: ofile, copied = self.copy_file(os.path.join(self.build_dir, cmlenz@39: 'tracd'), cmlenz@39: self.install_dir) cmlenz@39: if copied: cmlenz@39: self.outfiles.append(ofile) cmlenz@39: ofile, copied = self.copy_file(os.path.join(self.build_dir, cmlenz@39: 'tracdb2env'), cmlenz@39: self.install_dir) cmlenz@39: if copied: cmlenz@39: self.outfiles.append(ofile) cmlenz@39: cmlenz@39: cgi_dir = os.path.join(self.install_data, 'share', 'trac', 'cgi-bin') cmlenz@39: if not os.path.exists(cgi_dir): cmlenz@39: os.makedirs(cgi_dir) cmlenz@39: cmlenz@39: ofile, copied = self.copy_file(os.path.join(self.build_dir, cmlenz@39: 'trac.cgi'), cgi_dir) cmlenz@39: if copied: cmlenz@39: self.outfiles.append(ofile) cmlenz@39: cmlenz@39: ofile, copied = self.copy_file(os.path.join(self.build_dir, cmlenz@39: 'trac.fcgi'), cgi_dir) cmlenz@39: if copied: cmlenz@39: self.outfiles.append(ofile) cmlenz@39: cmlenz@39: for path in ('plugins', 'conf'): cmlenz@39: full_path = os.path.join(self.install_data, 'share', 'trac', path) cmlenz@39: if not os.path.exists(full_path): cmlenz@39: os.makedirs(full_path) cmlenz@39: cmlenz@39: if os.name == 'posix': cmlenz@39: # Set the executable bits (owner, group, and world) on cmlenz@39: # all the scripts we just installed. cmlenz@39: for file in self.get_outputs(): cmlenz@39: if not self.dry_run: cmlenz@39: mode = ((os.stat(file)[ST_MODE]) | 0555) & 07777 cmlenz@39: os.chmod(file, mode) cmlenz@39: elif os.name == 'nt': cmlenz@39: # Install post-install script on windows cmlenz@39: ofile, copied = self.copy_file(os.path.join(self.build_dir, cmlenz@39: 'trac-postinstall.py'), cmlenz@39: self.install_dir) cmlenz@39: if copied: cmlenz@39: self.outfiles.append(ofile) cmlenz@39: cmlenz@39: cmlenz@39: class my_install_data (install_data): cmlenz@39: def run (self): cmlenz@39: install_data.run(self) cmlenz@39: cmlenz@39: if os.name == 'posix' and not self.dry_run: cmlenz@39: # Make the data files we just installed world-readable, cmlenz@39: # and the directories world-executable as well. cmlenz@39: for path in self.get_outputs(): cmlenz@39: mode = os.stat(path)[ST_MODE] cmlenz@39: if S_ISDIR(mode): cmlenz@39: mode |= 011 cmlenz@39: mode |= 044 cmlenz@39: os.chmod(path, mode) cmlenz@39: cmlenz@39: # Our custom bdist_wininst cmlenz@39: import distutils.command.bdist_wininst cmlenz@39: from distutils.command.bdist_wininst import bdist_wininst cmlenz@39: class my_bdist_wininst(bdist_wininst): cmlenz@39: def initialize_options(self): cmlenz@39: bdist_wininst.initialize_options(self) cmlenz@39: self.title = 'Trac %s' % VERSION cmlenz@39: self.bitmap = 'setup_wininst.bmp' cmlenz@39: self.install_script = 'trac-postinstall.py' cmlenz@39: distutils.command.bdist_wininst.bdist_wininst = my_bdist_wininst cmlenz@39: cmlenz@39: cmlenz@39: # parameters for various rpm distributions cmlenz@39: rpm_distros = { cmlenz@39: 'suse_options': { 'version_suffix': 'SuSE', cmlenz@39: 'requires': """python >= 2.3 cmlenz@39: subversion >= 1.0.0 cmlenz@39: pysqlite >= 0.4.3 cmlenz@39: clearsilver >= 0.9.3 cmlenz@39: httpd""" }, cmlenz@39: cmlenz@39: 'fedora_options': { 'version_suffix': 'fc'} cmlenz@39: } cmlenz@39: cmlenz@39: cmlenz@39: # Our custom bdist_rpm cmlenz@39: import distutils.command.bdist_rpm cmlenz@39: from distutils.command.bdist_rpm import bdist_rpm cmlenz@39: class generic_bdist_rpm(bdist_rpm): cmlenz@39: cmlenz@39: def __init__(self, dist, distro): cmlenz@39: self.distro = distro cmlenz@39: bdist_rpm.__init__(self, dist) cmlenz@39: cmlenz@39: def initialize_options(self): cmlenz@39: bdist_rpm.initialize_options(self) cmlenz@39: self.title = "Trac %s" % VERSION cmlenz@39: self.packager = "Edgewall Software " cmlenz@39: for x in rpm_distros[self.distro].keys(): cmlenz@39: setattr(self, x, rpm_distros[self.distro][x]) cmlenz@39: self.install_script = "scripts/rpm-install.sh" cmlenz@39: cmlenz@39: def run(self): cmlenz@39: bdist_rpm.run(self) cmlenz@39: if hasattr(self, 'version_suffix'): cmlenz@39: prefix = os.path.join(self.dist_dir, string.lower(PACKAGE)+'-'+VERSION+'-1') cmlenz@39: os.rename(prefix+'.noarch.rpm', prefix+self.version_suffix+'.noarch.rpm') cmlenz@39: os.rename(prefix+'.src.rpm', prefix+self.version_suffix+'.src.rpm') cmlenz@39: cmlenz@39: class proxy_bdist_rpm(bdist_rpm): cmlenz@39: cmlenz@39: def __init__(self, dist): cmlenz@39: bdist_rpm.__init__(self, dist) cmlenz@39: self.dist = dist cmlenz@39: cmlenz@39: def initialize_options(self): cmlenz@39: bdist_rpm.initialize_options(self) cmlenz@39: cmlenz@39: def run(self): cmlenz@39: for distro in rpm_distros.keys(): cmlenz@39: r = generic_bdist_rpm(self.dist, distro) cmlenz@39: r.initialize_options() cmlenz@39: self.dist._set_command_options(r, self.dist.command_options['bdist_rpm']) cmlenz@39: r.finalize_options() cmlenz@39: r.run() cmlenz@39: cmlenz@39: distutils.command.bdist_rpm.bdist_rpm = proxy_bdist_rpm cmlenz@39: cmlenz@39: setup(name="trac", cmlenz@39: description="Integrated scm, wiki, issue tracker and project environment", cmlenz@39: long_description=\ cmlenz@39: """ cmlenz@39: Trac is a minimalistic web-based software project management and bug/issue cmlenz@39: tracking system. It provides an interface to the Subversion revision control cmlenz@39: systems, an integrated wiki, flexible issue tracking and convenient report cmlenz@39: facilities. cmlenz@39: """, cmlenz@39: version=VERSION, cmlenz@39: author="Edgewall Software", cmlenz@39: author_email="info@edgewall.com", cmlenz@39: license=LICENSE, cmlenz@39: url=URL, cmlenz@39: packages=['trac', 'trac.db', 'trac.mimeview', 'trac.scripts', cmlenz@39: 'trac.ticket', 'trac.upgrades', 'trac.util', 'trac.web', cmlenz@39: 'trac.versioncontrol', 'trac.versioncontrol.web_ui', cmlenz@39: 'trac.wiki'], cmlenz@39: data_files=[(_p('share/trac/templates'), glob('templates/*')), cmlenz@39: (_p('share/trac/htdocs'), glob(_p('htdocs/*.*')) + [_p('htdocs/README')]), cmlenz@39: (_p('share/trac/htdocs/css'), glob(_p('htdocs/css/*'))), cmlenz@39: (_p('share/trac/htdocs/js'), glob(_p('htdocs/js/*'))), cmlenz@39: (_p('share/man/man1'), glob(_p('scripts/*.1'))), cmlenz@39: (_p('share/trac/wiki-default'), glob(_p('wiki-default/[A-Z]*'))), cmlenz@39: (_p('share/trac/wiki-macros'), glob(_p('wiki-macros/*.py')))], cmlenz@39: scripts=[_p('scripts/trac-admin'), cmlenz@39: _p('scripts/trac-postinstall.py'), cmlenz@39: _p('scripts/tracd'), cmlenz@39: _p('scripts/tracdb2env'), cmlenz@39: _p('cgi-bin/trac.cgi'), cmlenz@39: _p('cgi-bin/trac.fcgi')], cmlenz@39: cmdclass = {'install': my_install, cmlenz@39: 'install_scripts': my_install_scripts, cmlenz@39: 'install_data': my_install_data})