annotate setup.py @ 234:a7079e835432

added stop command in sat.sh launching script
author Goffi <goffi@goffi.org>
date Thu, 06 Jan 2011 19:17:09 +0100
parents 6a37bc1b0b8c
children 7a2ef5fe4e8d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
225
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
1 #!/usr/bin/env python
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
2 # -*- coding: utf-8 -*-
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
3
230
b25cbec73c1e distutils: removes build and dist from manifest's prune
Goffi <goffi@goffi.org>
parents: 227
diff changeset
4 from distribute_setup import use_setuptools
b25cbec73c1e distutils: removes build and dist from manifest's prune
Goffi <goffi@goffi.org>
parents: 227
diff changeset
5 use_setuptools()
b25cbec73c1e distutils: removes build and dist from manifest's prune
Goffi <goffi@goffi.org>
parents: 227
diff changeset
6 from setuptools.command.install import install
b25cbec73c1e distutils: removes build and dist from manifest's prune
Goffi <goffi@goffi.org>
parents: 227
diff changeset
7 from setuptools import setup
225
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
8 from distutils.file_util import copy_file
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
9 import os,sys,subprocess
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
10 from stat import ST_MODE
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
11 from glob import glob
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
12
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
13 NAME = 'sat'
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
14 LAUNCH_DAEMON_COMMAND = 'sat'
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
15
232
0cd5b3c4513f Distutils: added custom wokkel checking/building
Goffi <goffi@goffi.org>
parents: 230
diff changeset
16 class MercurialException(Exception):
0cd5b3c4513f Distutils: added custom wokkel checking/building
Goffi <goffi@goffi.org>
parents: 230
diff changeset
17 pass
225
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
18
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
19 class custom_install(install):
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
20
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
21 def custom_auto_options(self):
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
22 """Change options for twistd in the shell script
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
23 Mainly change the paths"""
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
24 sh_buffer = ""
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
25 run_dir = os.path.dirname(self.sh_script_path)
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
26 with open(self.sh_script_path,'r') as sh_file:
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
27 for ori_line in sh_file:
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
28 if ori_line.startswith('DAEMON='):
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
29 dest_line = 'DAEMON=""\n' #we want to launch sat as a daemon
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
30 elif ori_line.startswith('TAP_PATH='):
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
31 dest_line = 'TAP_PATH="%s/"\n' % run_dir
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
32 else:
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
33 dest_line = ori_line
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
34 sh_buffer += dest_line
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
35
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
36 with open(self.sh_script_path,'w') as sh_file:
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
37 sh_file.write(sh_buffer)
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
38
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
39
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
40 def custom_create_links(self):
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
41 """Create symbolic links to executables"""
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
42 #the script which launch the daemon
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
43 links = [(self.sh_script_path,LAUNCH_DAEMON_COMMAND),]
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
44 for source,dest in links:
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
45 dest_name, copied = copy_file(source, os.path.join(self.install_scripts, dest), link='sym')
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
46 assert (copied)
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
47 #we change the perm in the same way as in the original install_scripts
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
48 mode = ((os.stat(dest_name)[ST_MODE]) | 0555) & 07777
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
49 os.chmod(dest_name, mode)
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
50
232
0cd5b3c4513f Distutils: added custom wokkel checking/building
Goffi <goffi@goffi.org>
parents: 230
diff changeset
51 def _custom_wokkel_installed(self):
0cd5b3c4513f Distutils: added custom wokkel checking/building
Goffi <goffi@goffi.org>
parents: 230
diff changeset
52 """Try to import muc from custom wokkel build
0cd5b3c4513f Distutils: added custom wokkel checking/building
Goffi <goffi@goffi.org>
parents: 230
diff changeset
53 @return: True if successful"""
0cd5b3c4513f Distutils: added custom wokkel checking/building
Goffi <goffi@goffi.org>
parents: 230
diff changeset
54 try:
0cd5b3c4513f Distutils: added custom wokkel checking/building
Goffi <goffi@goffi.org>
parents: 230
diff changeset
55 __import__('wokkel.muc')
0cd5b3c4513f Distutils: added custom wokkel checking/building
Goffi <goffi@goffi.org>
parents: 230
diff changeset
56 except:
0cd5b3c4513f Distutils: added custom wokkel checking/building
Goffi <goffi@goffi.org>
parents: 230
diff changeset
57 return False
0cd5b3c4513f Distutils: added custom wokkel checking/building
Goffi <goffi@goffi.org>
parents: 230
diff changeset
58 return True
0cd5b3c4513f Distutils: added custom wokkel checking/building
Goffi <goffi@goffi.org>
parents: 230
diff changeset
59
0cd5b3c4513f Distutils: added custom wokkel checking/building
Goffi <goffi@goffi.org>
parents: 230
diff changeset
60 def custom_wokkel_requirement(self):
0cd5b3c4513f Distutils: added custom wokkel checking/building
Goffi <goffi@goffi.org>
parents: 230
diff changeset
61 """Test if the custom wokkel is present, else get and build it"""
0cd5b3c4513f Distutils: added custom wokkel checking/building
Goffi <goffi@goffi.org>
parents: 230
diff changeset
62 if not self._custom_wokkel_installed():
0cd5b3c4513f Distutils: added custom wokkel checking/building
Goffi <goffi@goffi.org>
parents: 230
diff changeset
63 print ('Custom wokkel is not present, building it')
0cd5b3c4513f Distutils: added custom wokkel checking/building
Goffi <goffi@goffi.org>
parents: 230
diff changeset
64 import tempfile
0cd5b3c4513f Distutils: added custom wokkel checking/building
Goffi <goffi@goffi.org>
parents: 230
diff changeset
65 ori_path = os.getcwd()
0cd5b3c4513f Distutils: added custom wokkel checking/building
Goffi <goffi@goffi.org>
parents: 230
diff changeset
66 work_path = tempfile.mkdtemp()
0cd5b3c4513f Distutils: added custom wokkel checking/building
Goffi <goffi@goffi.org>
parents: 230
diff changeset
67 os.chdir(work_path)
0cd5b3c4513f Distutils: added custom wokkel checking/building
Goffi <goffi@goffi.org>
parents: 230
diff changeset
68 #we are now in a temp dir, we can get the repositories
0cd5b3c4513f Distutils: added custom wokkel checking/building
Goffi <goffi@goffi.org>
parents: 230
diff changeset
69 commands = ['/usr/bin/hg clone http://hg.ik.nu/wokkel wokkel',
0cd5b3c4513f Distutils: added custom wokkel checking/building
Goffi <goffi@goffi.org>
parents: 230
diff changeset
70 'cd wokkel',
0cd5b3c4513f Distutils: added custom wokkel checking/building
Goffi <goffi@goffi.org>
parents: 230
diff changeset
71 '/usr/bin/hg pull -f http://hg.ik.nu/ralphm/wokkel-muc-client-support-24-2',
0cd5b3c4513f Distutils: added custom wokkel checking/building
Goffi <goffi@goffi.org>
parents: 230
diff changeset
72 '/usr/bin/hg merge wokkel-muc-client-support-24',
0cd5b3c4513f Distutils: added custom wokkel checking/building
Goffi <goffi@goffi.org>
parents: 230
diff changeset
73 '/usr/bin/hg commit -m "Merged wokkel\'s MUC branch"',
0cd5b3c4513f Distutils: added custom wokkel checking/building
Goffi <goffi@goffi.org>
parents: 230
diff changeset
74 '%s setup.py install' % sys.executable]
0cd5b3c4513f Distutils: added custom wokkel checking/building
Goffi <goffi@goffi.org>
parents: 230
diff changeset
75 for command in commands:
233
6a37bc1b0b8c distutils: fixed custom wokkel building
Goffi <goffi@goffi.org>
parents: 232
diff changeset
76 if command.startswith('cd '):
6a37bc1b0b8c distutils: fixed custom wokkel building
Goffi <goffi@goffi.org>
parents: 232
diff changeset
77 os.chdir(command[3:])
6a37bc1b0b8c distutils: fixed custom wokkel building
Goffi <goffi@goffi.org>
parents: 232
diff changeset
78 else:
6a37bc1b0b8c distutils: fixed custom wokkel building
Goffi <goffi@goffi.org>
parents: 232
diff changeset
79 ret = subprocess.call(command, stdout=open('/dev/null', 'w'), shell=True)
6a37bc1b0b8c distutils: fixed custom wokkel building
Goffi <goffi@goffi.org>
parents: 232
diff changeset
80 if ret!=0:
6a37bc1b0b8c distutils: fixed custom wokkel building
Goffi <goffi@goffi.org>
parents: 232
diff changeset
81 os.chdir(ori_path)
6a37bc1b0b8c distutils: fixed custom wokkel building
Goffi <goffi@goffi.org>
parents: 232
diff changeset
82 print ("ERROR while building/installing custom wokkel")
6a37bc1b0b8c distutils: fixed custom wokkel building
Goffi <goffi@goffi.org>
parents: 232
diff changeset
83 print ('Error happened when executing [%s]' % command)
6a37bc1b0b8c distutils: fixed custom wokkel building
Goffi <goffi@goffi.org>
parents: 232
diff changeset
84 print ('tmpdir is [%s]' % work_path)
6a37bc1b0b8c distutils: fixed custom wokkel building
Goffi <goffi@goffi.org>
parents: 232
diff changeset
85 raise MercurialException
232
0cd5b3c4513f Distutils: added custom wokkel checking/building
Goffi <goffi@goffi.org>
parents: 230
diff changeset
86 os.chdir(ori_path)
0cd5b3c4513f Distutils: added custom wokkel checking/building
Goffi <goffi@goffi.org>
parents: 230
diff changeset
87 print "Custom wokkel builded and installed, removing temporary files"
0cd5b3c4513f Distutils: added custom wokkel checking/building
Goffi <goffi@goffi.org>
parents: 230
diff changeset
88 import shutil
0cd5b3c4513f Distutils: added custom wokkel checking/building
Goffi <goffi@goffi.org>
parents: 230
diff changeset
89 shutil.rmtree(work_path)
0cd5b3c4513f Distutils: added custom wokkel checking/building
Goffi <goffi@goffi.org>
parents: 230
diff changeset
90 print "done"
0cd5b3c4513f Distutils: added custom wokkel checking/building
Goffi <goffi@goffi.org>
parents: 230
diff changeset
91 else:
0cd5b3c4513f Distutils: added custom wokkel checking/building
Goffi <goffi@goffi.org>
parents: 230
diff changeset
92 print "Custom wokkel already installed"
0cd5b3c4513f Distutils: added custom wokkel checking/building
Goffi <goffi@goffi.org>
parents: 230
diff changeset
93
0cd5b3c4513f Distutils: added custom wokkel checking/building
Goffi <goffi@goffi.org>
parents: 230
diff changeset
94
225
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
95 def run(self):
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
96 install.run(self)
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
97 print ('running post installation stuff')
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
98 self.sh_script_path = os.path.join(self.install_lib,'sat','sat.sh')
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
99 self.primitivus_path = os.path.join(self.install_lib,'sat_frontends','primitivus')
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
100 self.custom_auto_options()
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
101 self.custom_create_links()
232
0cd5b3c4513f Distutils: added custom wokkel checking/building
Goffi <goffi@goffi.org>
parents: 230
diff changeset
102 self.custom_wokkel_requirement()
225
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
103
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
104
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
105
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
106 setup(name=NAME,
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
107 version='0.1.0',
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
108 description=u'Salut à Toi multi-frontend XMPP client',
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
109 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. ',
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
110 author='Goffi (Jérôme Poisson)',
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
111 author_email='goffi@goffi.org',
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
112 url='http://wiki.goffi.org/wiki/Salut_%C3%A0_Toi',
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
113 classifiers=['Development Status :: 3 - Alpha',
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
114 'Environment :: Console',
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
115 'Environment :: X11 Applications :: GTK',
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
116 'Framework :: Twisted',
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
117 'License :: OSI Approved :: GNU General Public License (GPL)',
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
118 'Operating System :: POSIX :: Linux',
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
119 'Topic :: Communications :: Chat'],
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
120 package_dir = {'sat':'src', 'sat_frontends':'frontends/src'},
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
121 packages=['sat','sat.tools','sat.bridge', 'sat.plugins',
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
122 'sat_frontends', 'sat_frontends.bridge', 'sat_frontends.quick_frontend',
227
533507bb4e32 distutils wix installation
Goffi <goffi@goffi.org>
parents: 225
diff changeset
123 'sat_frontends.primitivus', 'sat_frontends.wix'],
533507bb4e32 distutils wix installation
Goffi <goffi@goffi.org>
parents: 225
diff changeset
124 package_data = {'sat': ['sat.tac','sat.sh'],
533507bb4e32 distutils wix installation
Goffi <goffi@goffi.org>
parents: 225
diff changeset
125 'sat_frontends': ['wix/COPYING','wix/images/*png','wix/images/cards/*','wix/images/crystal/*']},
225
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
126 data_files=[(os.path.join(sys.prefix,'share/locale/fr/LC_MESSAGES'), ['i18n/fr/LC_MESSAGES/sat.mo']),
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
127 (os.path.join(sys.prefix,'share/locale/fr/LC_MESSAGES'), ['frontends/i18n/fr/LC_MESSAGES/sat_frontend.mo']),
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
128 (os.path.join(sys.prefix,'share/locale/fr/LC_MESSAGES'), ['frontends/src/jp/i18n/fr/LC_MESSAGES/jp.mo']),
227
533507bb4e32 distutils wix installation
Goffi <goffi@goffi.org>
parents: 225
diff changeset
129 ('share/doc/%s' % NAME, ['CHANGELOG', 'COPYING', 'INSTALL', 'README', 'README4TRANSLATORS']),
533507bb4e32 distutils wix installation
Goffi <goffi@goffi.org>
parents: 225
diff changeset
130 ('share/doc/%s/misc' % NAME, ['frontends/src/wix/images/split_card.sh']),
533507bb4e32 distutils wix installation
Goffi <goffi@goffi.org>
parents: 225
diff changeset
131 ],
533507bb4e32 distutils wix installation
Goffi <goffi@goffi.org>
parents: 225
diff changeset
132 scripts=['frontends/src/jp/jp', 'frontends/src/primitivus/primitivus', 'frontends/src/wix/wix'],
230
b25cbec73c1e distutils: removes build and dist from manifest's prune
Goffi <goffi@goffi.org>
parents: 227
diff changeset
133 zip_safe=False,
232
0cd5b3c4513f Distutils: added custom wokkel checking/building
Goffi <goffi@goffi.org>
parents: 230
diff changeset
134 install_requires=['twisted', 'progressbar', 'wxPython', 'urwid', 'BeautifulSoup','Mercurial'],
225
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
135 cmdclass=dict(install=custom_install),
232
0cd5b3c4513f Distutils: added custom wokkel checking/building
Goffi <goffi@goffi.org>
parents: 230
diff changeset
136 ) #XXX: The Mercurial dependecy is just here to build the custom wokkel (with MUC branch), it must be removed
0cd5b3c4513f Distutils: added custom wokkel checking/building
Goffi <goffi@goffi.org>
parents: 230
diff changeset
137 # and replace by wokkel as soon as MUC branch is officially available in wokkel main branch.