comparison setup.py @ 884:4054cf716322

setup.py fixes and improvments
author Goffi <goffi@goffi.org>
date Fri, 28 Feb 2014 14:39:45 +0100
parents 12cfa23c6ab9
children f93e917be3f4
comparison
equal deleted inserted replaced
883:3a943b5f2cec 884:4054cf716322
1 #!/usr/bin/env python 1 #!/usr/bin/env python2
2 # -*- coding: utf-8 -*- 2 # -*- coding: utf-8 -*-
3 3
4 # SAT: a jabber client 4 # SAT: a jabber client
5 # Copyright (C) 2009, 2010, 2011 Jérôme Poisson (goffi@goffi.org) 5 # Copyright (C) 2009, 2010, 2011 Jérôme Poisson (goffi@goffi.org)
6 6
28 from stat import ST_MODE 28 from stat import ST_MODE
29 29
30 NAME = 'sat' 30 NAME = 'sat'
31 LAUNCH_DAEMON_COMMAND = 'sat' 31 LAUNCH_DAEMON_COMMAND = 'sat'
32 32
33 ENV_SAT_INSTALL = "SAT_INSTALL" # environment variable to customise installation
34 NO_PREINSTALL_OPT = 'nopreinstall' # skip all preinstallation checks
35 AUTO_DEB_OPT = 'autodeb' # automaticaly install debs
36 NO_X_OPT = 'nox' # don't install X dependant packages
33 37
34 class MercurialException(Exception): 38 class MercurialException(Exception):
35 pass 39 pass
36 40
37 41
87 self.primitivus_path = os.path.join(self.install_lib, 'sat_frontends', 'primitivus') 91 self.primitivus_path = os.path.join(self.install_lib, 'sat_frontends', 'primitivus')
88 self.custom_auto_options() 92 self.custom_auto_options()
89 self.custom_create_links() 93 self.custom_create_links()
90 94
91 95
92 def preinstall_check(): 96 def preinstall_check(install_opt):
93 """Check presence of problematic dependencies, and try to install them with package manager 97 """Check presence of problematic dependencies, and try to install them with package manager
94 This ugly stuff is necessary as distributions are not installed correctly with setuptools/distribute 98 This ugly stuff is necessary as distributions are not installed correctly with setuptools/distribute
95 Hope to remove this at some point""" 99 Hope to remove this at some point"""
96 100
97 #modules_tocheck = ['twisted', 'twisted.words', 'twisted.web', 'wx', 'urwid'] 101 #modules_tocheck = ['twisted', 'twisted.words', 'twisted.web', 'wx', 'urwid']
98 modules_tocheck = ['wx', 'gobject'] # XXX: wx is the only one to be really difficult to install, python-gobject is not up-to-date in PyPi 102 modules_tocheck = ['gobject'] # XXX: python-gobject is not up-to-date in PyPi
103 if NO_X_OPT not in install_opt:
104 modules_tocheck.append('wx') # wx is the only one to be really difficult to install
99 105
100 package = {'twisted': 'python-twisted-core', 106 package = {'twisted': 'python-twisted-core',
101 'twisted.words': 'python-twisted-words', 107 'twisted.words': 'python-twisted-words',
102 'twisted.web': 'python-twisted-web', 108 'twisted.web': 'python-twisted-web',
103 'wx': 'python-wxgtk2.8', 109 'wx': 'python-wxgtk2.8',
113 hg_installed = subprocess.call('which hg', stdout=open('/dev/null', 'w'), shell=True) == 0 119 hg_installed = subprocess.call('which hg', stdout=open('/dev/null', 'w'), shell=True) == 0
114 if not hg_installed: 120 if not hg_installed:
115 modules_toinstall.append('mercurial')""" # hg can be installed from pypi 121 modules_toinstall.append('mercurial')""" # hg can be installed from pypi
116 122
117 if modules_toinstall: 123 if modules_toinstall:
118 # are we on a distribution using apt ? 124 if AUTO_DEB_OPT in install_opt: # auto debian installation is requested
119 apt_path = subprocess.Popen('which apt-get', stdout=subprocess.PIPE, shell=True).communicate()[0][:-1] 125 # are we on a distribution using apt ?
126 apt_path = subprocess.Popen('which apt-get', stdout=subprocess.PIPE, shell=True).communicate()[0][:-1]
127 else:
128 apt_path = None
129
120 not_installed = set() 130 not_installed = set()
121 if apt_path: 131 if apt_path:
122 # we have apt, we'll try to use it 132 # we have apt, we'll try to use it
123 for module_name in modules_toinstall: 133 for module_name in modules_toinstall:
124 package_name = package[module_name] 134 package_name = package[module_name]
134 sys.stdout.write("You should install the following dependencies with your distribution recommanded tool before installing %s:\n" % NAME) 144 sys.stdout.write("You should install the following dependencies with your distribution recommanded tool before installing %s:\n" % NAME)
135 for module_name in not_installed: 145 for module_name in not_installed:
136 sys.stdout.write("- %s (Debian name: %s)\n" % (module_name, package[module_name])) 146 sys.stdout.write("- %s (Debian name: %s)\n" % (module_name, package[module_name]))
137 sys.exit(2) 147 sys.exit(2)
138 148
139
140 if sys.argv[1].lower() in ['egg_info', 'install']: 149 if sys.argv[1].lower() in ['egg_info', 'install']:
141 # we only check dependencies if egg_info or install is used 150 # we only check dependencies if egg_info or install is used
142 install_opt = os.environ.get("SAT_INSTALL", "") 151 install_opt = os.environ.get(ENV_SAT_INSTALL, "").split()
143 if not "nopreinstall" in install_opt: # user can force preinstall skipping 152 if not NO_PREINSTALL_OPT in install_opt: # user can force preinstall skipping
144 preinstall_check() 153 preinstall_check(install_opt)
145 154
146 setup(name=NAME, 155 setup(name=NAME,
147 version='0.4.0', 156 version='0.4.0',
148 description=u'Salut à Toi multi-frontend XMPP client', 157 description=u'Salut à Toi multi-frontend XMPP client',
149 long_description=u'Salut à Toi (SàT) is a XMPP client based on a daemon/frontend architecture. Its multi-frontends (desktop, web, console interface, CLI, etc) and multi-purposes (instant messaging, microblogging, games, file sharing, etc).', 158 long_description=u'Salut à Toi (SàT) is a XMPP client based on a daemon/frontend architecture. Its multi-frontends (desktop, web, console interface, CLI, etc) and multi-purposes (instant messaging, microblogging, games, file sharing, etc).',
150 author='Goffi (Jérôme Poisson)', 159 author='Goffi (Jérôme Poisson)',
151 author_email='goffi@goffi.org', 160 author_email='goffi@goffi.org',
152 url='http://sat.goffi.org', 161 url='http://www.salut-a-toi.org',
153 classifiers=['Development Status :: 3 - Alpha', 162 classifiers=['Development Status :: 3 - Alpha',
154 'Environment :: Console', 163 'Environment :: Console',
155 'Environment :: X11 Applications :: GTK', 164 'Environment :: X11 Applications :: GTK',
156 'Framework :: Twisted', 165 'Framework :: Twisted',
157 'License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)', 166 'License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)',
167 ('share/doc/%s' % NAME, ['CHANGELOG', 'COPYING', 'INSTALL', 'README', 'README4TRANSLATORS']), 176 ('share/doc/%s' % NAME, ['CHANGELOG', 'COPYING', 'INSTALL', 'README', 'README4TRANSLATORS']),
168 ], 177 ],
169 scripts=['frontends/src/jp/jp', 'frontends/src/primitivus/primitivus', 'frontends/src/wix/wix'], 178 scripts=['frontends/src/jp/jp', 'frontends/src/primitivus/primitivus', 'frontends/src/wix/wix'],
170 zip_safe=False, 179 zip_safe=False,
171 dependency_links=['http://www.blarg.net/%7Esteveha/pyfeed-0.7.4.tar.gz', 'http://www.blarg.net/%7Esteveha/xe-0.7.4.tar.gz'], 180 dependency_links=['http://www.blarg.net/%7Esteveha/pyfeed-0.7.4.tar.gz', 'http://www.blarg.net/%7Esteveha/xe-0.7.4.tar.gz'],
172 install_requires=['twisted', 'wokkel >= 0.7.1', 'progressbar', 'urwid >= 1.1.0', 'urwid-satext', 'pyfeed', 'xe', 'mutagen', 'PIL', 'lxml'], 181 install_requires=['twisted', 'wokkel >= 0.7.1', 'progressbar', 'urwid >= 1.1.0', 'urwid-satext >= 0.3.0', 'pyfeed', 'xe', 'mutagen', 'PIL', 'lxml', 'markdown', 'html2text'],
173 cmdclass={'install': CustomInstall}, 182 cmdclass={'install': CustomInstall},
174 ) # XXX: wxpython doesn't work, it's managed with preinstall_check 183 ) # XXX: wxpython doesn't work, it's managed with preinstall_check