From dcf184d299bf95db227c9c814c6683b3af0d3ba8 Mon Sep 17 00:00:00 2001 From: Anshuman Bhaduri Date: Mon, 26 Dec 2011 14:22:52 +1300 Subject: [PATCH 1/3] Added develop.py to assist in setting up a virtualenv to run qtile. The script removes the dependence on global site-packages by installing each one of qtile's requirements from source. --HG-- branch : experimental --- develop.py | 258 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 258 insertions(+) create mode 100644 develop.py diff --git a/develop.py b/develop.py new file mode 100644 index 0000000000..2d79e64920 --- /dev/null +++ b/develop.py @@ -0,0 +1,258 @@ +import subprocess as sp +import os +import sys + +VENV = None +DEST_DIR = None +#SITE_PACKAGES = None + + +def xorg_util_macros(): + url = 'git://anongit.freedesktop.org/git/xorg/util/macros' + version = 'master' + + aclocal = os.environ['ACLOCAL'] + export('ACLOCAL', '') + + get_git_src(url, 'xorg_util_macros', version) + autogen() + configure() + make_make_install() + + export('ACLOCAL', aclocal) + + +def libxau(): + url = 'git://anongit.freedesktop.org/git/xorg/lib/libXau' + version = 'master' + + get_git_src(url, 'libxau', version) + autogen() + configure() + make_make_install() + + +def libxdmcp(): + url = 'git://anongit.freedesktop.org/git/xorg/lib/libXdmcp' + version = 'master' + + get_git_src(url, 'libxdmcp', version) + autogen() + configure() + make_make_install() + +def pthread_stubs(): + url = 'git://anongit.freedesktop.org/git/xcb/pthread-stubs' + version = 'master' + + get_git_src(url, 'pthread_stubs', version) + autogen() + configure() + make_make_install() + +def xcb_proto(): + url = 'git://anongit.freedesktop.org/git/xcb/proto' + # http://groups.google.com/group/qtile-dev/browse_thread/thread/1a184316e991a119 + version = '661fe8dd7727c27467e61a0d20dc91557ce3747f' + + get_git_src(url, 'xcb_proto', version) + autogen() + configure() + make_make_install() + +def libxcb(): + url = 'git://anongit.freedesktop.org/git/xcb/libxcb' + #version = '8ecd754b168a0352783bf1ba0f0887f7ff479ee8' + version = '8c2707773b3621fb8bbda9021d23944f5be34aab' + # First commit that doesn't work: 80322d11636dd638902660d80481080d2fad40fe + + get_git_src(url, 'libxcb', version) + autogen() + configure('--enable-xinput') + make_make_install() + +def xcb_util(): + # http://aur.archlinux.org/packages/xc/xcb-util-git/PKGBUILD + url = 'git://anongit.freedesktop.org/git/xcb/util' + version = 'master' + + get_git_src(url, 'xcb_util', version, cloneargs=['--recursive']) + autogen() + configure() + make_make_install() + +def pixman(): + url = 'git://anongit.freedesktop.org/git/pixman.git' + version = 'master' + + get_git_src(url, 'pixman', version) + autogen() + configure() + make_make_install() + + +def cairo_xcb(): + # http://aur.archlinux.org/packages/ca/cairo-xcb/PKGBUILD + url = 'git://anongit.freedesktop.org/git/cairo' + version = 'master' + + get_git_src(url, 'cairo_xcb', version) + autogen() + configure('--enable-xcb') + make_make_install() + + +def xpyb_ng(): + pip_install('-e git://github.com/dequis/xpyb-ng.git#egg=xpyb') + + +def py2cairo_xcb(): + # http://aur.archlinux.org/packages/py/pycairo-xcb-git/PKGBUILD + url = 'git://git.cairographics.org/git/py2cairo' + version = 'master' + + get_git_src(url, 'py2cairo_xcb', version) + autogen() + configure('--enable-xcb') + make_make_install() + + +#def glib2(): +# # http://aur.archlinux.org/packages/gl/glib2-git/PKGBUILD +# url = 'git://git.gnome.org/glib' +# version = 'master' +# +# get_git_src(url, 'glib2', version) +# autogen() +# configure() +# make_make_install() + + +#def gobject_introspection(): +# # https://aur.archlinux.org/packages/go/gobject-introspection-git/PKGBUILD +# url = 'git://git.gnome.org/gobject-introspection' +# version = 'GOBJECT_INTROSPECTION_1_30_0' +# +# get_git_src(url, 'gobject_introspection', version) +# autogen() +# configure() +# make_make_install() + + +def pygobject(): + url = 'git://git.gnome.org/pygobject' + version = 'PYGOBJECT_2_28_6' + + get_git_src(url, 'pygobject', version) + autogen() + configure('--disable-introspection') + make_make_install() + + +def pygtk(): + url = 'git://git.gnome.org/pygtk' + version = 'master' + + get_git_src(url, 'pygtk', version) + autogen() + configure() + make_make_install() + +def python_xlib(): + pip_install('http://downloads.sourceforge.net/python-xlib/python-xlib-0.15rc1.tar.gz') + pass + + +def pip_requirements_file(): + os.chdir(os.path.abspath(__file__)) + pip_install('-r requirements.txt') + + +def pip_install(*args): + call('pip install {0}'.format(' '.join(args))) + + +def export(key, value): + print 'export {0}={1}'.format(key, value) + os.environ[key] = value + + +def get_git_src(url, destination, revision, cloneargs=[], checkoutargs=[]): + print '***********', destination + # If directory exists checkout, else clone and checkout. + d = dest(destination) + if not os.path.exists(d): + git_clone(url, d, *cloneargs) + + os.chdir(d) + git_checkout(revision, *checkoutargs) + + +def git_clone(url, dest, *args): + call('git clone {0} {1} {2}'.format(url, dest, ' '.join(args))) + + +def git_checkout(revision, *args): + call('git checkout {0} {1}'.format(revision, ' '.join(args))) + + +def dest(d): + return os.path.join(DEST_DIR, d) + + +def autogen(*args): + call('./autogen.sh {0}'.format(' '.join(args))) + + +def configure(*args): + call('./configure --prefix={0} {1}'.format(VENV, ' '.join(args))) + + +def make_make_install(): + call('make') + call('make install') + +def call(cmd): + print cmd + #out = 0 + out = sp.call(cmd, shell=True) + if out != 0: + raise Exception('Ah! $@#%^&!! Error!!') + return out + +def main(): + global VENV + global DEST_DIR + #global SITE_PACKAGES + + # Assumes the virtualenv has been activated. + VENV = os.environ['VIRTUAL_ENV'] + DEST_DIR = os.path.join(VENV, 'src') + #SITE_PACKAGES = os.path.join(VENV, + # 'lib', + # 'python{0}.{1}'.format(sys.version_info.major, sys.version_info.minor), + # 'site-packages') + bin = os.path.join(VENV, 'bin') + python = os.path.join(bin, 'python') + lib = os.path.join(VENV, 'lib') + pkgconfig = os.path.join(lib, 'pkgconfig') + aclocal = os.path.join(VENV, 'share', 'aclocal') + + # All of Qtile's requirements, including those in the pip requirements + # file. + reqs = [xorg_util_macros, libxau, libxdmcp, pthread_stubs, xcb_proto, + libxcb, xcb_util, xpyb_ng, pixman, cairo_xcb, py2cairo_xcb, + pygobject, pygtk, python_xlib, pip_requirements_file] + + export('ACLOCAL', 'aclocal -I {0}'.format(aclocal)) + export('PKG_CONFIG_PATH', pkgconfig) + export('LD_LIBRARY_PATH', lib) + export('PYTHON', python) + + for r in reqs: + r() + + +if __name__ == '__main__': + main() + From 6c3e022489abc898e2b1d8d669c348d0efd42762 Mon Sep 17 00:00:00 2001 From: Anshuman Bhaduri Date: Mon, 26 Dec 2011 15:34:15 +1300 Subject: [PATCH 2/3] develop.py cleanup and documentation. --HG-- branch : experimental --- develop.py | 147 +++++++++++++++++++++++++++++++++-------------------- 1 file changed, 93 insertions(+), 54 deletions(-) diff --git a/develop.py b/develop.py index 2d79e64920..da53a1833b 100644 --- a/develop.py +++ b/develop.py @@ -1,31 +1,85 @@ +""" +A helper script to set up Qtile's dependencies completely inside a virtualenv. +This removes the need to link to the libraries in the global site-packages and +allows updating dependencies without affecting the system Qtile install (if +you're using Qtile). + +Note: This script is only intended for use during Qtile development. + + +Usage +===== + +#. Create a virtual environment for Qtile and activate it. (the script + requires the virtual environment to be activated). For example, :: + + virtualenv --no-site-packages --distribute /some/path/qtile + source /some/path/qtile/bin/activate + +#. Navigate to your Qtile development directory and run:: + + python develop.py + + This will download the source, build (when required) and install all the + dependencies, including the ones listed in the ``pip`` requirements file. + When searching for the requirements file, assumes it's in the same + directory as this script. + + The downloaded source code will be located at $VIRTUAL_ENV/src. + + +At least the following tools are required to build the dependencies (I may +have missed out a few): + +* git +* pkgconfig +* automake +* autoconf +* libtool +* python 2.x (ideally python 2.7) +* gperf +* gtk-doc + + +The script has been tested using Python 2.7 on an Arch Linux box. For most of +the requirements, I used Arch Linux's ABS and AUR PKGBUILDS to obtain the +required steps. + + +""" + import subprocess as sp import os -import sys VENV = None DEST_DIR = None -#SITE_PACKAGES = None + + +#============================================================================== +# Requirements start +#============================================================================== def xorg_util_macros(): url = 'git://anongit.freedesktop.org/git/xorg/util/macros' version = 'master' - + + # ACLOCAL should only be set after xorg_util_macros is installed. aclocal = os.environ['ACLOCAL'] export('ACLOCAL', '') - + get_git_src(url, 'xorg_util_macros', version) autogen() configure() make_make_install() - + export('ACLOCAL', aclocal) def libxau(): url = 'git://anongit.freedesktop.org/git/xorg/lib/libXau' version = 'master' - + get_git_src(url, 'libxau', version) autogen() configure() @@ -35,62 +89,69 @@ def libxau(): def libxdmcp(): url = 'git://anongit.freedesktop.org/git/xorg/lib/libXdmcp' version = 'master' - + get_git_src(url, 'libxdmcp', version) autogen() configure() make_make_install() + def pthread_stubs(): url = 'git://anongit.freedesktop.org/git/xcb/pthread-stubs' version = 'master' - + get_git_src(url, 'pthread_stubs', version) autogen() configure() make_make_install() + def xcb_proto(): url = 'git://anongit.freedesktop.org/git/xcb/proto' # http://groups.google.com/group/qtile-dev/browse_thread/thread/1a184316e991a119 version = '661fe8dd7727c27467e61a0d20dc91557ce3747f' - + get_git_src(url, 'xcb_proto', version) autogen() configure() make_make_install() + def libxcb(): url = 'git://anongit.freedesktop.org/git/xcb/libxcb' - #version = '8ecd754b168a0352783bf1ba0f0887f7ff479ee8' + # master doesn't build against the specified xcb_proto version. Requires + # recent xcb_proto version which we can't use. version = '8c2707773b3621fb8bbda9021d23944f5be34aab' - # First commit that doesn't work: 80322d11636dd638902660d80481080d2fad40fe - + # First commit that doesn't work: 80322d11636dd638902660d80481080d2fad40fe, + # I think. Used git bisect. + get_git_src(url, 'libxcb', version) autogen() configure('--enable-xinput') make_make_install() + def xcb_util(): # http://aur.archlinux.org/packages/xc/xcb-util-git/PKGBUILD url = 'git://anongit.freedesktop.org/git/xcb/util' version = 'master' - + get_git_src(url, 'xcb_util', version, cloneargs=['--recursive']) autogen() configure() make_make_install() + def pixman(): url = 'git://anongit.freedesktop.org/git/pixman.git' version = 'master' - + get_git_src(url, 'pixman', version) autogen() configure() make_make_install() - - + + def cairo_xcb(): # http://aur.archlinux.org/packages/ca/cairo-xcb/PKGBUILD url = 'git://anongit.freedesktop.org/git/cairo' @@ -110,39 +171,17 @@ def py2cairo_xcb(): # http://aur.archlinux.org/packages/py/pycairo-xcb-git/PKGBUILD url = 'git://git.cairographics.org/git/py2cairo' version = 'master' - + get_git_src(url, 'py2cairo_xcb', version) autogen() configure('--enable-xcb') make_make_install() -#def glib2(): -# # http://aur.archlinux.org/packages/gl/glib2-git/PKGBUILD -# url = 'git://git.gnome.org/glib' -# version = 'master' -# -# get_git_src(url, 'glib2', version) -# autogen() -# configure() -# make_make_install() - - -#def gobject_introspection(): -# # https://aur.archlinux.org/packages/go/gobject-introspection-git/PKGBUILD -# url = 'git://git.gnome.org/gobject-introspection' -# version = 'GOBJECT_INTROSPECTION_1_30_0' -# -# get_git_src(url, 'gobject_introspection', version) -# autogen() -# configure() -# make_make_install() - - def pygobject(): url = 'git://git.gnome.org/pygobject' version = 'PYGOBJECT_2_28_6' - + get_git_src(url, 'pygobject', version) autogen() configure('--disable-introspection') @@ -158,9 +197,9 @@ def pygtk(): configure() make_make_install() + def python_xlib(): pip_install('http://downloads.sourceforge.net/python-xlib/python-xlib-0.15rc1.tar.gz') - pass def pip_requirements_file(): @@ -168,6 +207,11 @@ def pip_requirements_file(): pip_install('-r requirements.txt') +#============================================================================== +# Requirements end +#============================================================================== + + def pip_install(*args): call('pip install {0}'.format(' '.join(args))) @@ -178,15 +222,14 @@ def export(key, value): def get_git_src(url, destination, revision, cloneargs=[], checkoutargs=[]): - print '***********', destination - # If directory exists checkout, else clone and checkout. + # If directory exists checkout version, else clone and checkout version. d = dest(destination) if not os.path.exists(d): git_clone(url, d, *cloneargs) os.chdir(d) git_checkout(revision, *checkoutargs) - + def git_clone(url, dest, *args): call('git clone {0} {1} {2}'.format(url, dest, ' '.join(args))) @@ -212,26 +255,23 @@ def make_make_install(): call('make') call('make install') + def call(cmd): print cmd - #out = 0 out = sp.call(cmd, shell=True) if out != 0: raise Exception('Ah! $@#%^&!! Error!!') return out + def main(): global VENV global DEST_DIR - #global SITE_PACKAGES # Assumes the virtualenv has been activated. VENV = os.environ['VIRTUAL_ENV'] DEST_DIR = os.path.join(VENV, 'src') - #SITE_PACKAGES = os.path.join(VENV, - # 'lib', - # 'python{0}.{1}'.format(sys.version_info.major, sys.version_info.minor), - # 'site-packages') + bin = os.path.join(VENV, 'bin') python = os.path.join(bin, 'python') lib = os.path.join(VENV, 'lib') @@ -239,20 +279,19 @@ def main(): aclocal = os.path.join(VENV, 'share', 'aclocal') # All of Qtile's requirements, including those in the pip requirements - # file. + # file. Order matters. reqs = [xorg_util_macros, libxau, libxdmcp, pthread_stubs, xcb_proto, libxcb, xcb_util, xpyb_ng, pixman, cairo_xcb, py2cairo_xcb, pygobject, pygtk, python_xlib, pip_requirements_file] - + export('ACLOCAL', 'aclocal -I {0}'.format(aclocal)) export('PKG_CONFIG_PATH', pkgconfig) export('LD_LIBRARY_PATH', lib) export('PYTHON', python) - + for r in reqs: r() if __name__ == '__main__': main() - From 27990cf30d3479e8e91635a21078813e90a68a16 Mon Sep 17 00:00:00 2001 From: Anshuman Bhaduri Date: Mon, 26 Dec 2011 16:29:39 +1300 Subject: [PATCH 3/3] Removed function to install from pip requirements file and added it as a manual step to the documentation. I got the function horribly wrong the first time and requirements file location detection would add unnecessary code. Updated requirements file. --HG-- branch : experimental --- develop.py | 33 ++++++++++++++++----------------- requirements.txt | 5 ++--- 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/develop.py b/develop.py index da53a1833b..b1089dfe9f 100644 --- a/develop.py +++ b/develop.py @@ -4,29 +4,34 @@ allows updating dependencies without affecting the system Qtile install (if you're using Qtile). -Note: This script is only intended for use during Qtile development. - Usage ===== #. Create a virtual environment for Qtile and activate it. (the script - requires the virtual environment to be activated). For example, :: + requires the virtual environment to be activated). For example,:: virtualenv --no-site-packages --distribute /some/path/qtile source /some/path/qtile/bin/activate -#. Navigate to your Qtile development directory and run:: +#. Navigate to your Qtile development directory and run ``develop.py``:: + cd /path/to/development/qtile python develop.py This will download the source, build (when required) and install all the - dependencies, including the ones listed in the ``pip`` requirements file. - When searching for the requirements file, assumes it's in the same - directory as this script. + dependencies, excluding some of the ones listed in the ``pip`` requirements + file, which will need to be performed separately. The downloaded source code will be located at $VIRTUAL_ENV/src. +#. Installing the requirements specified in the ``pip`` requirements file + using:: + + pip install -r requirements.txt + + should complete the development environment setup. + At least the following tools are required to build the dependencies (I may have missed out a few): @@ -44,13 +49,12 @@ The script has been tested using Python 2.7 on an Arch Linux box. For most of the requirements, I used Arch Linux's ABS and AUR PKGBUILDS to obtain the required steps. - - """ import subprocess as sp import os + VENV = None DEST_DIR = None @@ -202,11 +206,6 @@ def python_xlib(): pip_install('http://downloads.sourceforge.net/python-xlib/python-xlib-0.15rc1.tar.gz') -def pip_requirements_file(): - os.chdir(os.path.abspath(__file__)) - pip_install('-r requirements.txt') - - #============================================================================== # Requirements end #============================================================================== @@ -278,11 +277,11 @@ def main(): pkgconfig = os.path.join(lib, 'pkgconfig') aclocal = os.path.join(VENV, 'share', 'aclocal') - # All of Qtile's requirements, including those in the pip requirements - # file. Order matters. + # Most of Qtile's requirements. Includes some but not all the requirements + # in the pip requirements file. Order matters. reqs = [xorg_util_macros, libxau, libxdmcp, pthread_stubs, xcb_proto, libxcb, xcb_util, xpyb_ng, pixman, cairo_xcb, py2cairo_xcb, - pygobject, pygtk, python_xlib, pip_requirements_file] + pygobject, pygtk, python_xlib] export('ACLOCAL', 'aclocal -I {0}'.format(aclocal)) export('PKG_CONFIG_PATH', pkgconfig) diff --git a/requirements.txt b/requirements.txt index 7d3ee9da55..ff5a37bbcd 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,7 +7,6 @@ logilab-astng==0.23.0 logilab-common==0.57.1 nose==1.1.2 pep8==0.6.1 -pry==0.2.1 pylint==0.25.0 -wsgiref==0.1.2 -xpyb==1.3 +python-xlib==0.15rc1 +-e git://github.com/dequis/xpyb-ng.git@816304fd44ef5bb8548c09dd4419da0d9e17a1b5#egg=xpyb-dev