annotate setup.py @ 225:fd9b7834d98a

distutils installation script, draft
author Goffi <goffi@goffi.org>
date Wed, 05 Jan 2011 01:56:36 +0100
parents
children 533507bb4e32
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
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
4 from distutils.command.install import install
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
5 from distutils.core import setup
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
6 from distutils.file_util import copy_file
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
7 import os,sys,subprocess
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
8 from stat import ST_MODE
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
9 from glob import glob
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
10
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
11 NAME = 'sat'
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
12 LAUNCH_DAEMON_COMMAND = 'sat'
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
13
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
14
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
15 class custom_install(install):
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
16
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
17 def custom_auto_options(self):
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
18 """Change options for twistd in the shell script
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
19 Mainly change the paths"""
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
20 sh_buffer = ""
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
21 run_dir = os.path.dirname(self.sh_script_path)
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
22 with open(self.sh_script_path,'r') as sh_file:
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
23 for ori_line in sh_file:
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
24 if ori_line.startswith('DAEMON='):
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
25 dest_line = 'DAEMON=""\n' #we want to launch sat as a daemon
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
26 elif ori_line.startswith('TAP_PATH='):
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
27 dest_line = 'TAP_PATH="%s/"\n' % run_dir
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
28 else:
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
29 dest_line = ori_line
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
30 sh_buffer += dest_line
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
31
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
32 with open(self.sh_script_path,'w') as sh_file:
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
33 sh_file.write(sh_buffer)
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
34
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 def custom_create_links(self):
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
37 """Create symbolic links to executables"""
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
38 #the script which launch the daemon
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
39 links = [(self.sh_script_path,LAUNCH_DAEMON_COMMAND),]
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
40 for source,dest in links:
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
41 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
42 assert (copied)
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
43 #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
44 mode = ((os.stat(dest_name)[ST_MODE]) | 0555) & 07777
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
45 os.chmod(dest_name, mode)
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
46
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
47 def run(self):
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
48 install.run(self)
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
49 print ('running post installation stuff')
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
50 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
51 self.primitivus_path = os.path.join(self.install_lib,'sat_frontends','primitivus')
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
52 self.custom_auto_options()
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
53 self.custom_create_links()
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
54
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
55
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
56
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
57 setup(name=NAME,
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
58 version='0.1.0',
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
59 description=u'Salut à Toi multi-frontend XMPP client',
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
60 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
61 author='Goffi (Jérôme Poisson)',
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
62 author_email='goffi@goffi.org',
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
63 url='http://wiki.goffi.org/wiki/Salut_%C3%A0_Toi',
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
64 classifiers=['Development Status :: 3 - Alpha',
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
65 'Environment :: Console',
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
66 'Environment :: X11 Applications :: GTK',
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
67 'Framework :: Twisted',
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
68 'License :: OSI Approved :: GNU General Public License (GPL)',
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
69 'Operating System :: POSIX :: Linux',
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
70 'Topic :: Communications :: Chat'],
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
71 package_dir = {'sat':'src', 'sat_frontends':'frontends/src'},
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
72 packages=['sat','sat.tools','sat.bridge', 'sat.plugins',
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
73 'sat_frontends', 'sat_frontends.bridge', 'sat_frontends.quick_frontend',
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
74 'sat_frontends.primitivus'],
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
75 package_data = {'sat': ['sat.tac','sat.sh']},
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
76 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
77 (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
78 (os.path.join(sys.prefix,'share/locale/fr/LC_MESSAGES'), ['frontends/src/jp/i18n/fr/LC_MESSAGES/jp.mo']),
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
79 ('share/doc/%s' % NAME, ['CHANGELOG', 'COPYING', 'INSTALL', 'README', 'README4TRANSLATORS'])],
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
80 scripts=['frontends/src/jp/jp', 'frontends/src/primitivus/primitivus'],
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
81 cmdclass=dict(install=custom_install),
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
82 )
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
83