comparison 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
comparison
equal deleted inserted replaced
231:f68a9a429c88 232:0cd5b3c4513f
11 from glob import glob 11 from glob import glob
12 12
13 NAME = 'sat' 13 NAME = 'sat'
14 LAUNCH_DAEMON_COMMAND = 'sat' 14 LAUNCH_DAEMON_COMMAND = 'sat'
15 15
16 class MercurialException(Exception):
17 pass
16 18
17 class custom_install(install): 19 class custom_install(install):
18 20
19 def custom_auto_options(self): 21 def custom_auto_options(self):
20 """Change options for twistd in the shell script 22 """Change options for twistd in the shell script
44 assert (copied) 46 assert (copied)
45 #we change the perm in the same way as in the original install_scripts 47 #we change the perm in the same way as in the original install_scripts
46 mode = ((os.stat(dest_name)[ST_MODE]) | 0555) & 07777 48 mode = ((os.stat(dest_name)[ST_MODE]) | 0555) & 07777
47 os.chmod(dest_name, mode) 49 os.chmod(dest_name, mode)
48 50
51 def _custom_wokkel_installed(self):
52 """Try to import muc from custom wokkel build
53 @return: True if successful"""
54 try:
55 __import__('wokkel.muc')
56 except:
57 return False
58 return True
59
60 def custom_wokkel_requirement(self):
61 """Test if the custom wokkel is present, else get and build it"""
62 if not self._custom_wokkel_installed():
63 print ('Custom wokkel is not present, building it')
64 import tempfile
65 ori_path = os.getcwd()
66 work_path = tempfile.mkdtemp()
67 os.chdir(work_path)
68 #we are now in a temp dir, we can get the repositories
69 commands = ['/usr/bin/hg clone http://hg.ik.nu/wokkel wokkel',
70 'cd wokkel',
71 '/usr/bin/hg pull -f http://hg.ik.nu/ralphm/wokkel-muc-client-support-24-2',
72 '/usr/bin/hg merge wokkel-muc-client-support-24',
73 '/usr/bin/hg commit -m "Merged wokkel\'s MUC branch"',
74 '%s setup.py install' % sys.executable]
75 for command in commands:
76 ret = subprocess.call(command, shell=True)
77 if ret!=0:
78 os.chdir(ori_path)
79 print ("ERROR while building/installing custom wokkel")
80 print ('Error happened when executing [%s]' % command)
81 raise MercurialException
82 os.chdir(ori_path)
83 print "Custom wokkel builded and installed, removing temporary files"
84 import shutil
85 shutil.rmtree(work_path)
86 print "done"
87 else:
88 print "Custom wokkel already installed"
89
90
49 def run(self): 91 def run(self):
50 install.run(self) 92 install.run(self)
51 print ('running post installation stuff') 93 print ('running post installation stuff')
52 self.sh_script_path = os.path.join(self.install_lib,'sat','sat.sh') 94 self.sh_script_path = os.path.join(self.install_lib,'sat','sat.sh')
53 self.primitivus_path = os.path.join(self.install_lib,'sat_frontends','primitivus') 95 self.primitivus_path = os.path.join(self.install_lib,'sat_frontends','primitivus')
54 self.custom_auto_options() 96 self.custom_auto_options()
55 self.custom_create_links() 97 self.custom_create_links()
98 self.custom_wokkel_requirement()
56 99
57 100
58 101
59 setup(name=NAME, 102 setup(name=NAME,
60 version='0.1.0', 103 version='0.1.0',
82 ('share/doc/%s' % NAME, ['CHANGELOG', 'COPYING', 'INSTALL', 'README', 'README4TRANSLATORS']), 125 ('share/doc/%s' % NAME, ['CHANGELOG', 'COPYING', 'INSTALL', 'README', 'README4TRANSLATORS']),
83 ('share/doc/%s/misc' % NAME, ['frontends/src/wix/images/split_card.sh']), 126 ('share/doc/%s/misc' % NAME, ['frontends/src/wix/images/split_card.sh']),
84 ], 127 ],
85 scripts=['frontends/src/jp/jp', 'frontends/src/primitivus/primitivus', 'frontends/src/wix/wix'], 128 scripts=['frontends/src/jp/jp', 'frontends/src/primitivus/primitivus', 'frontends/src/wix/wix'],
86 zip_safe=False, 129 zip_safe=False,
87 install_requires=['twisted', 'progressbar', 'wxPython', 'urwid', 'BeautifulSoup'], 130 install_requires=['twisted', 'progressbar', 'wxPython', 'urwid', 'BeautifulSoup','Mercurial'],
88 cmdclass=dict(install=custom_install), 131 cmdclass=dict(install=custom_install),
89 ) 132 ) #XXX: The Mercurial dependecy is just here to build the custom wokkel (with MUC branch), it must be removed
90 133 # and replace by wokkel as soon as MUC branch is officially available in wokkel main branch.