view setup.py @ 226:d8bb72f00eec

distutils install: fixed plugin import and log file path
author Goffi <goffi@goffi.org>
date Wed, 05 Jan 2011 02:39:35 +0100
parents fd9b7834d98a
children 533507bb4e32
line wrap: on
line source

#!/usr/bin/env python
# -*- coding: utf-8 -*-

from distutils.command.install import install
from distutils.core import setup
from distutils.file_util import copy_file
import os,sys,subprocess
from stat import ST_MODE
from glob import glob

NAME = 'sat'
LAUNCH_DAEMON_COMMAND = 'sat'


class custom_install(install):
    
    def custom_auto_options(self):
        """Change options for twistd in the shell script
        Mainly change the paths"""
        sh_buffer = ""
        run_dir = os.path.dirname(self.sh_script_path)
        with open(self.sh_script_path,'r') as sh_file:
            for ori_line in sh_file:
                if ori_line.startswith('DAEMON='):
                    dest_line = 'DAEMON=""\n' #we want to launch sat as a daemon
                elif ori_line.startswith('TAP_PATH='):
                    dest_line = 'TAP_PATH="%s/"\n' % run_dir
                else:
                    dest_line = ori_line
                sh_buffer += dest_line
        
        with open(self.sh_script_path,'w') as sh_file:
            sh_file.write(sh_buffer)

    
    def custom_create_links(self):
        """Create symbolic links to executables"""
        #the script which launch the daemon
        links = [(self.sh_script_path,LAUNCH_DAEMON_COMMAND),]
        for source,dest in links:
            dest_name, copied = copy_file(source, os.path.join(self.install_scripts, dest), link='sym')
            assert (copied)
            #we change the perm in the same way as in the original install_scripts
            mode = ((os.stat(dest_name)[ST_MODE]) | 0555) & 07777
            os.chmod(dest_name, mode)

    def run(self):
        install.run(self)
        print ('running post installation stuff')
        self.sh_script_path = os.path.join(self.install_lib,'sat','sat.sh')
        self.primitivus_path = os.path.join(self.install_lib,'sat_frontends','primitivus')
        self.custom_auto_options()
        self.custom_create_links()



setup(name=NAME,
      version='0.1.0',
      description=u'Salut à Toi multi-frontend XMPP client',
      long_description=u'Salut à Toi (SàT) is a XMPP client based on a daemon/frontend architecture. You can use it with the desktop frontend (wix - WxPython based), console ui frontend (Primitivus, Urwid based), or command line frontend (jp), and others are coming. ',
      author='Goffi (Jérôme Poisson)',
      author_email='goffi@goffi.org',
      url='http://wiki.goffi.org/wiki/Salut_%C3%A0_Toi',
      classifiers=['Development Status :: 3 - Alpha',
                   'Environment :: Console',
                   'Environment :: X11 Applications :: GTK',
                   'Framework :: Twisted',
                   'License :: OSI Approved :: GNU General Public License (GPL)',
                   'Operating System :: POSIX :: Linux',
                   'Topic :: Communications :: Chat'],
      package_dir = {'sat':'src', 'sat_frontends':'frontends/src'},
      packages=['sat','sat.tools','sat.bridge', 'sat.plugins',
                'sat_frontends', 'sat_frontends.bridge', 'sat_frontends.quick_frontend',
                'sat_frontends.primitivus'],
      package_data = {'sat': ['sat.tac','sat.sh']},
      data_files=[(os.path.join(sys.prefix,'share/locale/fr/LC_MESSAGES'), ['i18n/fr/LC_MESSAGES/sat.mo']),
                  (os.path.join(sys.prefix,'share/locale/fr/LC_MESSAGES'), ['frontends/i18n/fr/LC_MESSAGES/sat_frontend.mo']),
                  (os.path.join(sys.prefix,'share/locale/fr/LC_MESSAGES'), ['frontends/src/jp/i18n/fr/LC_MESSAGES/jp.mo']),
                  ('share/doc/%s' % NAME, ['CHANGELOG', 'COPYING', 'INSTALL', 'README', 'README4TRANSLATORS'])],
      scripts=['frontends/src/jp/jp', 'frontends/src/primitivus/primitivus'],
      cmdclass=dict(install=custom_install),
      )