Distutils: added custom wokkel checking/building

This commit is contained in:
Goffi 2011-01-06 18:48:56 +01:00
commit fff2c34237

View file

@ -13,6 +13,8 @@ from glob import glob
NAME = 'sat'
LAUNCH_DAEMON_COMMAND = 'sat'
class MercurialException(Exception):
pass
class custom_install(install):
@ -46,6 +48,46 @@ class custom_install(install):
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 @@ class custom_install(install):
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 @@ setup(name=NAME,
],
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.