Mercurial > libervia-backend
view setup.py @ 232:0cd5b3c4513f
Distutils: added custom wokkel checking/building
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 06 Jan 2011 18:48:56 +0100 |
parents | b25cbec73c1e |
children | 6a37bc1b0b8c |
line wrap: on
line source
#!/usr/bin/env python # -*- coding: utf-8 -*- from distribute_setup import use_setuptools use_setuptools() from setuptools.command.install import install from setuptools 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 MercurialException(Exception): pass 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 _custom_wokkel_installed(self): """Try to import muc from custom wokkel build @return: True if successful""" try: __import__('wokkel.muc') except: return False return True def custom_wokkel_requirement(self): """Test if the custom wokkel is present, else get and build it""" if not self._custom_wokkel_installed(): print ('Custom wokkel is not present, building it') import tempfile ori_path = os.getcwd() work_path = tempfile.mkdtemp() os.chdir(work_path) #we are now in a temp dir, we can get the repositories commands = ['/usr/bin/hg clone http://hg.ik.nu/wokkel wokkel', 'cd wokkel', '/usr/bin/hg pull -f http://hg.ik.nu/ralphm/wokkel-muc-client-support-24-2', '/usr/bin/hg merge wokkel-muc-client-support-24', '/usr/bin/hg commit -m "Merged wokkel\'s MUC branch"', '%s setup.py install' % sys.executable] for command in commands: ret = subprocess.call(command, shell=True) if ret!=0: os.chdir(ori_path) print ("ERROR while building/installing custom wokkel") print ('Error happened when executing [%s]' % command) raise MercurialException os.chdir(ori_path) print "Custom wokkel builded and installed, removing temporary files" import shutil shutil.rmtree(work_path) print "done" else: print "Custom wokkel already installed" 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() self.custom_wokkel_requirement() 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', 'sat_frontends.wix'], package_data = {'sat': ['sat.tac','sat.sh'], 'sat_frontends': ['wix/COPYING','wix/images/*png','wix/images/cards/*','wix/images/crystal/*']}, 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']), ('share/doc/%s/misc' % NAME, ['frontends/src/wix/images/split_card.sh']), ], scripts=['frontends/src/jp/jp', 'frontends/src/primitivus/primitivus', 'frontends/src/wix/wix'], zip_safe=False, install_requires=['twisted', 'progressbar', 'wxPython', 'urwid', 'BeautifulSoup','Mercurial'], cmdclass=dict(install=custom_install), ) #XXX: The Mercurial dependecy is just here to build the custom wokkel (with MUC branch), it must be removed # and replace by wokkel as soon as MUC branch is officially available in wokkel main branch.