Mercurial > libervia-backend
diff 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 diff
--- a/setup.py Thu Jan 06 18:09:35 2011 +0100 +++ b/setup.py Thu Jan 06 18:48:56 2011 +0100 @@ -13,6 +13,8 @@ NAME = 'sat' LAUNCH_DAEMON_COMMAND = 'sat' +class MercurialException(Exception): + pass class custom_install(install): @@ -46,6 +48,46 @@ 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') @@ -53,6 +95,7 @@ self.primitivus_path = os.path.join(self.install_lib,'sat_frontends','primitivus') self.custom_auto_options() self.custom_create_links() + self.custom_wokkel_requirement() @@ -84,7 +127,7 @@ ], scripts=['frontends/src/jp/jp', 'frontends/src/primitivus/primitivus', 'frontends/src/wix/wix'], zip_safe=False, - install_requires=['twisted', 'progressbar', 'wxPython', 'urwid', 'BeautifulSoup'], + 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.