setup.py fixes and improvments

This commit is contained in:
Goffi 2014-02-28 14:39:45 +01:00
commit 6916fe91a0

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
# SAT: a jabber client
@ -30,6 +30,10 @@ from stat import ST_MODE
NAME = 'sat'
LAUNCH_DAEMON_COMMAND = 'sat'
ENV_SAT_INSTALL = "SAT_INSTALL" # environment variable to customise installation
NO_PREINSTALL_OPT = 'nopreinstall' # skip all preinstallation checks
AUTO_DEB_OPT = 'autodeb' # automaticaly install debs
NO_X_OPT = 'nox' # don't install X dependant packages
class MercurialException(Exception):
pass
@ -89,13 +93,15 @@ class CustomInstall(install):
self.custom_create_links()
def preinstall_check():
def preinstall_check(install_opt):
"""Check presence of problematic dependencies, and try to install them with package manager
This ugly stuff is necessary as distributions are not installed correctly with setuptools/distribute
Hope to remove this at some point"""
#modules_tocheck = ['twisted', 'twisted.words', 'twisted.web', 'wx', 'urwid']
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
modules_tocheck = ['gobject'] # XXX: python-gobject is not up-to-date in PyPi
if NO_X_OPT not in install_opt:
modules_tocheck.append('wx') # wx is the only one to be really difficult to install
package = {'twisted': 'python-twisted-core',
'twisted.words': 'python-twisted-words',
@ -115,8 +121,12 @@ def preinstall_check():
modules_toinstall.append('mercurial')""" # hg can be installed from pypi
if modules_toinstall:
# are we on a distribution using apt ?
apt_path = subprocess.Popen('which apt-get', stdout=subprocess.PIPE, shell=True).communicate()[0][:-1]
if AUTO_DEB_OPT in install_opt: # auto debian installation is requested
# are we on a distribution using apt ?
apt_path = subprocess.Popen('which apt-get', stdout=subprocess.PIPE, shell=True).communicate()[0][:-1]
else:
apt_path = None
not_installed = set()
if apt_path:
# we have apt, we'll try to use it
@ -136,12 +146,11 @@ def preinstall_check():
sys.stdout.write("- %s (Debian name: %s)\n" % (module_name, package[module_name]))
sys.exit(2)
if sys.argv[1].lower() in ['egg_info', 'install']:
# we only check dependencies if egg_info or install is used
install_opt = os.environ.get("SAT_INSTALL", "")
if not "nopreinstall" in install_opt: # user can force preinstall skipping
preinstall_check()
install_opt = os.environ.get(ENV_SAT_INSTALL, "").split()
if not NO_PREINSTALL_OPT in install_opt: # user can force preinstall skipping
preinstall_check(install_opt)
setup(name=NAME,
version='0.4.0',
@ -149,7 +158,7 @@ setup(name=NAME,
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).',
author='Goffi (Jérôme Poisson)',
author_email='goffi@goffi.org',
url='http://sat.goffi.org',
url='http://www.salut-a-toi.org',
classifiers=['Development Status :: 3 - Alpha',
'Environment :: Console',
'Environment :: X11 Applications :: GTK',
@ -169,6 +178,6 @@ setup(name=NAME,
scripts=['frontends/src/jp/jp', 'frontends/src/primitivus/primitivus', 'frontends/src/wix/wix'],
zip_safe=False,
dependency_links=['http://www.blarg.net/%7Esteveha/pyfeed-0.7.4.tar.gz', 'http://www.blarg.net/%7Esteveha/xe-0.7.4.tar.gz'],
install_requires=['twisted', 'wokkel >= 0.7.1', 'progressbar', 'urwid >= 1.1.0', 'urwid-satext', 'pyfeed', 'xe', 'mutagen', 'PIL', 'lxml'],
install_requires=['twisted', 'wokkel >= 0.7.1', 'progressbar', 'urwid >= 1.1.0', 'urwid-satext >= 0.3.0', 'pyfeed', 'xe', 'mutagen', 'PIL', 'lxml', 'markdown', 'html2text'],
cmdclass={'install': CustomInstall},
) # XXX: wxpython doesn't work, it's managed with preinstall_check