From 64119bc03ff13cefdf8576c610c5a92fc553031c Mon Sep 17 00:00:00 2001 From: Laurent Bachelier Date: Mon, 25 Mar 2013 02:48:52 +0100 Subject: [PATCH] Add local_install / local_run tools --- INSTALL | 65 ++++++++++++++++++++++++------------------ tools/local_install.py | 36 +++++++++++++++++++++++ tools/local_install.sh | 10 +++++++ tools/local_run.py | 44 ++++++++++++++++++++++++++++ tools/local_run.sh | 10 +++++++ 5 files changed, 137 insertions(+), 28 deletions(-) create mode 100644 tools/local_install.py create mode 100755 tools/local_install.sh create mode 100644 tools/local_run.py create mode 100755 tools/local_run.sh diff --git a/INSTALL b/INSTALL index eec8cdeb08..f3c10d2384 100644 --- a/INSTALL +++ b/INSTALL @@ -1,47 +1,56 @@ Weboob installation =================== -Like any Python package using setuptools, Weboob can be installed in install -mode or in development mode. +Using the packages provided by your distribution is recommended. +See http://weboob.org/install for a list of available packages. +Since there are many dependencies, when you install from sources, +you have to handle them by hand, according to your distribution. -Install mode ------------- +The requirements are provided in ``setup.py``, except for: -The install mode copies files to the Python system-wide packages directory -(for example /usr/lib/python2.5/site-packages for Python 2.5, -or /usr/local/lib/python2.6/dist-packages for Python 2.6) +* gpgv (for secure updates). If not packaged alone, it should be in ``gnupg`` or ``gpg``. +* PyQt4 (python-qt4) for graphical applications. +* For more performance, ensure you have ``libyaml`` and ``simplejson`` installed. -# python setup.py install +Some modules may have more dependencies. -Scripts are copied to /usr/bin. +All installation procedures allow you to chose wether you want graphical applications. +Add ``--no-qt --no-xdg`` to disable them; ``--qt --xdg`` to enable them. -Since there are many dependencies, when you install from sources, -you have to handle them by hand, according to your distribution. -If you still want to download them, you can uncomment the dependencies -in setup.py +After a package or system installation, +you should run ``weboob-config update`` as your login user. -To uninstall, remove the egg-info from the Python system-wide packages directory -and remove the weboob_dev line in easy-install.pth. +User installation +----------------- +There is a way to install weboob locally without messing with your system. +Run ./tools/local_install.sh as your local user. :: -Development mode ----------------- + $ ./tools/local_install.sh ~/bin -The development mode doesn't copy files, but creates an egg-link -in the Python system-wide packages directory which points to the development -directory. It is useful for development when files often change. +The scripts are copied to ``~/bin``. -# python setup.py develop +System insallation (discouraged) +-------------------------------- -Scripts are copied to /usr/bin too. +The install mode copies files to the Python system-wide packages directory +(for example /usr/lib/python2.5/site-packages for Python 2.5, +or /usr/local/lib/python2.6/dist-packages for Python 2.6). :: + + # ./setup.py install + +Scripts are copied to ``/usr/bin``. + +Development mode +---------------- -To uninstall, remove the egg-link from the Python system-wide packages directory -and remove the weboob_dev line in easy-install.pth. +This does not actually install anything, but lets you run Weboob from the source code, +while also using the modules from that source. This is only recommended if using +the git source and not a release. :: -It is possible to install in a specific directory, and it does not need root privileges. For instance: + $ ./tools/local_run.sh APPLICATION COMMANDS -$ mkdir ~/mydir -$ PYTHONPATH=~/mydir python setup.py develop --install-dir ~/mydir +For example, instead of running ``videoob -b youtube search plop``, you would run:: -That way, the only altered directory is the one you chose earlier. + $ ./tools/local_run.sh videoob -b youtube search plop diff --git a/tools/local_install.py b/tools/local_install.py new file mode 100644 index 0000000000..b67b516a6c --- /dev/null +++ b/tools/local_install.py @@ -0,0 +1,36 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +import subprocess +import sys +import os + +print "Weboob local installer" +print +if len(sys.argv) < 2: + print "This tool will install Weboob to be usuable without requiring" + print "messing with your system, which should only be touched by a package manager." + print + print "Usage: %s DESTINATION" % sys.argv[0] + print + print >>sys.stderr, "Error: Please provide a destination, " \ + "for example ‘%s/bin’" % os.getenv('HOME') + sys.exit(1) +else: + dest = os.path.expanduser(sys.argv[1]) + +print "Installing weboob applications into ‘%s’." % dest +subprocess.check_call( + [sys.executable, 'setup.py', + 'install', '--user', '--install-scripts', dest] + sys.argv[2:], + cwd=os.path.join(os.path.dirname(__file__), os.pardir)) + +subprocess.check_call([sys.executable, os.path.join(dest, 'weboob-config'), 'update']) + +print +print "Installation done. Applications are available in ‘%s’." % dest +print "You can remove the source files." +print +print "To have easy access to the Weboob applications," +print "you should add the following line to your ~/.bashrc or ~/.zshrc file:" +print "export PATH=\"$PATH:%s\"" % dest +print "And then restart your shells." diff --git a/tools/local_install.sh b/tools/local_install.sh new file mode 100755 index 0000000000..aaf67b50fa --- /dev/null +++ b/tools/local_install.sh @@ -0,0 +1,10 @@ +#!/bin/sh +set -e + +if [ -z "${PYTHON}" ]; then + which python >/dev/null 2>&1 && PYTHON=$(which python) + which python2 >/dev/null 2>&1 && PYTHON=$(which python2) + which python2.7 >/dev/null 2>&1 && PYTHON=$(which python2.7) +fi + +exec "${PYTHON}" "$(dirname $0)/local_install.py" "$@" diff --git a/tools/local_run.py b/tools/local_run.py new file mode 100644 index 0000000000..dc323353a4 --- /dev/null +++ b/tools/local_run.py @@ -0,0 +1,44 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +import subprocess +import sys +import os +import shutil + +if len(sys.argv) < 2: + print "Usage: %s SCRIPTNAME [args]" % sys.argv[0] + sys.exit(1) +else: + script = sys.argv[1] + args = sys.argv[2:] + +project = os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir)) +wd = os.path.join(project, 'localconfig') +if not os.path.isdir(wd): + os.path.makedirs(wd) + +env = os.environ.copy() +env['PYTHONPATH'] = project +env['WEBOOB_WORKDIR'] = wd + +shutil.copyfile( + os.path.expanduser('~/.config/weboob/backends'), + os.path.join(project, wd, 'backends')) + +with open(os.path.join(wd, 'sources.list'), 'w') as f: + f.write("file://%s\n" % os.path.join(project, 'modules')) + +# Hide output unless there is an error +p = subprocess.Popen( + [sys.executable, os.path.join(project, 'scripts', 'weboob-config'), 'update'], + env=env, + stdout=subprocess.PIPE, stderr=subprocess.STDOUT) +s = p.communicate() +if p.returncode != 0: + print s[0] + sys.exit(p.returncode) + +os.execvpe( + sys.executable, + ['-Wall', os.path.join(project, 'scripts', script)] + args, + env) diff --git a/tools/local_run.sh b/tools/local_run.sh new file mode 100755 index 0000000000..a3b5332942 --- /dev/null +++ b/tools/local_run.sh @@ -0,0 +1,10 @@ +#!/bin/sh +set -e + +if [ -z "${PYTHON}" ]; then + which python >/dev/null 2>&1 && PYTHON=$(which python) + which python2 >/dev/null 2>&1 && PYTHON=$(which python2) + which python2.7 >/dev/null 2>&1 && PYTHON=$(which python2.7) +fi + +exec "${PYTHON}" "$(dirname $0)/local_run.py" "$@" -- GitLab