summary refs log tree commit diff
diff options
context:
space:
mode:
authorDomen Kožar <domen@dev.si>2015-11-26 17:38:35 +0100
committerDomen Kožar <domen@dev.si>2015-11-26 17:38:35 +0100
commit67e03d0c50f275b030f305de1215ee576f10b045 (patch)
tree3a25147d2a93c3c2cb7d477e39d44b86313f71ff
parente568fe9cef86bbd475cfdc681eb65c74bd973bf5 (diff)
parent0c772699ba3c58fc10bc97f4cd7d93385757d5ce (diff)
downloadnixlib-67e03d0c50f275b030f305de1215ee576f10b045.tar
nixlib-67e03d0c50f275b030f305de1215ee576f10b045.tar.gz
nixlib-67e03d0c50f275b030f305de1215ee576f10b045.tar.bz2
nixlib-67e03d0c50f275b030f305de1215ee576f10b045.tar.lz
nixlib-67e03d0c50f275b030f305de1215ee576f10b045.tar.xz
nixlib-67e03d0c50f275b030f305de1215ee576f10b045.tar.zst
nixlib-67e03d0c50f275b030f305de1215ee576f10b045.zip
Merge branch 'buildPythonPackage+wheels'
-rw-r--r--doc/language-support.xml48
-rw-r--r--pkgs/applications/audio/gpodder/default.nix15
-rw-r--r--pkgs/applications/audio/mopidy-mopify/default.nix2
-rw-r--r--pkgs/applications/editors/leo-editor/default.nix9
-rw-r--r--pkgs/applications/graphics/jbrout/default.nix34
-rw-r--r--pkgs/applications/misc/ocropus/default.nix5
-rw-r--r--pkgs/applications/misc/printrun/default.nix4
-rw-r--r--pkgs/applications/misc/pytrainer/default.nix6
-rw-r--r--pkgs/applications/networking/cluster/mesos/default.nix6
-rw-r--r--pkgs/applications/networking/mailreaders/mailnag/default.nix6
-rw-r--r--pkgs/applications/office/zim/default.nix74
-rw-r--r--pkgs/applications/science/spyder/default.nix21
-rw-r--r--pkgs/applications/video/devede/default.nix4
-rw-r--r--pkgs/applications/virtualization/virt-manager/default.nix32
-rw-r--r--pkgs/development/interpreters/pypy/default.nix6
-rw-r--r--pkgs/development/interpreters/pypy/setup-hook.sh4
-rw-r--r--pkgs/development/python-modules/bootstrapped-pip/default.nix51
-rw-r--r--pkgs/development/python-modules/bootstrapped-pip/pip-7.0.1-prefix.patch151
-rw-r--r--pkgs/development/python-modules/generic/catch_conflicts.py30
-rw-r--r--pkgs/development/python-modules/generic/default.nix131
-rw-r--r--pkgs/development/python-modules/generic/run_setup.py6
-rw-r--r--pkgs/development/python-modules/generic/wrap.sh2
-rw-r--r--pkgs/development/python-modules/matplotlib/default.nix2
-rw-r--r--pkgs/development/python-modules/mygpoclient/default.nix6
-rw-r--r--pkgs/development/python-modules/numpy-scipy-support.nix27
-rw-r--r--pkgs/development/python-modules/setuptools/default.nix21
-rw-r--r--pkgs/development/python-modules/sqlalchemy-0.7.10-test-failures.patch13
-rw-r--r--pkgs/development/python-modules/tables/default.nix1
-rw-r--r--pkgs/development/python-modules/wxPython/2.8.nix3
-rw-r--r--pkgs/development/python-modules/wxPython/generic.nix21
-rw-r--r--pkgs/development/tools/build-managers/buildbot/default.nix16
-rw-r--r--pkgs/development/tools/continuous-integration/jenkins-job-builder/default.nix26
-rw-r--r--pkgs/tools/X11/arandr/default.nix5
-rw-r--r--pkgs/tools/backup/attic/default.nix1
-rw-r--r--pkgs/tools/networking/gmvault/default.nix10
-rw-r--r--pkgs/tools/networking/p2p/tahoe-lafs/default.nix35
-rw-r--r--pkgs/tools/virtualization/cloud-init/default.nix9
-rw-r--r--pkgs/top-level/all-packages.nix12
-rw-r--r--pkgs/top-level/python-packages.nix971
-rw-r--r--pkgs/top-level/release-python.nix72
40 files changed, 1067 insertions, 831 deletions
diff --git a/doc/language-support.xml b/doc/language-support.xml
index 0a0e24e9abfd..386db7490415 100644
--- a/doc/language-support.xml
+++ b/doc/language-support.xml
@@ -196,12 +196,12 @@ you need it.</para>
 
 <para>
   Currently supported interpreters are <varname>python26</varname>, <varname>python27</varname>,
-  <varname>python32</varname>, <varname>python33</varname>, <varname>python34</varname>
+  <varname>python33</varname>, <varname>python34</varname>, <varname>python35</varname>
   and <varname>pypy</varname>.
 </para>
 
 <para>
-  <varname>python</varname> is an alias of <varname>python27</varname> and <varname>python3</varname> is an alias of <varname>python34</varname>.
+  <varname>python</varname> is an alias to <varname>python27</varname> and <varname>python3</varname> is an alias to <varname>python34</varname>.
 </para>
 
 <para>
@@ -231,7 +231,7 @@ are provided with all modules included.</para>
 </para>
 
 <para>
- All packages depending on any Python interpreter get appended <varname>$out/${python.libPrefix}/site-packages</varname>
+ All packages depending on any Python interpreter get appended <varname>$out/${python.sitePackages}</varname>
  to <literal>$PYTHONPATH</literal> if such directory exists.
 </para>
 
@@ -306,7 +306,7 @@ twisted = buildPythonPackage {
   Most of Python packages that use <varname>buildPythonPackage</varname> are defined
   in <link xlink:href="https://github.com/NixOS/nixpkgs/blob/master/pkgs/top-level/python-packages.nix"><filename>pkgs/top-level/python-packages.nix</filename></link>
   and generated for each python interpreter separately into attribute sets <varname>python26Packages</varname>,
-  <varname>python27Packages</varname>, <varname>python32Packages</varname>, <varname>python33Packages</varname>,
+  <varname>python27Packages</varname>, <varname>python35Packages</varname>, <varname>python33Packages</varname>,
   <varname>python34Packages</varname> and <varname>pypyPackages</varname>.
   </para>
 
@@ -315,19 +315,13 @@ twisted = buildPythonPackage {
 
     <orderedlist>
       <listitem><para>
-        In the <varname>configurePhase</varname>, it patches
-        <literal>setup.py</literal> to always include setuptools before
-        distutils for monkeypatching machinery to take place.
-      </para></listitem>
-
-      <listitem><para>
         In the <varname>buildPhase</varname>, it calls
-        <literal>${python.interpreter} setup.py build ...</literal>
+        <literal>${python.interpreter} setup.py bdist_wheel</literal> to build a wheel binary zipfile.
       </para></listitem>
 
       <listitem><para>
-        In the <varname>installPhase</varname>, it calls
-        <literal>${python.interpreter} setup.py install ...</literal>
+        In the <varname>installPhase</varname>, it installs the wheel file using
+        <literal>pip install *.whl</literal>.
       </para></listitem>
 
       <listitem><para>
@@ -336,11 +330,15 @@ twisted = buildPythonPackage {
         directory to include <literal>$PYTHONPATH</literal> and <literal>$PATH</literal>
         environment variables.
       </para></listitem>
+
+      <listitem><para>
+        In the <varname>installCheck/varname> phase, <literal>${python.interpreter} setup.py test</literal>
+        is ran.
+      </para></listitem>
     </orderedlist>
   </para>
 
-  <para>By default <varname>doCheck = true</varname> is set and tests are run with
-  <literal>${python.interpreter} setup.py test</literal> command in <varname>checkPhase</varname>.</para>
+  <para>By default <varname>doCheck = true</varname> is set</para>
 
   <para>
     As in Perl, dependencies on other Python packages can be specified in the
@@ -383,16 +381,9 @@ twisted = buildPythonPackage {
     </varlistentry>
 
     <varlistentry>
-      <term><varname>setupPyInstallFlags</varname></term>
-      <listitem><para>
-        List of flags passed to <command>setup.py install</command> command.
-      </para></listitem>
-    </varlistentry>
-
-    <varlistentry>
       <term><varname>setupPyBuildFlags</varname></term>
       <listitem><para>
-        List of flags passed to <command>setup.py build</command> command.
+        List of flags passed to <command>setup.py build_ext</command> command.
       </para></listitem>
     </varlistentry>
 
@@ -400,7 +391,7 @@ twisted = buildPythonPackage {
       <term><varname>pythonPath</varname></term>
       <listitem><para>
         List of packages to be added into <literal>$PYTHONPATH</literal>.
-        Packages in <varname>pythonPath</varname> are not propagated into user environment
+        Packages in <varname>pythonPath</varname> are not propagated
         (contrary to <varname>propagatedBuildInputs</varname>).
       </para></listitem>
     </varlistentry>
@@ -420,15 +411,6 @@ twisted = buildPythonPackage {
     </varlistentry>
 
     <varlistentry>
-      <term><varname>distutilsExtraCfg</varname></term>
-      <listitem><para>
-        Extra lines passed to <varname>[easy_install]</varname> section of
-        <filename>distutils.cfg</filename> (acts as global setup.cfg
-        configuration).
-      </para></listitem>
-    </varlistentry>
-
-    <varlistentry>
       <term><varname>makeWrapperArgs</varname></term>
       <listitem><para>
         A list of strings. Arguments to be passed to
diff --git a/pkgs/applications/audio/gpodder/default.nix b/pkgs/applications/audio/gpodder/default.nix
index 58b9be41545d..c2ea35105823 100644
--- a/pkgs/applications/audio/gpodder/default.nix
+++ b/pkgs/applications/audio/gpodder/default.nix
@@ -15,7 +15,7 @@ in buildPythonPackage rec {
   };
 
   buildInputs = [
-    coverage feedparser minimock sqlite3 mygpoclient intltool
+    coverage minimock sqlite3 mygpoclient intltool
     gnome3.gnome_themes_standard gnome3.defaultIconTheme
     gnome3.gsettings_desktop_schemas
   ];
@@ -27,8 +27,6 @@ in buildPythonPackage rec {
 
   postPatch = "sed -ie 's/PYTHONPATH=src/PYTHONPATH=\$(PYTHONPATH):src/' makefile";
 
-  checkPhase = "make unittest";
-
   preFixup = ''
     wrapProgram $out/bin/gpodder \
       --prefix XDG_DATA_DIRS : "${gnome3.gnome_themes_standard}/share:$XDG_ICON_DIRS:$GSETTINGS_SCHEMAS_PATH"
@@ -40,17 +38,6 @@ in buildPythonPackage rec {
   postFixup = ''
     wrapPythonPrograms
 
-    if test -e $out/nix-support/propagated-build-inputs; then
-        ln -s $out/nix-support/propagated-build-inputs $out/nix-support/propagated-user-env-packages
-    fi
-
-    createBuildInputsPth build-inputs "$buildInputStrings"
-    for inputsfile in propagated-build-inputs propagated-native-build-inputs; do
-      if test -e $out/nix-support/$inputsfile; then
-          createBuildInputsPth $inputsfile "$(cat $out/nix-support/$inputsfile)"
-      fi
-    done
-
     sed -i "$out/bin/..gpodder-wrapped-wrapped" -e '{
         /import sys; sys.argv/d
     }'
diff --git a/pkgs/applications/audio/mopidy-mopify/default.nix b/pkgs/applications/audio/mopidy-mopify/default.nix
index 770a1a79556c..4792a02f341d 100644
--- a/pkgs/applications/audio/mopidy-mopify/default.nix
+++ b/pkgs/applications/audio/mopidy-mopify/default.nix
@@ -10,7 +10,7 @@ pythonPackages.buildPythonPackage rec {
     sha256 = "0hhdss4i5436dj37pndxk81a4g3g8f6zqjyv04lhpqcww01290as";
   };
 
-  propagatedBuildInputs = [ mopidy ];
+  propagatedBuildInputs = with pythonPackages; [ mopidy configobj ];
 
   doCheck = false;
 
diff --git a/pkgs/applications/editors/leo-editor/default.nix b/pkgs/applications/editors/leo-editor/default.nix
index 4c7e3cc08af7..597f9148564b 100644
--- a/pkgs/applications/editors/leo-editor/default.nix
+++ b/pkgs/applications/editors/leo-editor/default.nix
@@ -1,9 +1,9 @@
 { stdenv, pythonPackages, fetchgit }:
+
 pythonPackages.buildPythonPackage rec {
   name = "leo-editor-${version}";
-  version = "5.1";
-
   namePrefix = "";
+  version = "5.1";
 
   src = fetchgit {
     url = "https://github.com/leo-editor/leo-editor";
@@ -13,6 +13,11 @@ pythonPackages.buildPythonPackage rec {
 
   propagatedBuildInputs = with pythonPackages; [ pyqt4 sqlite3 ];
 
+
+  patchPhase = ''
+    rm setup.cfg
+  '';
+
   meta = {
     homepage = "http://leoeditor.com";
     description = "A powerful folding editor";
diff --git a/pkgs/applications/graphics/jbrout/default.nix b/pkgs/applications/graphics/jbrout/default.nix
index 496078ffdb2e..e37c2c283e47 100644
--- a/pkgs/applications/graphics/jbrout/default.nix
+++ b/pkgs/applications/graphics/jbrout/default.nix
@@ -1,36 +1,36 @@
-{ stdenv, fetchsvn, buildPythonPackage, python, pyGtkGlade, makeWrapper, pyexiv2, lxml, pil, fbida, which }:
+{ stdenv, fetchsvn, buildPythonPackage, python, pyGtkGlade, makeWrapper, pyexiv2,  pythonPackages, fbida, which }:
 
-buildPythonPackage {
-  name = "jbrout-338";
+buildPythonPackage rec {
+  name = "jbrout-${version}";
   version = "338";
+
   src = fetchsvn {
     url = "http://jbrout.googlecode.com/svn/trunk";
-    rev = "338";
+    rev = version;
     sha256 = "0257ni4vkxgd0qhs73fw5ppw1qpf11j8fgwsqc03b1k1yv3hk4hf";
   };
 
   doCheck = false;
-# XXX: preConfigure to avoid this
-#  File "/nix/store/vnyjxn6h3rbrn49m25yyw7i1chlxglhw-python-2.7.1/lib/python2.7/zipfile.py", line 348, in FileHeader
-#    len(filename), len(extra))
-#struct.error: ushort format requires 0 <= number <= USHRT_MAX
 
-  preConfigure = ''
+  # XXX: patchPhase to avoid this
+  #  File "/nix/store/vnyjxn6h3rbrn49m25yyw7i1chlxglhw-python-2.7.1/lib/python2.7/zipfile.py", line 348, in FileHeader
+  #    len(filename), len(extra))
+  #struct.error: ushort format requires 0 <= number <= USHRT_MAX
+  patchPhase = ''
     find | xargs touch
+
+    substituteInPlace setup.py --replace "version=__version__" "version=baseVersion"
   '';
 
   postInstall = ''
-    mkdir -p $out/bin
-    echo '#!/bin/sh' > $out/bin/jbrout
-    echo "python $out/lib/python2.7/site-packages/jbrout-src-py2.7.egg/jbrout/jbrout.py" >> $out/bin/jbrout
+    mkdir $out/bin
+    echo "python $out/${python.sitePackages}/jbrout/jbrout.py" > $out/bin/jbrout
     chmod +x $out/bin/jbrout
-
-    wrapProgram $out/bin/jbrout \
-            --set PYTHONPATH "$out/lib/python:$(toPythonPath ${pyGtkGlade})/gtk-2.0:$(toPythonPath ${pyexiv2}):$(toPythonPath ${lxml}):$(toPythonPath ${pil}):$PYTHONPATH" \
-            --set PATH "${fbida}/bin:${which}/bin:$PATH"
   '';
 
-  buildInputs = [ python pyGtkGlade makeWrapper pyexiv2 lxml pil fbida which ];
+  buildInputs = [ python makeWrapper which ];
+  propagatedBuildInputs = with pythonPackages; [ pillow lxml pyGtkGlade pyexiv2 fbida ];
+
   meta = {
     homepage = "http://code.google.com/p/jbrout";
     description = "Photo manager";
diff --git a/pkgs/applications/misc/ocropus/default.nix b/pkgs/applications/misc/ocropus/default.nix
index b76852b035ad..b53a928931b6 100644
--- a/pkgs/applications/misc/ocropus/default.nix
+++ b/pkgs/applications/misc/ocropus/default.nix
@@ -32,14 +32,15 @@ pythonPackages.buildPythonPackage {
     matplotlib beautifulsoup4 pygtk lxml ];
 
   enableParallelBuilding = true;
-  
+
   preConfigure = with stdenv.lib; ''
-    ${concatStrings (map (x: "ln -s ${x.src} models/`basename ${x.name}`;")
+    ${concatStrings (map (x: "cp -R ${x.src} models/`basename ${x.name}`;")
       models)}
 
     substituteInPlace ocrolib/{common,default}.py --replace /usr/local $out
   '';
 
+  doCheck = false;  # fails
   checkPhase = ''
     patchShebangs .
     substituteInPlace ./run-test \
diff --git a/pkgs/applications/misc/printrun/default.nix b/pkgs/applications/misc/printrun/default.nix
index b407c739c703..7420441850b6 100644
--- a/pkgs/applications/misc/printrun/default.nix
+++ b/pkgs/applications/misc/printrun/default.nix
@@ -16,10 +16,10 @@ python27Packages.buildPythonPackage rec {
 
   doCheck = false;
 
+  setupPyBuildFlags = ["-i"];
+
   postPatch = ''
     sed -i -r "s|/usr(/local)?/share/|$out/share/|g" printrun/utils.py
-    sed -i "s|distutils.core|setuptools|" setup.py
-    sed -i "s|distutils.command.install |setuptools.command.install |" setup.py
   '';
 
   postInstall = ''
diff --git a/pkgs/applications/misc/pytrainer/default.nix b/pkgs/applications/misc/pytrainer/default.nix
index 843d0ab93d88..2f731fea1b0d 100644
--- a/pkgs/applications/misc/pytrainer/default.nix
+++ b/pkgs/applications/misc/pytrainer/default.nix
@@ -27,12 +27,12 @@ pythonPackages.buildPythonPackage rec {
   # string, which allows setting an explicit MIME type.
   patches = [ ./pytrainer-webkit.patch ];
 
-  pythonPath = with pythonPackages; [
+  propagatedBuildInputs = with pythonPackages; [
     dateutil lxml matplotlibGtk pyGtkGlade pywebkitgtk
-    sqlalchemy sqlalchemy_migrate
+    sqlalchemy_migrate
   ];
 
-  buildInputs = [gpsbabel sqlite] ++ pythonPath;
+  buildInputs = [ gpsbabel sqlite ];
 
   # This package contains no binaries to patch or strip.
   dontPatchELF = true;
diff --git a/pkgs/applications/networking/cluster/mesos/default.nix b/pkgs/applications/networking/cluster/mesos/default.nix
index bb7a60f2b27f..0651f729cdc9 100644
--- a/pkgs/applications/networking/cluster/mesos/default.nix
+++ b/pkgs/applications/networking/cluster/mesos/default.nix
@@ -1,6 +1,6 @@
 { stdenv, lib, makeWrapper, fetchurl, curl, sasl, openssh, autoconf
 , automake114x, libtool, unzip, gnutar, jdk, maven, python, wrapPython
-, setuptools, distutils-cfg, boto, pythonProtobuf, apr, subversion
+, setuptools, boto, pythonProtobuf, apr, subversion
 , leveldb, glog, perf, utillinux, libnl, iproute
 }:
 
@@ -15,7 +15,7 @@ in stdenv.mkDerivation rec {
   dontDisableStatic = true;
 
   src = fetchurl {
-    url = "http://www.apache.org/dist/mesos/${version}/mesos-${version}.tar.gz";
+    url = "http://archive.apache.org/dist/mesos/${version}/${name}.tar.gz";
     sha256 = "1v5xpn4wal4vcrvcklchx9slkpa8xlwqkdbnxzy9zkzpq5g3arxr";
   };
 
@@ -26,7 +26,7 @@ in stdenv.mkDerivation rec {
 
   buildInputs = [
     makeWrapper autoconf automake114x libtool curl sasl jdk maven
-    python wrapPython boto distutils-cfg setuptools leveldb
+    python wrapPython boto setuptools leveldb
     subversion apr glog
   ] ++ lib.optionals stdenv.isLinux [
     libnl
diff --git a/pkgs/applications/networking/mailreaders/mailnag/default.nix b/pkgs/applications/networking/mailreaders/mailnag/default.nix
index e4253f5bff57..4818de49e42b 100644
--- a/pkgs/applications/networking/mailreaders/mailnag/default.nix
+++ b/pkgs/applications/networking/mailreaders/mailnag/default.nix
@@ -12,12 +12,6 @@ buildPythonPackage rec {
     sha256 = "0li4kvxjmbz3nqg6bysgn2wdazqrd7gm9fym3rd7148aiqqwa91r";
   };
 
-  # Sometimes the generated output isn't identical. It seems like there's a
-  # race condtion while patching the Mailnag/commons/dist_cfg.py file. This is
-  # a small workaround to produce deterministic builds.
-  # For more information see https://github.com/NixOS/nixpkgs/pull/8279
-  setupPyBuildFlags = [ "--build-base=$PWD" ];
-
   buildInputs = [
     gettext gtk3 pythonPackages.pygobject3 pythonPackages.dbus
     pythonPackages.pyxdg gdk_pixbuf libnotify gst_all_1.gstreamer
diff --git a/pkgs/applications/office/zim/default.nix b/pkgs/applications/office/zim/default.nix
index 84a5680b1f40..d5163eef4d88 100644
--- a/pkgs/applications/office/zim/default.nix
+++ b/pkgs/applications/office/zim/default.nix
@@ -11,89 +11,25 @@ buildPythonPackage rec {
   name = "zim-${version}";
   version = "0.63";
   namePrefix = "";
-  
+
   src = fetchurl {
     url = "http://zim-wiki.org/downloads/${name}.tar.gz";
     sha256 = "077vf4h0hjmbk8bxj9l0z9rxcb3dw642n32lvfn6vjdna1qm910m";
   };
 
-  propagatedBuildInputs = [ pythonPackages.sqlite3 pygtk /*pythonPackages.pyxdg*/ pygobject ];
+  propagatedBuildInputs = [ pythonPackages.sqlite3 pygtk pythonPackages.pyxdg pygobject ];
 
   preBuild = ''
     mkdir -p /tmp/home
     export HOME="/tmp/home"
-  '';
-  
-  setupPyInstallFlags = ["--skip-xdg-cmd"];
-  
-  #
-  # Exactly identical to buildPythonPackage's version but for the
-  # `--old-and-unmanagable`, which I removed. This was removed because
-  # this is a setuptools specific flag and as zim is overriding 
-  # the install step, setuptools could not perform its monkey
-  # patching trick for the command. Alternate solutions were to
-  #
-  #  -  Remove the custom install step (tested as working but
-  #	also remove the possibility of performing the xdg-cmd
-  #     stuff).
-  #  -  Explicitly replace distutils import(s) by their setuptools
-  #	equivalent (untested). 
-  #
-  # Both solutions were judged unsatisfactory as altering the code
-  # would be required.
-  #
-  # Note that a improved solution would be to expose the use of 
-  # the `--old-and-unmanagable` flag as an option of passed to the
-  # buildPythonPackage function.
-  #
-  # Also note that I stripped all comments.
-  #
-  installPhase = ''
-    runHook preInstall
-
-    mkdir -p "$out/lib/${python.libPrefix}/site-packages"
-
-    export PYTHONPATH="$out/lib/${python.libPrefix}/site-packages:$PYTHONPATH"
-
-    ${python}/bin/${python.executable} setup.py install \
-      --install-lib=$out/lib/${python.libPrefix}/site-packages \
-      --prefix="$out" ${lib.concatStringsSep " " setupPyInstallFlags}
 
-    eapth="$out/lib/${python.libPrefix}"/site-packages/easy-install.pth
-    if [ -e "$eapth" ]; then
-	# move colliding easy_install.pth to specifically named one
-	mv "$eapth" $(dirname "$eapth")/${name}.pth
-    fi
-
-    rm -f "$out/lib/${python.libPrefix}"/site-packages/site.py*
-
-    runHook postInstall
+    sed -i '/zim_install_class,/d' setup.py
   '';
 
-  # FIXME: this is quick and dirty hack, because zim expects the
-  # path to the executable in argv[0] therefore the wrapper is
-  # modified accordingly.
-  postFixup = ''
-    wrapProgram "$out/bin/zim" \
-      --prefix XDG_DATA_DIRS : "$out/share"
-
-    wrapPythonPrograms
-
-    sed -i "s#sys\.argv\[0\] = '.zim-wrapped'#sys.argv[0] = '$out/bin/zim'#g" \
-      $out/bin/..zim-wrapped-wrapped
-
-    if test -e $out/nix-support/propagated-build-inputs; then
-        ln -s $out/nix-support/propagated-build-inputs $out/nix-support/propagated-user-env-packages
-    fi
 
-    createBuildInputsPth build-inputs "$buildInputStrings"
-    for inputsfile in propagated-build-inputs propagated-native-build-inputs; do
-      if test -e $out/nix-support/$inputsfile; then
-          createBuildInputsPth $inputsfile "$(cat $out/nix-support/$inputsfile)"
-      fi
-    done
+  preFixup = ''
+    export makeWrapperArgs="--prefix XDG_DATA_DIRS : $out/share --argv0 $out/bin/.zim-wrapped"
   '';
-  
   # Testing fails.
   doCheck = false;
 
diff --git a/pkgs/applications/science/spyder/default.nix b/pkgs/applications/science/spyder/default.nix
index 382a5cb5532a..4bc160a2c284 100644
--- a/pkgs/applications/science/spyder/default.nix
+++ b/pkgs/applications/science/spyder/default.nix
@@ -9,26 +9,21 @@
 
 buildPythonPackage rec {
   name = "spyder-${version}";
-  version = "2.3.6";
+  version = "2.3.7";
   namePrefix = "";
 
   src = fetchurl {
     url = "https://pypi.python.org/packages/source/s/spyder/${name}.zip";
-    sha256 = "0e6502e0d3f270ea8916d1a3d7ca29915801d31932db399582bc468c01d535e2";
+    sha256 = "0ywgvgcp9s64ys25nfscd2648f7di8544a21b5lb59d4f48z028h";
   };
 
-  buildInputs = [ unzip ];
+  # NOTE: sphinx makes the build fail with: ValueError: ZIP does not support timestamps before 1980
   propagatedBuildInputs =
-    [ pyside pyflakes rope sphinx numpy scipy matplotlib ipython pylint pep8 ];
+    [ pyside pyflakes rope  numpy scipy matplotlib ipython pylint pep8 ];
 
   # There is no test for spyder
   doCheck = false;
 
-  # Use setuptools instead of distutils.
-  preConfigure = ''
-    export USE_SETUPTOOLS=True
-  '';
-
   desktopItem = makeDesktopItem {
     name = "Spyder";
     exec = "spyder";
@@ -41,11 +36,9 @@ buildPythonPackage rec {
 
   # Create desktop item
   postInstall = ''
-    mkdir -p $out/share/applications
-    cp $desktopItem/share/applications/* $out/share/applications/
-
-    mkdir -p $out/share/icons
-    cp spyderlib/images/spyder.svg $out/share/icons/
+    mkdir -p $out/share/{applications,icons}
+    cp  $desktopItem/share/applications/* $out/share/applications/
+    cp  spyderlib/images/spyder.svg $out/share/icons/
   '';
 
   meta = with stdenv.lib; {
diff --git a/pkgs/applications/video/devede/default.nix b/pkgs/applications/video/devede/default.nix
index b48f0f42936d..6520f7ac21fa 100644
--- a/pkgs/applications/video/devede/default.nix
+++ b/pkgs/applications/video/devede/default.nix
@@ -14,11 +14,10 @@ in buildPythonPackage rec {
 
   buildInputs = [ ffmpeg ];
 
-  pythonPath = [ pygtk dbus ffmpeg mplayer dvdauthor vcdimager cdrkit ];
+  propagatedBuildInputs = [ pygtk dbus ffmpeg mplayer dvdauthor vcdimager cdrkit ];
 
   postPatch = ''
     substituteInPlace devede --replace "/usr/share/devede" "$out/share/devede"
-
   '';
 
   meta = with stdenv.lib; {
@@ -26,5 +25,6 @@ in buildPythonPackage rec {
     homepage = http://www.rastersoft.com/programas/devede.html;
     license = licenses.gpl3;
     maintainers = [ maintainers.bdimcheff ];
+    broken = true;  # tarball is gone
   };
 }
diff --git a/pkgs/applications/virtualization/virt-manager/default.nix b/pkgs/applications/virtualization/virt-manager/default.nix
index 0b1cf9ebc527..243b6464bb5e 100644
--- a/pkgs/applications/virtualization/virt-manager/default.nix
+++ b/pkgs/applications/virtualization/virt-manager/default.nix
@@ -18,40 +18,26 @@ buildPythonPackage rec {
   };
 
   propagatedBuildInputs =
-    [ eventlet greenlet gflags netaddr sqlalchemy carrot routes
-      PasteDeploy m2crypto ipy twisted sqlalchemy_migrate
+    [ eventlet greenlet gflags netaddr carrot routes
+      PasteDeploy m2crypto ipy twisted sqlalchemy_migrate_0_7
       distutils_extra simplejson readline glance cheetah lockfile httplib2
       urlgrabber virtinst pyGtkGlade pythonDBus gnome_python pygobject3
-      libvirt libxml2Python ipaddr vte libosinfo
+      libvirt libxml2Python ipaddr vte libosinfo gobjectIntrospection gtk3 mox
+      gtkvnc libvirt-glib glib gsettings_desktop_schemas gnome3.defaultIconTheme
+      wrapGAppsHook
     ] ++ optional spiceSupport spice_gtk;
 
-  buildInputs =
-    [ mox
-      intltool
-      gtkvnc
-      gtk3
-      libvirt-glib
-      avahi
-      glib
-      gobjectIntrospection
-      gsettings_desktop_schemas
-      gnome3.defaultIconTheme
-      wrapGAppsHook
-      dconf
-    ];
+  buildInputs = [ dconf avahi intltool ];
 
   patchPhase = ''
     sed -i 's|/usr/share/libvirt/cpu_map.xml|${system-libvirt}/share/libvirt/cpu_map.xml|g' virtinst/capabilities.py
+    sed -i "/'install_egg_info'/d" setup.py
   '';
 
-  configurePhase = ''
-    sed -i 's/from distutils.core/from setuptools/g' setup.py
-    sed -i 's/from distutils.command.install/from setuptools.command.install/g' setup.py
-    python setup.py configure --prefix=$out
+  postConfigure = ''
+    ${python.interpreter} setup.py configure --prefix=$out
   '';
 
-  buildPhase = "true";
-
   postInstall = ''
     ${glib}/bin/glib-compile-schemas "$out"/share/glib-2.0/schemas
   '';
diff --git a/pkgs/development/interpreters/pypy/default.nix b/pkgs/development/interpreters/pypy/default.nix
index fe209f6f1148..f4d322c71bb5 100644
--- a/pkgs/development/interpreters/pypy/default.nix
+++ b/pkgs/development/interpreters/pypy/default.nix
@@ -6,7 +6,7 @@ assert zlibSupport -> zlib != null;
 
 let
 
-  majorVersion = "2.6";
+  majorVersion = "4.0";
   version = "${majorVersion}.0";
   libPrefix = "pypy${majorVersion}";
 
@@ -18,7 +18,7 @@ let
 
     src = fetchurl {
       url = "https://bitbucket.org/pypy/pypy/get/release-${version}.tar.bz2";
-      sha256 = "0xympj874cnjpxj68xm5gllq2f8bbvz8hr0md8mh1yd6fgzzxibh";
+      sha256 = "008a7mxyw95asiz678v09p345v7pfchq6aa3x96fn7lkzhir67z7";
     };
 
     buildInputs = [ bzip2 openssl pkgconfig pythonFull libffi ncurses expat sqlite tk tcl xlibsWrapper libX11 makeWrapper ]
@@ -119,7 +119,7 @@ let
       isPypy = true;
       buildEnv = callPackage ../python/wrapper.nix { python = self; };
       interpreter = "${self}/bin/${executable}";
-      sitePackages = "lib/${libPrefix}/site-packages";
+      sitePackages = "site-packages";
     };
 
     enableParallelBuilding = true;  # almost no parallelization without STM
diff --git a/pkgs/development/interpreters/pypy/setup-hook.sh b/pkgs/development/interpreters/pypy/setup-hook.sh
index c82179d9e87b..e9081d1eaa53 100644
--- a/pkgs/development/interpreters/pypy/setup-hook.sh
+++ b/pkgs/development/interpreters/pypy/setup-hook.sh
@@ -1,12 +1,12 @@
 addPythonPath() {
-    addToSearchPathWithCustomDelimiter : PYTHONPATH $1/lib/pypy2.6/site-packages
+    addToSearchPathWithCustomDelimiter : PYTHONPATH $1/site-packages
 }
 
 toPythonPath() {
     local paths="$1"
     local result=
     for i in $paths; do
-        p="$i/lib/pypy2.6/site-packages"
+        p="$i/site-packages"
         result="${result}${result:+:}$p"
     done
     echo $result
diff --git a/pkgs/development/python-modules/bootstrapped-pip/default.nix b/pkgs/development/python-modules/bootstrapped-pip/default.nix
new file mode 100644
index 000000000000..677736270290
--- /dev/null
+++ b/pkgs/development/python-modules/bootstrapped-pip/default.nix
@@ -0,0 +1,51 @@
+{ stdenv, python, fetchurl, makeWrapper, unzip }:
+
+let
+  wheel_source = fetchurl {
+    url = "https://pypi.python.org/packages/py2.py3/w/wheel/wheel-0.26.0-py2.py3-none-any.whl";
+    sha256 = "1sl642ncvipqx0hzypvl5hsiqngy0sib0kq242g4mic7vnid6bn9";
+  };
+  setuptools_source = fetchurl {
+    url = "https://pypi.python.org/packages/3.4/s/setuptools/setuptools-18.2-py2.py3-none-any.whl";
+    sha256 = "0jhafl8wmjc8xigl1ib5hqiq9crmipcz0zcga52riymgqbf2bzh4";
+  };
+in stdenv.mkDerivation rec {
+  name = "python-${python.version}-bootstrapped-pip-${version}";
+  version = "7.1.2";
+
+  src = fetchurl {
+    url = "https://pypi.python.org/packages/py2.py3/p/pip/pip-${version}-py2.py3-none-any.whl";
+    sha256 = "133hx6jaspm6hd02gza66lng37l65yficc2y2x1gh16fbhxrilxr";
+  };
+
+  unpackPhase = ''
+    mkdir -p $out/${python.sitePackages}
+    unzip -d $out/${python.sitePackages} $src
+    unzip -d $out/${python.sitePackages} ${setuptools_source}
+    unzip -d $out/${python.sitePackages} ${wheel_source}
+  '';
+
+  patchPhase = ''
+    mkdir -p $out/bin
+
+    # patch pip to support "pip install --prefix"
+    # https://github.com/pypa/pip/pull/3252
+    pushd $out/${python.sitePackages}/
+    patch -p1 < ${./pip-7.0.1-prefix.patch}
+    popd
+  '';
+
+  buildInputs = [ python makeWrapper unzip ];
+
+  installPhase = ''
+
+    # install pip binary
+    echo '${python.interpreter} -m pip "$@"' > $out/bin/pip
+    chmod +x $out/bin/pip
+
+    # wrap binaries with PYTHONPATH
+    for f in $out/bin/*; do
+      wrapProgram $f --prefix PYTHONPATH ":" $out/${python.sitePackages}/
+    done
+  '';
+}
diff --git a/pkgs/development/python-modules/bootstrapped-pip/pip-7.0.1-prefix.patch b/pkgs/development/python-modules/bootstrapped-pip/pip-7.0.1-prefix.patch
new file mode 100644
index 000000000000..21936ec99e6b
--- /dev/null
+++ b/pkgs/development/python-modules/bootstrapped-pip/pip-7.0.1-prefix.patch
@@ -0,0 +1,151 @@
+commit e87c83d95bb91acdca92202e94488ca51a70e059
+Author: Domen Kožar <domen@dev.si>
+Date:   Mon Nov 16 17:39:44 2015 +0100
+
+    WIP
+
+diff --git a/pip/commands/install.py b/pip/commands/install.py
+index dbcf100..05d5a08 100644
+--- a/pip/commands/install.py
++++ b/pip/commands/install.py
+@@ -139,6 +139,13 @@ class InstallCommand(RequirementCommand):
+                  "directory.")
+ 
+         cmd_opts.add_option(
++            '--prefix',
++            dest='prefix_path',
++            metavar='dir',
++            default=None,
++            help="Installation prefix where lib, bin and other top-level folders are placed")
++
++        cmd_opts.add_option(
+             "--compile",
+             action="store_true",
+             dest="compile",
+@@ -309,6 +316,7 @@ class InstallCommand(RequirementCommand):
+                             install_options,
+                             global_options,
+                             root=options.root_path,
++                            prefix=options.prefix_path,
+                         )
+                         reqs = sorted(
+                             requirement_set.successfully_installed,
+diff --git a/pip/locations.py b/pip/locations.py
+index 4e6f65d..43aeb1f 100644
+--- a/pip/locations.py
++++ b/pip/locations.py
+@@ -163,7 +163,7 @@ site_config_files = [
+ 
+ 
+ def distutils_scheme(dist_name, user=False, home=None, root=None,
+-                     isolated=False):
++                     isolated=False, prefix=None):
+     """
+     Return a distutils install scheme
+     """
+@@ -187,6 +187,8 @@ def distutils_scheme(dist_name, user=False, home=None, root=None,
+     i.user = user or i.user
+     if user:
+         i.prefix = ""
++    else:
++        i.prefix = prefix or i.prefix
+     i.home = home or i.home
+     i.root = root or i.root
+     i.finalize_options()
+diff --git a/pip/req/req_install.py b/pip/req/req_install.py
+index 7c5bf8f..6f80a18 100644
+--- a/pip/req/req_install.py
++++ b/pip/req/req_install.py
+@@ -792,7 +792,7 @@ exec(compile(
+         else:
+             return True
+ 
+-    def install(self, install_options, global_options=[], root=None):
++    def install(self, install_options, global_options=[], root=None, prefix=None):
+         if self.editable:
+             self.install_editable(install_options, global_options)
+             return
+@@ -800,7 +800,7 @@ exec(compile(
+             version = pip.wheel.wheel_version(self.source_dir)
+             pip.wheel.check_compatibility(version, self.name)
+ 
+-            self.move_wheel_files(self.source_dir, root=root)
++            self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
+             self.install_succeeded = True
+             return
+ 
+@@ -833,6 +833,8 @@ exec(compile(
+ 
+             if root is not None:
+                 install_args += ['--root', root]
++            if prefix is not None:
++                install_args += ['--prefix', prefix]
+ 
+             if self.pycompile:
+                 install_args += ["--compile"]
+@@ -988,12 +990,13 @@ exec(compile(
+     def is_wheel(self):
+         return self.link and self.link.is_wheel
+ 
+-    def move_wheel_files(self, wheeldir, root=None):
++    def move_wheel_files(self, wheeldir, root=None, prefix=None):
+         move_wheel_files(
+             self.name, self.req, wheeldir,
+             user=self.use_user_site,
+             home=self.target_dir,
+             root=root,
++            prefix=prefix,
+             pycompile=self.pycompile,
+             isolated=self.isolated,
+         )
+diff --git a/pip/wheel.py b/pip/wheel.py
+index 403f48b..14eb141 100644
+--- a/pip/wheel.py
++++ b/pip/wheel.py
+@@ -234,12 +234,12 @@ def get_entrypoints(filename):
+ 
+ 
+ def move_wheel_files(name, req, wheeldir, user=False, home=None, root=None,
+-                     pycompile=True, scheme=None, isolated=False):
++                     pycompile=True, scheme=None, isolated=False, prefix=None):
+     """Install a wheel"""
+ 
+     if not scheme:
+         scheme = distutils_scheme(
+-            name, user=user, home=home, root=root, isolated=isolated
++            name, user=user, home=home, root=root, isolated=isolated, prefix=prefix,
+         )
+ 
+     if root_is_purelib(name, wheeldir):
+diff --git a/pip/req/req_install.py b/pip/req/req_install.py
+index 51bf4a7..e2e285e 100644
+--- a/pip/req/req_install.py
++++ b/pip/req/req_install.py
+@@ -795,7 +795,7 @@ exec(compile(
+     def install(self, install_options, global_options=[], root=None,
+                 prefix=None):
+         if self.editable:
+-            self.install_editable(install_options, global_options)
++            self.install_editable(install_options, global_options, prefix=prefix)
+             return
+         if self.is_wheel:
+             version = pip.wheel.wheel_version(self.source_dir)
+@@ -929,12 +929,16 @@ exec(compile(
+             rmtree(self._temp_build_dir)
+         self._temp_build_dir = None
+ 
+-    def install_editable(self, install_options, global_options=()):
++    def install_editable(self, install_options, global_options=(), prefix=None):
+         logger.info('Running setup.py develop for %s', self.name)
+ 
+         if self.isolated:
+             global_options = list(global_options) + ["--no-user-cfg"]
+ 
++        if prefix:
++            prefix_param = ['--prefix={0}'.format(prefix)]
++            install_options = list(install_options) + prefix_param
++
+         with indent_log():
+             # FIXME: should we do --install-headers here too?
+             cwd = self.source_dir
+
diff --git a/pkgs/development/python-modules/generic/catch_conflicts.py b/pkgs/development/python-modules/generic/catch_conflicts.py
new file mode 100644
index 000000000000..35512bb44d35
--- /dev/null
+++ b/pkgs/development/python-modules/generic/catch_conflicts.py
@@ -0,0 +1,30 @@
+import pkg_resources
+import collections
+import sys
+
+do_abort = False
+packages = collections.defaultdict(list)
+
+for f in sys.path:
+    for req in pkg_resources.find_distributions(f):
+        if req not in packages[req.project_name]:
+            # some exceptions inside buildPythonPackage
+            if req.project_name in ['setuptools', 'pip']:
+                continue
+            packages[req.project_name].append(req)
+
+
+for name, duplicates in packages.items():
+    if len(duplicates) > 1:
+        do_abort = True
+        print("Found duplicated packages in closure for dependency '{}': ".format(name))
+        for dup in duplicates:
+            print("  " + repr(dup))
+
+if do_abort:
+    print("")
+    print(
+        'Package duplicates found in closure, see above. Usually this '
+        'happens if two packages depend on different version '
+        'of the same dependency.')
+    sys.exit(1)
diff --git a/pkgs/development/python-modules/generic/default.nix b/pkgs/development/python-modules/generic/default.nix
index 4827f3745853..fe62428c0b08 100644
--- a/pkgs/development/python-modules/generic/default.nix
+++ b/pkgs/development/python-modules/generic/default.nix
@@ -3,7 +3,7 @@
    (http://pypi.python.org/pypi/setuptools/), which represents a large
    number of Python packages nowadays.  */
 
-{ python, setuptools, unzip, wrapPython, lib, recursivePthLoader, distutils-cfg }:
+{ python, setuptools, unzip, wrapPython, lib, bootstrapped-pip }:
 
 { name
 
@@ -12,28 +12,18 @@
 
 , buildInputs ? []
 
-# pass extra information to the distutils global configuration (think as global setup.cfg)
-, distutilsExtraCfg ? ""
-
 # propagate build dependencies so in case we have A -> B -> C,
-# C can import propagated packages by A
+# C can import package A propagated by B 
 , propagatedBuildInputs ? []
 
-# passed to "python setup.py install"
-, setupPyInstallFlags ? []
-
-# passed to "python setup.py build"
+# passed to "python setup.py build_ext"
+# https://github.com/pypa/pip/issues/881
 , setupPyBuildFlags ? []
 
 # enable tests by default
 , doCheck ? true
 
-# List of packages that should be added to the PYTHONPATH
-# environment variable in programs built by this function.  Packages
-# in the standard `propagatedBuildInputs' variable are also added.
-# The difference is that `pythonPath' is not propagated to the user
-# environment.  This is preferrable for programs because it doesn't
-# pollute the user environment.
+# DEPRECATED: use propagatedBuildInputs
 , pythonPath ? []
 
 # used to disable derivation, useful for specific python versions
@@ -59,106 +49,71 @@ if disabled
 then throw "${name} not supported for interpreter ${python.executable}"
 else
 
-python.stdenv.mkDerivation (builtins.removeAttrs attrs ["disabled"] // {
-  inherit doCheck;
-
+let
+  # use setuptools shim (so that setuptools is imported before distutils)
+  # pip does the same thing: https://github.com/pypa/pip/pull/3265
+  setuppy = ./run_setup.py;
+  # For backwards compatibility, let's use an alias
+  doInstallCheck = doCheck;
+in
+python.stdenv.mkDerivation (builtins.removeAttrs attrs ["disabled" "doCheck"] // {
   name = namePrefix + name;
 
-  buildInputs = [
-    wrapPython setuptools
-    (distutils-cfg.override { extraCfg = distutilsExtraCfg; })
-  ] ++ buildInputs ++ pythonPath
+  buildInputs = [ wrapPython bootstrapped-pip ] ++ buildInputs ++ pythonPath
     ++ (lib.optional (lib.hasSuffix "zip" attrs.src.name or "") unzip);
 
   # propagate python/setuptools to active setup-hook in nix-shell
-  propagatedBuildInputs = propagatedBuildInputs ++ [ recursivePthLoader python setuptools ];
-
-  pythonPath = pythonPath;
+  propagatedBuildInputs = propagatedBuildInputs ++ [ python setuptools ];
 
   configurePhase = attrs.configurePhase or ''
     runHook preConfigure
 
     # patch python interpreter to write null timestamps when compiling python files
-    # with following var we tell python to activate the patch so that python doesn't
-    # try to update them when we freeze timestamps in nix store
+    # this way python doesn't try to update them when we freeze timestamps in nix store
     export DETERMINISTIC_BUILD=1
 
-    # prepend following line to import setuptools before distutils
-    # this way we make sure setuptools monkeypatches distutils commands
-    # this way setuptools provides extra helpers such as "python setup.py test"
-    sed -i '0,/import distutils/s//import setuptools;import distutils/' setup.py
-    sed -i '0,/from distutils/s//import setuptools;from distutils/' setup.py
-
     runHook postConfigure
   '';
 
-  checkPhase = attrs.checkPhase or ''
-      runHook preCheck
-
-      ${python}/bin/${python.executable} setup.py test
-
-      runHook postCheck
-  '';
-
+  # we copy nix_run_setup.py over so it's executed relative to the root of the source
+  # many project make that assumption
   buildPhase = attrs.buildPhase or ''
     runHook preBuild
-
-    ${python}/bin/${python.executable} setup.py build ${lib.concatStringsSep " " setupPyBuildFlags}
-
+    cp ${setuppy} nix_run_setup.py
+    ${python.interpreter} nix_run_setup.py ${lib.optionalString (setupPyBuildFlags != []) ("build_ext " + (lib.concatStringsSep " " setupPyBuildFlags))} bdist_wheel
     runHook postBuild
   '';
 
   installPhase = attrs.installPhase or ''
     runHook preInstall
 
-    mkdir -p "$out/lib/${python.libPrefix}/site-packages"
-
-    export PYTHONPATH="$out/lib/${python.libPrefix}/site-packages:$PYTHONPATH"
-
-    ${python}/bin/${python.executable} setup.py install \
-      --install-lib=$out/lib/${python.libPrefix}/site-packages \
-      --old-and-unmanageable \
-      --prefix="$out" ${lib.concatStringsSep " " setupPyInstallFlags}
-
-    # --install-lib:
-    # sometimes packages specify where files should be installed outside the usual
-    # python lib prefix, we override that back so all infrastructure (setup hooks)
-    # work as expected
-
-    # --old-and-unmanagable:
-    # instruct setuptools not to use eggs but fallback to plan package install
-    # this also reduces one .pth file in the chain, but the main reason is to
-    # force install process to install only scripts for the package we are
-    # installing (otherwise it will install scripts also for dependencies)
-
-    # A pth file might have been generated to load the package from
-    # within its own site-packages, rename this package not to
-    # collide with others.
-    eapth="$out/lib/${python.libPrefix}"/site-packages/easy-install.pth
-    if [ -e "$eapth" ]; then
-        # move colliding easy_install.pth to specifically named one
-        mv "$eapth" $(dirname "$eapth")/${name}.pth
-    fi
+    mkdir -p "$out/${python.sitePackages}"
+    export PYTHONPATH="$out/${python.sitePackages}:$PYTHONPATH"
 
-    # Remove any site.py files generated by easy_install as these
-    # cause collisions. If pth files are to be processed a
-    # corresponding site.py needs to be included in the PYTHONPATH.
-    rm -f "$out/lib/${python.libPrefix}"/site-packages/site.py*
+    pushd dist
+    ${bootstrapped-pip}/bin/pip install *.whl --no-index --prefix=$out --no-cache
+    popd
 
     runHook postInstall
   '';
 
+  # We run all tests after software has been installed since that is
+  # a common idiom in Python
+  doInstallCheck = doInstallCheck;
+
+  installCheckPhase = attrs.checkPhase or ''
+    runHook preCheck
+    ${python.interpreter} nix_run_setup.py test
+    runHook postCheck
+  '';
+
   postFixup = attrs.postFixup or ''
-      wrapPythonPrograms
+    wrapPythonPrograms
 
-      # TODO: document
-      createBuildInputsPth build-inputs "$buildInputStrings"
-      for inputsfile in propagated-build-inputs propagated-native-build-inputs; do
-        if test -e $out/nix-support/$inputsfile; then
-            createBuildInputsPth $inputsfile "$(cat $out/nix-support/$inputsfile)"
-        fi
-      done
-    '';
+    # check if we have two packagegs with the same name in closure and fail
+    # this shouldn't happen, something went wrong with dependencies specs
+    ${python.interpreter} ${./catch_conflicts.py}
+  '';
 
   shellHook = attrs.shellHook or ''
     ${preShellHook}
@@ -166,7 +121,8 @@ python.stdenv.mkDerivation (builtins.removeAttrs attrs ["disabled"] // {
        tmp_path=$(mktemp -d)
        export PATH="$tmp_path/bin:$PATH"
        export PYTHONPATH="$tmp_path/${python.sitePackages}:$PYTHONPATH"
-       ${python.interpreter} setup.py develop --prefix $tmp_path
+       mkdir -p $tmp_path/${python.sitePackages}
+       ${bootstrapped-pip}/bin/pip install -e . --prefix $tmp_path
     fi
     ${postShellHook}
   '';
@@ -177,6 +133,7 @@ python.stdenv.mkDerivation (builtins.removeAttrs attrs ["disabled"] // {
   } // meta // {
     # add extra maintainer(s) to every package
     maintainers = (meta.maintainers or []) ++ [ chaoflow iElectric ];
+    # a marker for release utilies to discover python packages
+    isBuildPythonPackage = python.meta.platforms;
   };
-
 })
diff --git a/pkgs/development/python-modules/generic/run_setup.py b/pkgs/development/python-modules/generic/run_setup.py
new file mode 100644
index 000000000000..d980ac7d23d4
--- /dev/null
+++ b/pkgs/development/python-modules/generic/run_setup.py
@@ -0,0 +1,6 @@
+import setuptools
+import tokenize
+
+__file__='setup.py';
+
+exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\\r\\n', '\\n'), __file__, 'exec'))
diff --git a/pkgs/development/python-modules/generic/wrap.sh b/pkgs/development/python-modules/generic/wrap.sh
index 557f79f865ec..fa6a4d0102f3 100644
--- a/pkgs/development/python-modules/generic/wrap.sh
+++ b/pkgs/development/python-modules/generic/wrap.sh
@@ -46,7 +46,7 @@ wrapPythonProgramsIn() {
                 # (see pkgs/build-support/setup-hooks/make-wrapper.sh)
                 local wrap_args="$f \
                                  --prefix PYTHONPATH ':' $program_PYTHONPATH \
-                                 --prefix PATH ':' $program_PATH"
+                                 --prefix PATH ':' $program_PATH:$dir/bin"
 
                 # Add any additional arguments provided by makeWrapperArgs
                 # argument to buildPythonPackage.
diff --git a/pkgs/development/python-modules/matplotlib/default.nix b/pkgs/development/python-modules/matplotlib/default.nix
index b6789a851cb5..70c498ffa785 100644
--- a/pkgs/development/python-modules/matplotlib/default.nix
+++ b/pkgs/development/python-modules/matplotlib/default.nix
@@ -35,6 +35,8 @@ buildPythonPackage rec {
     sed -i 's/test_use_url/fails/' lib/matplotlib/tests/test_style.py
     # Failing test: ERROR: test suite for <class 'matplotlib.sphinxext.tests.test_tinypages.TestTinyPages'>
     sed -i 's/TestTinyPages/fails/' lib/matplotlib/sphinxext/tests/test_tinypages.py
+    # Transient errors
+    sed -i 's/test_invisible_Line_rendering/noop/' lib/matplotlib/tests/test_lines.py
   '';
 
 
diff --git a/pkgs/development/python-modules/mygpoclient/default.nix b/pkgs/development/python-modules/mygpoclient/default.nix
index e83cc9ad1f4c..a901ce774c56 100644
--- a/pkgs/development/python-modules/mygpoclient/default.nix
+++ b/pkgs/development/python-modules/mygpoclient/default.nix
@@ -8,9 +8,11 @@ buildPythonPackage rec {
     sha256 = "6a0b7b1fe2b046875456e14eda3e42430e493bf2251a64481cf4fd1a1e21a80e";
   };
 
-  buildInputs = [ pythonPackages.nose pythonPackages.minimock ];
+  buildInputs = with pythonPackages; [ nose minimock ];
 
-  checkPhase = "make test";
+  checkPhase = ''
+    nosetests
+  '';
 
   meta = {
     description = "A gpodder.net client library";
diff --git a/pkgs/development/python-modules/numpy-scipy-support.nix b/pkgs/development/python-modules/numpy-scipy-support.nix
index 915b27cb4cd3..422de794e31b 100644
--- a/pkgs/development/python-modules/numpy-scipy-support.nix
+++ b/pkgs/development/python-modules/numpy-scipy-support.nix
@@ -16,30 +16,9 @@
   # .test() function, which will run the test suite.
   checkPhase = ''
     runHook preCheck
-
-    _python=${python}/bin/${python.executable}
-
-    # We will "install" into a temp directory, so that we can run the
-    # tests (see below).
-    install_dir="$TMPDIR/test_install"
-    install_lib="$install_dir/lib/${python.libPrefix}/site-packages"
-    mkdir -p $install_dir
-    $_python setup.py install \
-      --install-lib=$install_lib \
-      --old-and-unmanageable \
-      --prefix=$install_dir > /dev/null
-
-    # Create a directory in which to run tests (you get an error if you try to
-    # import the package when you're in the current directory).
-    mkdir $TMPDIR/run_tests
-    pushd $TMPDIR/run_tests > /dev/null
-    # Temporarily add the directory we installed in to the python path
-    # (not permanently, or this pythonpath will wind up getting exported),
-    # and run the test suite.
-    PYTHONPATH="$install_lib:$PYTHONPATH" $_python -c \
-      'import ${pkgName}; ${pkgName}.test("fast", verbose=10)'
-    popd > /dev/null
-
+    pushd dist
+    ${python.interpreter} -c 'import ${pkgName}; ${pkgName}.test("fast", verbose=10)'
+    popd
     runHook postCheck
   '';
 
diff --git a/pkgs/development/python-modules/setuptools/default.nix b/pkgs/development/python-modules/setuptools/default.nix
index dc1db1405db3..082a16056fd0 100644
--- a/pkgs/development/python-modules/setuptools/default.nix
+++ b/pkgs/development/python-modules/setuptools/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, python, wrapPython, distutils-cfg }:
+{ stdenv, fetchurl, python, wrapPython }:
 
 stdenv.mkDerivation rec {
   shortName = "setuptools-${version}";
@@ -11,23 +11,14 @@ stdenv.mkDerivation rec {
     sha256 = "07avbdc26yl2a46s76fc7m4vg611g8sh39l26x9dr9byya6sb509";
   };
 
-  buildInputs = [ python wrapPython distutils-cfg ];
-
-  buildPhase = "${python}/bin/${python.executable} setup.py build";
-
-  installPhase =
-    ''
-      dst=$out/lib/${python.libPrefix}/site-packages
+  buildInputs = [ python wrapPython ];
+  doCheck = false;  # requires pytest
+  installPhase = ''
+      dst=$out/${python.sitePackages}
       mkdir -p $dst
       export PYTHONPATH="$dst:$PYTHONPATH"
-      ${python}/bin/${python.executable} setup.py install --prefix=$out --install-lib=$out/lib/${python.libPrefix}/site-packages
+      ${python.interpreter} setup.py install --prefix=$out
       wrapPythonPrograms
-    '';
-
-  doCheck = false;  # requires pytest
-
-  checkPhase = ''
-    ${python}/bin/${python.executable} setup.py test
   '';
 
   meta = with stdenv.lib; {
diff --git a/pkgs/development/python-modules/sqlalchemy-0.7.10-test-failures.patch b/pkgs/development/python-modules/sqlalchemy-0.7.10-test-failures.patch
index cca4a2021042..5880af40d14a 100644
--- a/pkgs/development/python-modules/sqlalchemy-0.7.10-test-failures.patch
+++ b/pkgs/development/python-modules/sqlalchemy-0.7.10-test-failures.patch
@@ -31,19 +31,6 @@ index 416df5a..f07c9ec 100644
  
  .. changelog::
      :version: 0.7.10
-diff --git a/lib/sqlalchemy/__init__.py b/lib/sqlalchemy/__init__.py
-index 9a21a70..6523ccb 100644
---- a/lib/sqlalchemy/__init__.py
-+++ b/lib/sqlalchemy/__init__.py
-@@ -120,7 +120,7 @@
- __all__ = sorted(name for name, obj in locals().items()
-                  if not (name.startswith('_') or inspect.ismodule(obj)))
- 
--__version__ = '0.7.10'
-+__version__ = '0.7.11'
- 
- del inspect, sys
- 
 diff --git a/test/engine/test_execute.py b/test/engine/test_execute.py
 index 69b94f1..a37f684 100644
 --- a/test/engine/test_execute.py
diff --git a/pkgs/development/python-modules/tables/default.nix b/pkgs/development/python-modules/tables/default.nix
index f1551f41ae53..3dcf00e9b8ce 100644
--- a/pkgs/development/python-modules/tables/default.nix
+++ b/pkgs/development/python-modules/tables/default.nix
@@ -20,7 +20,6 @@ buildPythonPackage rec {
       "--lzo=${lzo}"
       "--bzip2=${bzip2}"
     ];
-  setupPyInstallFlags = setupPyBuildFlags;
 
   # Run the test suite.
   # It requires the build path to be in the python search path.
diff --git a/pkgs/development/python-modules/wxPython/2.8.nix b/pkgs/development/python-modules/wxPython/2.8.nix
index 4a464e572b80..f0a452424158 100644
--- a/pkgs/development/python-modules/wxPython/2.8.nix
+++ b/pkgs/development/python-modules/wxPython/2.8.nix
@@ -1,9 +1,6 @@
 { callPackage, ... } @ args:
 
 callPackage ./generic.nix (args // rec {
-
   version = "2.8.12.1";
-
   sha256 = "1l1w4i113csv3bd5r8ybyj0qpxdq83lj6jrc5p7cc10mkwyiagqz";
-
 })
diff --git a/pkgs/development/python-modules/wxPython/generic.nix b/pkgs/development/python-modules/wxPython/generic.nix
index 8990f5cf4d1b..3151dbcfac3d 100644
--- a/pkgs/development/python-modules/wxPython/generic.nix
+++ b/pkgs/development/python-modules/wxPython/generic.nix
@@ -1,31 +1,28 @@
-{ stdenv, fetchurl, pkgconfig, python, buildPythonPackage, isPy3k, isPyPy, wxGTK, openglSupport ? true, pyopengl
-, version, sha256, ...
+{ stdenv, fetchurl, pkgconfig, python, isPy3k, isPyPy, wxGTK, openglSupport ? true, pyopengl
+, version, sha256, wrapPython, setuptools, ...
 }:
 
 assert wxGTK.unicode;
 
-buildPythonPackage rec {
+stdenv.mkDerivation rec {
+  name = "wxPython-${version}";
+  inherit version;
 
   disabled = isPy3k || isPyPy;
   doCheck = false;
 
-  name = "wxPython-${version}";
-  inherit version;
-
   src = fetchurl {
     url = "mirror://sourceforge/wxpython/wxPython-src-${version}.tar.bz2";
     inherit sha256;
   };
 
-  buildInputs = [ pkgconfig wxGTK (wxGTK.gtk) ]
-                ++ stdenv.lib.optional openglSupport pyopengl;
-
+  pythonPath = [ python setuptools ];
+  buildInputs = [ python setuptools pkgconfig wxGTK (wxGTK.gtk) wrapPython ]  ++ stdenv.lib.optional openglSupport pyopengl;
   preConfigure = "cd wxPython";
 
-  setupPyBuildFlags = [ "WXPORT=gtk2" "NO_HEADERS=1" "BUILD_GLCANVAS=${if openglSupport then "1" else "0"}" "UNICODE=1" ];
-
   installPhase = ''
-    ${python}/bin/${python.executable} setup.py ${stdenv.lib.concatStringsSep " " setupPyBuildFlags} install --prefix=$out
+    ${python.interpreter} setup.py install WXPORT=gtk2 NO_HEADERS=1 BUILD_GLCANVAS=${if openglSupport then "1" else "0"} UNICODE=1 --prefix=$out
+    wrapPythonPrograms
   '';
 
   passthru = { inherit wxGTK openglSupport; };
diff --git a/pkgs/development/tools/build-managers/buildbot/default.nix b/pkgs/development/tools/build-managers/buildbot/default.nix
index 8193845770cf..a7c4fb89007b 100644
--- a/pkgs/development/tools/build-managers/buildbot/default.nix
+++ b/pkgs/development/tools/build-managers/buildbot/default.nix
@@ -1,5 +1,5 @@
 { stdenv, buildPythonPackage, fetchurl, twisted, dateutil, jinja2
-, sqlalchemy , sqlalchemy_migrate
+, sqlalchemy , sqlalchemy_migrate_0_7
 , enableDebugClient ? false, pygobject ? null, pyGtkGlade ? null
 }:
 
@@ -9,12 +9,12 @@
 assert enableDebugClient -> pygobject != null && pyGtkGlade != null;
 
 buildPythonPackage (rec {
-  name = "buildbot-0.8.10";
+  name = "buildbot-0.8.12";
   namePrefix = "";
 
   src = fetchurl {
     url = "https://pypi.python.org/packages/source/b/buildbot/${name}.tar.gz";
-    sha256 = "1x5513mjvd3mwwadawk6v3ca2wh5mcmgnn5h9jhq1jw1plp4v5n4";
+    sha256 = "1mn4h04sp6smr3ahqfflys15cpn13q9mfkapcs2jc4ppvxv6kdn6";
   };
 
   patchPhase =
@@ -25,12 +25,12 @@ buildPythonPackage (rec {
          sed -i "$i" \
              -e "s|/usr/bin/python|$(type -P python)|g ; s|/usr/bin/||g"
        done
-    '';
 
-  buildInputs = [ ];
+      sed -i 's/==/>=/' setup.py
+    '';
 
   propagatedBuildInputs =
-    [ twisted dateutil jinja2 sqlalchemy sqlalchemy_migrate
+    [ twisted dateutil jinja2 sqlalchemy_migrate_0_7
     ] ++ stdenv.lib.optional enableDebugClient [ pygobject pyGtkGlade ];
 
   # What's up with this?! 'trial' should be 'test', no?
@@ -51,12 +51,9 @@ buildPythonPackage (rec {
 
   meta = with stdenv.lib; {
     homepage = http://buildbot.net/;
-
     license = stdenv.lib.licenses.gpl2Plus;
-
     # Of course, we don't really need that on NixOS.  :-)
     description = "Continuous integration system that automates the build/test cycle";
-
     longDescription =
       '' The BuildBot is a system to automate the compile/test cycle
          required by most software projects to validate code changes.  By
@@ -79,7 +76,6 @@ buildPythonPackage (rec {
          encouraging them to be more careful about testing before checking
          in code.
       '';
-
     maintainers = with maintainers; [ bjornfor ];
     platforms = platforms.all;
   };
diff --git a/pkgs/development/tools/continuous-integration/jenkins-job-builder/default.nix b/pkgs/development/tools/continuous-integration/jenkins-job-builder/default.nix
deleted file mode 100644
index 31ab75947dfd..000000000000
--- a/pkgs/development/tools/continuous-integration/jenkins-job-builder/default.nix
+++ /dev/null
@@ -1,26 +0,0 @@
-{ stdenv, fetchurl, pythonPackages, buildPythonPackage, git }:
-
-let
-  upstreamName = "jenkins-job-builder";
-  version = "1.2.0";
-
-in
-
-buildPythonPackage rec {
-  name = "${upstreamName}-${version}";
-  namePrefix = "";  # Don't prepend "pythonX.Y-" to the name
-
-  src = fetchurl {
-    url = "https://pypi.python.org/packages/source/j/${upstreamName}/${name}.tar.gz";
-    sha256 = "09nxdhb0ilxpmk5gbvik6kj9b6j718j5an903dpcvi3r6vzk9b3p";
-  };
-
-  pythonPath = with pythonPackages; [ pip six pyyaml pbr python-jenkins ];
-  doCheck = false;  # Requires outdated Sphinx
-
-  meta = {
-    description = "System for configuring Jenkins jobs using simple YAML files";
-    homepage = http://ci.openstack.org/jjb.html;
-    license = stdenv.lib.licenses.asl20;
-  };
-}
diff --git a/pkgs/tools/X11/arandr/default.nix b/pkgs/tools/X11/arandr/default.nix
index 556de1bd8e82..a6af7b996512 100644
--- a/pkgs/tools/X11/arandr/default.nix
+++ b/pkgs/tools/X11/arandr/default.nix
@@ -8,15 +8,14 @@ pythonPackages.buildPythonPackage rec {
     sha256 = "0d574mbmhaqmh7kivaryj2hpghz6xkvic9ah43s1hf385y7c33kd";
   };
 
-  buildPhase = ''
+  patchPhase = ''
     rm -rf data/po/*
-    python setup.py build
   '';
 
   # no tests
   doCheck = false;
 
-  buildInputs = [pythonPackages.docutils];
+  buildInputs = [ pythonPackages.docutils ];
   propagatedBuildInputs = [ xrandr pythonPackages.pygtk ];
 
   meta = {
diff --git a/pkgs/tools/backup/attic/default.nix b/pkgs/tools/backup/attic/default.nix
index e04281936870..0e2462c5ec85 100644
--- a/pkgs/tools/backup/attic/default.nix
+++ b/pkgs/tools/backup/attic/default.nix
@@ -16,6 +16,7 @@ python3Packages.buildPythonPackage rec {
 
   preConfigure = ''
     export ATTIC_OPENSSL_PREFIX="${openssl}"
+    substituteInPlace setup.py --replace "version=versioneer.get_version()" "version='${version}'"
   '';
 
   meta = with stdenv.lib; {
diff --git a/pkgs/tools/networking/gmvault/default.nix b/pkgs/tools/networking/gmvault/default.nix
index e78dfa5b2cae..aa52e4f3ae24 100644
--- a/pkgs/tools/networking/gmvault/default.nix
+++ b/pkgs/tools/networking/gmvault/default.nix
@@ -12,19 +12,15 @@ buildPythonPackage rec {
 
   doCheck = false;
 
-  propagatedBuildInputs = [
-    pythonPackages.gdata
-    pythonPackages.IMAPClient
-    pythonPackages.Logbook
-    pythonPackages.argparse
-  ];
+  propagatedBuildInputs = with pythonPackages; [ gdata IMAPClient Logbook
+    argparse ];
 
   startScript = ./gmvault.py;
 
   patchPhase = ''
     cat ${startScript} > etc/scripts/gmvault
     chmod +x etc/scripts/gmvault
-    substituteInPlace setup.py --replace "Logbook==0.4.1" "Logbook==0.4.2"
+    substituteInPlace setup.py --replace "==" ">="
   '';
 
   meta = {
diff --git a/pkgs/tools/networking/p2p/tahoe-lafs/default.nix b/pkgs/tools/networking/p2p/tahoe-lafs/default.nix
index e82b7b8050ef..836f3e1e60ca 100644
--- a/pkgs/tools/networking/p2p/tahoe-lafs/default.nix
+++ b/pkgs/tools/networking/p2p/tahoe-lafs/default.nix
@@ -1,17 +1,14 @@
 { fetchurl, lib, unzip, buildPythonPackage, twisted, foolscap, nevow
-, simplejson, zfec, pycryptopp, sqlite3, darcsver, setuptoolsTrial
-, setuptoolsDarcs, numpy, nettools, pycrypto, pyasn1, mock }:
+, simplejson, zfec, pycryptopp, sqlite3, darcsver, setuptoolsTrial, python
+, setuptoolsDarcs, numpy, nettools, pycrypto, pyasn1, mock, zope_interface }:
 
 # FAILURES: The "running build_ext" phase fails to compile Twisted
 # plugins, because it tries to write them into Twisted's (immutable)
 # store path. The problem appears to be non-fatal, but there's probably
 # some loss of functionality because of it.
 
-let
+buildPythonPackage rec {
   name = "tahoe-lafs-1.10.0";
-in
-buildPythonPackage {
-  inherit name;
   namePrefix = "";
 
   src = fetchurl {
@@ -19,7 +16,7 @@ buildPythonPackage {
     sha256 = "1qng7j1vykk8zl5da9yklkljvgxfnjky58gcay6dypz91xq1cmcw";
   };
 
-  configurePhase = ''
+  patchPhase = ''
     sed -i "src/allmydata/util/iputil.py" \
         -es"|_linux_path = '/sbin/ifconfig'|_linux_path = '${nettools}/bin/ifconfig'|g"
 
@@ -29,45 +26,43 @@ buildPythonPackage {
     do
       sed -i "$i" -e"s/localhost/127.0.0.1/g"
     done
+
+    sed -i 's/"zope.interface.*"/"zope.interface"/' src/allmydata/_auto_deps.py
+    sed -i 's/"pycrypto.*"/"pycrypto"/' src/allmydata/_auto_deps.py
   '';
 
-  buildInputs = [ unzip ]
-    ++ [ numpy ]; # Some tests want this + http://tahoe-lafs.org/source/tahoe-lafs/deps/tahoe-dep-sdists/mock-0.6.0.tar.bz2
+  # Some tests want this + http://tahoe-lafs.org/source/tahoe-lafs/deps/tahoe-dep-sdists/mock-0.6.0.tar.bz2
+  buildInputs = [ unzip numpy mock ];
 
   # The `backup' command requires `sqlite3'.
   propagatedBuildInputs =
     [ twisted foolscap nevow simplejson zfec pycryptopp sqlite3
-      darcsver setuptoolsTrial setuptoolsDarcs pycrypto pyasn1 mock
+      darcsver setuptoolsTrial setuptoolsDarcs pycrypto pyasn1 zope_interface
     ];
 
-  # The test suite is run in `postInstall'.
-  doCheck = false;
-
   postInstall = ''
     # Install the documentation.
     mkdir -p "$out/share/doc/${name}"
     cp -rv "docs/"* "$out/share/doc/${name}"
     find "$out/share/doc/${name}" -name Makefile -exec rm -v {} \;
+  '';
 
-    # Run the tests once everything is installed.
-    export PYTHON_EGG_CACHE="$TMPDIR"
-    python setup.py build
-    python setup.py trial
+  checkPhase = ''
+    # TODO: broken with wheels
+    #${python.interpreter} setup.py trial
   '';
 
   meta = {
     description = "Tahoe-LAFS, a decentralized, fault-tolerant, distributed storage system";
-
     longDescription = ''
       Tahoe-LAFS is a secure, decentralized, fault-tolerant filesystem.
       This filesystem is encrypted and spread over multiple peers in
       such a way that it remains available even when some of the peers
       are unavailable, malfunctioning, or malicious.
     '';
-
     homepage = http://allmydata.org/;
     license = [ lib.licenses.gpl2Plus /* or */ "TGPPLv1+" ];
-    maintainers = [ lib.maintainers.simons  ];
+    maintainers = [ lib.maintainers.simons ];
     platforms = lib.platforms.gnu;  # arbitrary choice
   };
 }
diff --git a/pkgs/tools/virtualization/cloud-init/default.nix b/pkgs/tools/virtualization/cloud-init/default.nix
index 48eb68242e1e..af2779e59e36 100644
--- a/pkgs/tools/virtualization/cloud-init/default.nix
+++ b/pkgs/tools/virtualization/cloud-init/default.nix
@@ -3,7 +3,7 @@
 let version = "0.7.6";
 
 in pythonPackages.buildPythonPackage rec {
-  name = "cloud-init-0.7.6";
+  name = "cloud-init-${version}";
   namePrefix = "";
 
   src = fetchurl {
@@ -11,20 +11,19 @@ in pythonPackages.buildPythonPackage rec {
     sha256 = "1mry5zdkfaq952kn1i06wiggc66cqgfp6qgnlpk0mr7nnwpd53wy";
   };
 
-  preBuild = ''
+  patchPhase = ''
     patchShebangs ./tools
 
     substituteInPlace setup.py \
       --replace /usr $out \
       --replace /etc $out/etc \
       --replace /lib/systemd $out/lib/systemd \
+      --replace 'self.init_system = ""' 'self.init_system = "systemd"'
     '';
 
-  pythonPath = with pythonPackages; [ cheetah jinja2 prettytable
+  propagatedBuildInputs = with pythonPackages; [ cheetah jinja2 prettytable
     oauth pyserial configobj pyyaml argparse requests jsonpatch ];
 
-  setupPyInstallFlags = ["--init-system systemd"];
-
   meta = {
     homepage = http://cloudinit.readthedocs.org;
     description = "provides configuration and customization of cloud instance";
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index 9d87029b7153..96011a20c870 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -5054,7 +5054,7 @@ let
 
   mesos = callPackage ../applications/networking/cluster/mesos {
     sasl = cyrus_sasl;
-    inherit (pythonPackages) python boto setuptools distutils-cfg wrapPython;
+    inherit (pythonPackages) python boto setuptools wrapPython;
     pythonProtobuf = pythonPackages.protobuf2_5;
     perf = linuxPackages.perf;
   };
@@ -5419,7 +5419,7 @@ let
   };
 
   buildbot = callPackage ../development/tools/build-managers/buildbot {
-    inherit (pythonPackages) twisted jinja2 sqlalchemy sqlalchemy_migrate;
+    inherit (pythonPackages) twisted jinja2 sqlalchemy sqlalchemy_migrate_0_7;
     dateutil = pythonPackages.dateutil_1_5;
   };
 
@@ -5698,7 +5698,7 @@ let
 
   jenkins = callPackage ../development/tools/continuous-integration/jenkins { };
 
-  jenkins-job-builder = callPackage ../development/tools/continuous-integration/jenkins-job-builder { };
+  jenkins-job-builder = pythonPackages.jenkins-job-builder;
 
   kcov = callPackage ../development/tools/analysis/kcov { };
 
@@ -12109,9 +12109,7 @@ let
 
   joe = callPackage ../applications/editors/joe { };
 
-  jbrout = callPackage ../applications/graphics/jbrout {
-    inherit (pythonPackages) lxml;
-  };
+  jbrout = callPackage ../applications/graphics/jbrout { };
 
   jumanji = callPackage ../applications/networking/browsers/jumanji {
     webkitgtk = webkitgtk24x;
@@ -13127,7 +13125,7 @@ let
   tahoelafs = callPackage ../tools/networking/p2p/tahoe-lafs {
     inherit (pythonPackages) twisted foolscap simplejson nevow zfec
       pycryptopp sqlite3 darcsver setuptoolsTrial setuptoolsDarcs
-      numpy pyasn1 mock;
+      numpy pyasn1 mock zope_interface;
   };
 
   tailor = builderDefsPackage (callPackage ../applications/version-management/tailor) {};
diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix
index 351f8626d44a..2999ff21565f 100644
--- a/pkgs/top-level/python-packages.nix
+++ b/pkgs/top-level/python-packages.nix
@@ -15,7 +15,9 @@ let
 
   callPackage = pkgs.newScope self;
 
-  buildPythonPackage = makeOverridable (callPackage ../development/python-modules/generic { });
+  buildPythonPackage = makeOverridable (callPackage ../development/python-modules/generic {
+    bootstrapped-pip = callPackage ../development/python-modules/bootstrapped-pip { };
+  });
 
   # Unique python version identifier
   pythonName =
@@ -34,19 +36,16 @@ let
     crypt = null;
   };
 
-  pythonPackages = modules // {
+in modules // {
 
   inherit python isPy26 isPy27 isPy33 isPy34 isPy35 isPyPy isPy3k pythonName buildPythonPackage;
 
   # helpers
 
-  # global distutils config used by buildPythonPackage
-  distutils-cfg = callPackage ../development/python-modules/distutils-cfg { };
-
   wrapPython = pkgs.makeSetupHook
     { deps = pkgs.makeWrapper;
       substitutions.libPrefix = python.libPrefix;
-      substitutions.executable = "${python}/bin/${python.executable}";
+      substitutions.executable = python.interpreter;
       substitutions.magicalSedExpression = let
         # Looks weird? Of course, it's between single quoted shell strings.
         # NOTE: Order DOES matter here, so single character quotes need to be
@@ -273,9 +272,8 @@ let
     };
 
     propagatedBuildInputs = with self ; [
-      pycares
-    ] ++ optional (isPy33) self.asyncio
-      ++ optional (isPy26 || isPy27) self.trollius;
+      pycares asyncio
+    ] ++ optional (isPy26 || isPy27 || isPyPy) self.trollius;
 
     meta = {
       homepage = http://github.com/saghul/aiodns;
@@ -366,7 +364,7 @@ let
       self.pyramid_jinja2
       self.pyramid_tm
       self.pytz
-      self.sqlalchemy
+      self.sqlalchemy8
       self.transaction
       self.waitress
       self.webhelpers
@@ -554,11 +552,10 @@ let
     };
   };
 
-  asyncio = buildPythonPackage rec {
+  asyncio = if (pythonAtLeast "3.3") then buildPythonPackage rec {
     name = "asyncio-${version}";
     version = "3.4.3";
 
-    disabled = (!isPy33);
 
     src = pkgs.fetchurl {
       url = "https://pypi.python.org/packages/source/a/asyncio/${name}.tar.gz";
@@ -570,7 +567,7 @@ let
       homepage = http://www.python.org/dev/peps/pep-3156;
       license = licenses.free;
     };
-  };
+  } else null;
 
   funcsigs = buildPythonPackage rec {
     name = "funcsigs-0.4";
@@ -665,6 +662,7 @@ let
     };
 
     doCheck = false;
+    propagatedBuildInputs = with self; [ dateutil ];
 
     meta = {
       description = "Twitter API library";
@@ -943,7 +941,7 @@ let
     name = "${pname}-${version}";
     version = "0.2.2";
     pname = "basiciw";
-    disabled = isPy26 || isPy27;
+    disabled = isPy26 || isPy27 || isPyPy;
 
     src = pkgs.fetchurl {
       url = "https://pypi.python.org/packages/source/b/${pname}/${name}.tar.gz";
@@ -1119,7 +1117,7 @@ let
     };
 
     buildInputs = with self; [ pkgs.btrfsProgs ];
-    propagatedBuildInputs = with self; [ contextlib2 sqlalchemy9 pyxdg pycparser alembic ]
+    propagatedBuildInputs = with self; [ contextlib2 pyxdg pycparser alembic ]
       ++ optionals (!isPyPy) [ cffi ];
 
     meta = {
@@ -1370,7 +1368,7 @@ let
     };
   };
 
-  proboscis = pythonPackages.buildPythonPackage rec {
+  proboscis = buildPythonPackage rec {
     name = "proboscis-1.2.6.0";
 
     src = pkgs.fetchurl {
@@ -1378,7 +1376,7 @@ let
       md5 = "e4b36449ef7c18f70b8243f4c8bddbca";
     };
 
-    propagatedBuildInputs = with pythonPackages; [ nose ];
+    propagatedBuildInputs = with self; [ nose ];
     doCheck = false;
 
     meta = {
@@ -1416,9 +1414,6 @@ let
 
     buildInputs = with self; [ nose unittest2 mock ];
 
-    # i can't imagine these were intentionally installed
-    postInstall = "rm -r $out/${python.sitePackages}/funtests";
-
     meta = {
       homepage = https://github.com/celery/billiard;
       description = "Python multiprocessing fork with improvements and bugfixes";
@@ -1963,6 +1958,7 @@ let
       inherit md5;
       url = "https://pypi.python.org/packages/source/z/zc.recipe.egg/zc.recipe.egg-${version}.tar.gz";
     };
+    meta.broken = true;  # https://bitbucket.org/pypa/setuptools/issues/462/pkg_resourcesfind_on_path-thinks-the
   };
   zc_recipe_egg_buildout171 = self.zc_recipe_egg_fun {
     buildout = self.zc_buildout171;
@@ -1971,8 +1967,8 @@ let
   };
   zc_recipe_egg_buildout2 = self.zc_recipe_egg_fun {
     buildout = self.zc_buildout2;
-    version = "2.0.1";
-    md5 = "5e81e9d4cc6200f5b1abcf7c653dd9e3";
+    version = "2.0.3";
+    md5 = "69a8ce276029390a36008150444aa0b4";
   };
 
   bunch = buildPythonPackage (rec {
@@ -2088,10 +2084,11 @@ let
     };
 
     buildInputs = with self; [ mock nose unittest2 ];
-    propagatedBuildInputs = with self; [ kombu billiard pytz anyjson ];
+    propagatedBuildInputs = with self; [ kombu billiard pytz anyjson amqp ];
 
-    # tests broken on python 2.6? https://github.com/nose-devs/nose/issues/806
-    doCheck = pythonAtLeast "2.7";
+    checkPhase = ''
+      nosetests $out/${python.sitePackages}/celery/tests/
+    '';
 
     meta = {
       homepage = https://github.com/celery/celery/;
@@ -2103,11 +2100,11 @@ let
 
   certifi = buildPythonPackage rec {
     name = "certifi-${version}";
-    version = "14.05.14";
+    version = "2015.9.6.2";
 
     src = pkgs.fetchurl {
       url = "https://pypi.python.org/packages/source/c/certifi/${name}.tar.gz";
-      sha256 = "0s8vxzfz6s4m6fvxc7z25k9j35w0rh6jkw3wwcd1az1mssncn6qy";
+      sha256 = "19mfly763c6bzya9dwm6qgc48z4x3gk6ldl6fprdncqhklnjnfnw";
     };
 
     meta = {
@@ -2199,6 +2196,12 @@ let
       sha256 = "04lqd2i4fjs606b0q075yi9xksk567m0sfph6v6j80za0hvzqyy5";
     };
 
+    patchPhase = ''
+      sed -i 's/==/>=/' requirements.txt
+    '';
+
+    propagatedBuildInputs = with self; [ docopt requests2 pygments ];
+
     # Error when running tests:
     # No local packages or download links found for requests
     doCheck = false;
@@ -2532,7 +2535,7 @@ let
 
     # TypeError: __call__() takes 1 positional argument but 2 were given
     doCheck = !isPy3k;
-    buildInputs = with self; [ nose mock ];
+    buildInputs = with self; [ mock ];
 
     meta = {
       description = "Code coverage measurement for python";
@@ -2624,18 +2627,17 @@ let
 
   cryptography = buildPythonPackage rec {
     # also bump cryptography_vectors
-    name = "cryptography-1.0.2";
+    name = "cryptography-1.1.1";
 
     src = pkgs.fetchurl {
       url = "https://pypi.python.org/packages/source/c/cryptography/${name}.tar.gz";
-      sha256 = "1jmcidddbbgdavvnvjjc0pda4b9a5i9idsivchn69pqxx68x8k6n";
+      sha256 = "1q5snbnn2am85zb5jrnxwzncl4kwa11740ws8g9b4ps5ywx944i9";
     };
 
     buildInputs = [ pkgs.openssl self.pretend self.cryptography_vectors
-                    self.iso8601 self.pyasn1 self.pytest self.py ]
+                    self.iso8601 self.pyasn1 self.pytest self.py self.hypothesis ]
                ++ optional stdenv.isDarwin pkgs.darwin.apple_sdk.frameworks.Security;
-    propagatedBuildInputs = [ self.six self.idna self.ipaddress self.pyasn1 ]
-     ++ optional (!isPyPy) self.cffi
+    propagatedBuildInputs = with self; [ six idna ipaddress pyasn1 cffi pyasn1-modules modules.sqlite3 ]
      ++ optional (pythonOlder "3.4") self.enum34;
 
     # IOKit's dependencies are inconsistent between OSX versions, so this is the best we
@@ -2645,11 +2647,11 @@ let
 
   cryptography_vectors = buildPythonPackage rec {
       # also bump cryptography
-    name = "cryptography_vectors-1.0.2";
+    name = "cryptography_vectors-1.1.1";
 
     src = pkgs.fetchurl {
       url = "https://pypi.python.org/packages/source/c/cryptography-vectors/${name}.tar.gz";
-      sha256 = "0dx98kcypmarwwhi6rjwy30ridys2ja6mc6mjf0svd4nllkaljdq";
+      sha256 = "17gi301p3wi39dr4dhrmpfflid3k004jp9cnvdp46b7p5lm6hb3w";
     };
   };
 
@@ -2752,6 +2754,46 @@ let
     };
   };
 
+  tablib = buildPythonPackage rec {
+    name = "tablib-${version}";
+    version = "0.10.0";
+
+    src = pkgs.fetchurl {
+      url = "https://pypi.python.org/packages/source/t/tablib/tablib-${version}.tar.gz";
+      sha256 = "14wc8bmz60g35r6gsyhdzfvgfqpd3gw9lfkq49z5bxciykbxmhj1";
+    };
+
+    buildInputs = with self; [ pytest ];
+
+    meta = with stdenv.lib; {
+      description = "Tablib: format-agnostic tabular dataset library";
+      homepage = "http://python-tablib.org";
+    };
+  };
+
+
+  cliff-tablib = buildPythonPackage rec {
+    name = "cliff-tablib-${version}";
+    version = "1.1";
+
+    src = pkgs.fetchurl {
+      url = "https://pypi.python.org/packages/source/c/cliff-tablib/cliff-tablib-${version}.tar.gz";
+      sha256 = "0fa1qw41lwda5ac3z822qhzbilp51y6p1wlp0h76vrvqcqgxi3ja";
+    };
+
+    propagatedBuildInputs = with self; [
+      argparse pyyaml pbr six cmd2 tablib unicodecsv prettytable stevedore pyparsing cliff
+    ];
+    buildInputs = with self; [
+
+    ];
+
+    meta = with stdenv.lib; {
+      homepage = "https://github.com/dreamhost/cliff-tablib";
+    };
+  };
+
+
   openstackclient = buildPythonPackage rec {
     name = "openstackclient-${version}";
     version = "1.7.1";
@@ -2764,7 +2806,7 @@ let
     propagatedBuildInputs = with self; [
      pbr six Babel cliff os-client-config oslo-config oslo-i18n oslo-utils
      glanceclient keystoneclient novaclient cinderclient neutronclient requests2
-     stevedore
+     stevedore cliff-tablib
     ];
     buildInputs = with self; [
      requests-mock
@@ -2910,7 +2952,7 @@ let
     };
   };
 
-  cffi_0_8 = buildPythonPackage rec {
+  cffi_0_8 = if isPyPy then null else buildPythonPackage rec {
     name = "cffi-0.8.6";
 
     src = pkgs.fetchurl {
@@ -2925,7 +2967,7 @@ let
     };
   };
 
-  cffi = buildPythonPackage rec {
+  cffi = if isPyPy then null else buildPythonPackage rec {
     name = "cffi-1.3.0";
 
     src = pkgs.fetchurl {
@@ -2949,8 +2991,7 @@ let
       sha256 = "0i50lh98550pwr95zgzrgiqzsspm09wl52xlv83y5nrsz4mblylv";
     };
 
-    # pycollada-0.4 needs python-dateutil==1.5
-    buildInputs = with self; [ dateutil_1_5 numpy ];
+    buildInputs = with self; [ numpy ] ++ (if isPy3k then [dateutil] else [dateutil_1_5]);
 
     # Some tests fail because they refer to test data files that don't exist
     # (upstream packaging issue)
@@ -3348,13 +3389,18 @@ let
 
   decorator = buildPythonPackage rec {
     name = "decorator-${version}";
-    version = "3.4.2";
+    version = "4.0.4";
 
     src = pkgs.fetchurl {
       url = "http://pypi.python.org/packages/source/d/decorator/${name}.tar.gz";
-      sha256 = "7320002ce61dea6aa24adc945d9d7831b3669553158905cdd12f5d0027b54b44";
+      sha256 = "1qf3iiv401vhsdmf4bd08fwb3fq4xq769q2yl7zqqr1iml7w3l2s";
     };
 
+    # no idea what that file is doing there (probably bad release)
+    preCheck = ''
+      rm src/tests/x.py
+    '';
+
     meta = {
       homepage = http://pypi.python.org/pypi/decorator;
       description = "Better living through Python with decorators";
@@ -3761,7 +3807,9 @@ let
     doCheck = !isPy3k;  # lots of transient failures
     checkPhase = ''
       # Not worth the trouble
+      rm test/with_dummyserver/test_poolmanager.py
       rm test/with_dummyserver/test_proxy_poolmanager.py
+      rm test/with_dummyserver/test_socketlevel.py
       # pypy: https://github.com/shazow/urllib3/issues/736
       rm test/with_dummyserver/test_connectionpool.py
 
@@ -3782,14 +3830,14 @@ let
   dropbox = buildPythonPackage rec {
     name = "dropbox-${version}";
     version = "3.37";
-    doCheck = false; # python 2.7.9 does verify ssl certificates
+    #doCheck = false; # python 2.7.9 does verify ssl certificates
 
     src = pkgs.fetchurl {
       url = "https://pypi.python.org/packages/source/d/dropbox/${name}.tar.gz";
       sha256 = "f65c12bd97f09e29a951bc7cb30a74e005fc4b2f8bb48778796be3f73866b173";
     };
 
-    propagatedBuildInputs = with self; [ urllib3 mock setuptools ];
+    propagatedBuildInputs = with self; [ requests2 urllib3 mock setuptools ];
 
     meta = {
       description = "A Python library for Dropbox's HTTP-based Core and Datastore APIs";
@@ -3825,6 +3873,8 @@ let
     # Check is disabled because running them destroy the content of the local cluster!
     # https://github.com/elasticsearch/elasticsearch-py/tree/master/test_elasticsearch
     doCheck = false;
+    propagatedBuildInputs = with self; [ urllib3 pyaml requests2 pyyaml ];
+    buildInputs = with self; [ nosexcover mock ];
 
     meta = {
       description = "Official low-level client for Elasticsearch";
@@ -4039,7 +4089,7 @@ let
     meta.maintainers = with maintainers; [ mornfall ];
 
     src = pkgs.fetchurl {
-      url = "https://fedorahosted.org/releases/f/e/fedpkg/fedpkg-1.14.tar.bz2";
+      url = "https://fedorahosted.org/releases/f/e/fedpkg/${name}.tar.bz2";
       sha256 = "0rj60525f2sv34g5llafnkmpvbwrfbmfajxjc14ldwzymp8clc02";
     };
 
@@ -4089,6 +4139,22 @@ let
     };
   };
 
+  functools32 = if isPy3k then null else buildPythonPackage rec {
+    name = "functools32-${version}";
+    version = "3.2.3-2";
+
+    src = pkgs.fetchurl {
+      url = "https://pypi.python.org/packages/source/f/functools32/functools32-${version}.tar.gz";
+      sha256 = "0v8ya0b58x47wp216n1zamimv4iw57cxz3xxhzix52jkw3xks9gn";
+    };
+
+
+    meta = with stdenv.lib; {
+      description = "This is a backport of the functools standard library module from";
+      homepage = "https://github.com/MiCHiLU/python-functools32";
+    };
+  };
+
   gateone = buildPythonPackage rec {
     name = "gateone-1.2-0d57c3";
     disabled = ! isPy27;
@@ -4098,7 +4164,7 @@ let
       repo = "GateOne";
       sha256 ="0zp9vfs6sqbx4d0g45kkjinfmsl9zqwa6bhp3xd81wx3ph9yr1hq";
     };
-    propagatedBuildInputs = with pkgs.pythonPackages; [tornado futures html5lib readline pkgs.openssl];
+    propagatedBuildInputs = with pkgs.self; [tornado futures html5lib readline pkgs.openssl];
     meta = {
       homepage = https://liftoffsoftware.com/;
       description = "GateOne is a web-based terminal emulator and SSH client";
@@ -4182,7 +4248,7 @@ let
     };
   };
 
-  gmusicapi = with pkgs; pythonPackages.buildPythonPackage rec {
+  gmusicapi = with pkgs; buildPythonPackage rec {
     name = "gmusicapi-4.0.0";
 
     src = pkgs.fetchurl {
@@ -4190,7 +4256,7 @@ let
       md5 = "12ba66607531978b349c7035c9bab311";
     };
 
-    propagatedBuildInputs = with pythonPackages; [
+    propagatedBuildInputs = with self; [
       validictory
       decorator
       mutagen
@@ -4809,7 +4875,6 @@ let
   };
 
   mailchimp = buildPythonPackage rec {
-
     version = "2.0.9";
     name = "mailchimp-${version}";
 
@@ -4818,13 +4883,11 @@ let
       sha256 = "0351ai0jqv3dzx0xxm1138sa7mb42si6xfygl5ak8wnfc95ff770";
     };
 
-    # Test fails because specific version of docopt is searched
-    # (Possible fix: Needs upstream patching in the library)
-    doCheck = false;
-
     buildInputs = with self; [ docopt ];
-
     propagatedBuildInputs = with self; [ requests ];
+    patchPhase = ''
+      sed -i 's/==/>=/' setup.py
+    '';
 
     meta = {
       description = "A CLI client and Python API library for the MailChimp email platform";
@@ -5169,7 +5232,7 @@ let
     };
   };
 
-  pies2overrides = pythonPackages.buildPythonPackage rec {
+  pies2overrides = buildPythonPackage rec {
     name = "pies2overrides-2.6.5";
     disabled = isPy3k;
 
@@ -5187,7 +5250,7 @@ let
     };
   };
 
-  pirate-get = pythonPackages.buildPythonPackage rec {
+  pirate-get = buildPythonPackage rec {
     name = "pirate-get-${version}";
     version = "0.2.8";
 
@@ -5662,6 +5725,21 @@ let
     };
   };
 
+  multi_key_dict = buildPythonPackage rec {
+    name = "multi_key_dict-${version}";
+    version = "2.0.3";
+
+    src = pkgs.fetchurl {
+      url = "https://pypi.python.org/packages/source/m/multi_key_dict/multi_key_dict-${version}.tar.gz";
+      sha256 = "17lkx4rf4waglwbhc31aak0f28c63zl3gx5k5i1iq2m3gb0xxsyy";
+    };
+
+    meta = with stdenv.lib; {
+      description = "multi_key_dict";
+      homepage = "https://github.com/formiaczek/multi_key_dict";
+    };
+  };
+
   pyramid_zodbconn = buildPythonPackage rec {
     name = "pyramid_zodbconn-0.7";
 
@@ -5673,8 +5751,8 @@ let
     # should be fixed in next release
     doCheck = false;
 
-    buildInputs = with self; [ pyramid mock ];
-    propagatedBuildInputs = with self; [ zodb zodburi ];
+    buildInputs = with self; [ mock ];
+    propagatedBuildInputs = with self; [ pyramid zodb zodburi ZEO ];
 
     meta = {
       maintainers = with maintainers; [ iElectric ];
@@ -5981,7 +6059,7 @@ let
     };
   };
 
-  validictory = pythonPackages.buildPythonPackage rec {
+  validictory = buildPythonPackage rec {
     name = "validictory-1.0.0a2";
 
     src = pkgs.fetchurl {
@@ -5989,7 +6067,6 @@ let
       md5 = "54c206827931cc4ed8a9b1cc78e380c5";
     };
 
-    propagatedBuildInputs = with pythonPackages; [  ];
     doCheck = false;
 
     meta = {
@@ -6227,51 +6304,6 @@ let
     };
   };
 
-  django_1_4 = buildPythonPackage rec {
-    name = "Django-${version}";
-    version = "1.4.22";
-
-    src = pkgs.fetchurl {
-      url = "http://www.djangoproject.com/m/releases/1.4/${name}.tar.gz";
-      sha256 = "110p1mgdcf87kyr64mr2jgmyapyg27kha74yq3wjrazwfbbwkqnh";
-    };
-
-    # error: invalid command 'test'
-    doCheck = false;
-
-    # patch only $out/bin to avoid problems with starter templates (see #3134)
-    postFixup = ''
-      wrapPythonProgramsIn $out/bin "$out $pythonPath"
-    '';
-
-    meta = {
-      description = "A high-level Python Web framework";
-      homepage = https://www.djangoproject.com/;
-    };
-  };
-
-  django_1_3 = buildPythonPackage rec {
-    name = "Django-1.3.7";
-
-    src = pkgs.fetchurl {
-      url = "http://www.djangoproject.com/m/releases/1.3/${name}.tar.gz";
-      sha256 = "12pv8y2x3fhrcrjayfm6z40r57iwchfi5r19ajs8q8z78i3z8l7f";
-    };
-
-    # error: invalid command 'test'
-    doCheck = false;
-
-    # patch only $out/bin to avoid problems with starter templates (see #3134)
-    postFixup = ''
-      wrapPythonProgramsIn $out/bin "$out $pythonPath"
-    '';
-
-    meta = {
-      description = "A high-level Python Web framework";
-      homepage = https://www.djangoproject.com/;
-    };
-  };
-
   django_appconf = buildPythonPackage rec {
     name = "django-appconf-${version}";
     version = "1.0.1";
@@ -6311,15 +6343,15 @@ let
   };
 
   django_evolution = buildPythonPackage rec {
-    name = "django_evolution-0.6.9";
+    name = "django_evolution-0.7.5";
     disabled = isPy3k;
 
     src = pkgs.fetchurl {
-      url = "http://downloads.reviewboard.org/releases/django-evolution/${name}.tar.gz";
-      md5 = "c0d7d10bc41898c88b14d434c48766ff";
+      url = "https://pypi.python.org/packages/source/d/django_evolution/${name}.tar.gz";
+      sha256 = "1qbcx54hq8iy3n2n6cki3bka1m9rp39np4hqddrm9knc954fb7nv";
     };
 
-    propagatedBuildInputs = with self; [ django_1_5 ];
+    propagatedBuildInputs = with self; [ django_1_6 ];
 
     meta = {
       description = "A database schema evolution tool for the Django web framework";
@@ -6339,7 +6371,7 @@ let
     # error: invalid command 'test'
     doCheck = false;
 
-    propagatedBuildInputs = with self; [ django_1_3 ];
+    propagatedBuildInputs = with self; [ django_1_5 ];
 
     meta = {
       description = "A generic tagging application for Django projects";
@@ -6526,11 +6558,10 @@ let
 
     src = pkgs.fetchurl {
       url = "http://pypi.python.org/packages/source/d/django-pipeline/${name}.tar.gz";
-      md5 = "dff8a4abb2895ee5df335c3fb2775a02";
       sha256 = "1y49fa8jj7x9qjj5wzhns3zxwj0s73sggvkrv660cqw5qb7d8hha";
     };
 
-    propagatedBuildInputs = with self; [ django futures ];
+    propagatedBuildInputs = with self; [ django_1_6 futures ];
 
     meta = with stdenv.lib; {
       description = "Pipeline is an asset packaging library for Django.";
@@ -6539,16 +6570,25 @@ let
     };
   };
 
+  django_pipeline_1_3 = self.django_pipeline.overrideDerivation (super: rec {
+    name = "django-pipeline-1.3.27";
+    src = pkgs.fetchurl {
+      url = "http://pypi.python.org/packages/source/d/django-pipeline/${name}.tar.gz";
+      sha256 = "0iva3cmnh5jw54c7w83nx9nqv523hjvkbjchzd2pb6vzilxf557k";
+    };
+  });
+
 
   djblets = buildPythonPackage rec {
-    name = "Djblets-0.6.31";
+    name = "Djblets-0.9";
 
     src = pkgs.fetchurl {
-      url = "http://downloads.reviewboard.org/releases/Djblets/0.6/${name}.tar.gz";
-      sha256 = "1yf0dnkj00yzzhbssw88j9gr58ngjfrd6r68p9asf6djishj9h45";
+      url = "http://downloads.reviewboard.org/releases/Djblets/0.9/${name}.tar.gz";
+      sha256 = "1rr5vjwiiw3kih4k9nawislf701l838dbk5xgizadvwp6lpbpdpl";
     };
 
-    propagatedBuildInputs = with self; [ pil django_1_3 feedparser ];
+    propagatedBuildInputs = with self; [
+      django_1_6 feedparser django_pipeline_1_3 pillowfight pytz ];
 
     meta = {
       description = "A collection of useful extensions for Django";
@@ -6556,6 +6596,65 @@ let
     };
   };
 
+  pillowfight = buildPythonPackage rec {
+    name = "pillowfight-${version}";
+    version = "0.2";
+
+    src = pkgs.fetchurl {
+      url = "https://pypi.python.org/packages/source/p/pillowfight/pillowfight-${version}.tar.gz";
+      sha256 = "1mh1nhcjjgv7x134sv0krri59ng8bp2w6cwsxc698rixba9f3g0m";
+    };
+
+    propagatedBuildInputs = with self; [
+      pillow
+    ];
+    meta = with stdenv.lib; {
+      description = "Pillow Fight";
+      homepage = "https://github.com/beanbaginc/pillowfight";
+    };
+  };
+
+
+  keepalive = buildPythonPackage rec {
+    name = "keepalive-${version}";
+    version = "0.4.1";
+
+    src = pkgs.fetchurl {
+      url = "https://pypi.python.org/packages/source/k/keepalive/keepalive-${version}.tar.gz";
+      sha256 = "07vn3b67ajwi7vv37h02kw7hg2z5dxhn9947dnvii05rfr5b27iy";
+    };
+
+    meta = with stdenv.lib; {
+      description = "An HTTP handler for `urllib2` that supports HTTP 1.1 and keepalive.";
+      homepage = "https://github.com/wikier/keepalive";
+    };
+  };
+
+
+  SPARQLWrapper = buildPythonPackage rec {
+    name = "SPARQLWrapper-${version}";
+    version = "1.7.4";
+
+    src = pkgs.fetchurl {
+      url = "https://pypi.python.org/packages/source/S/SPARQLWrapper/SPARQLWrapper-${version}.tar.gz";
+      sha256 = "1dpwwlcdk4m8wr3d9lb24g1xcvs202c0ir4q3jcijy88is3bvgmp";
+    };
+
+    # break circular dependency loop
+    patchPhase = ''
+      sed -i '/rdflib/d' requirements.txt
+    '';
+
+    propagatedBuildInputs = with self; [
+      six isodate pyparsing html5lib keepalive
+    ];
+
+    meta = with stdenv.lib; {
+      description = "This is a wrapper around a SPARQL service. It helps in creating the query URI and, possibly, convert the result into a more manageable format.";
+      homepage = "http://rdflib.github.io/sparqlwrapper";
+    };
+  };
+
 
   dulwich = buildPythonPackage rec {
     name = "dulwich-${version}";
@@ -6738,10 +6837,9 @@ let
     };
   };
 
-  enum34 = buildPythonPackage rec {
+  enum34 = if pythonAtLeast "3.4" then null else buildPythonPackage rec {
     name = "enum34-${version}";
     version = "1.0.4";
-    disabled = pythonAtLeast "3.4";
 
     src = pkgs.fetchurl {
       url = "http://pypi.python.org/packages/source/e/enum34/${name}.tar.gz";
@@ -6897,27 +6995,26 @@ let
   };
 
   docker_compose = buildPythonPackage rec {
-    version = "1.4.2";
+    version = "1.5.1";
     name = "docker-compose-${version}";
     namePrefix = "";
     disabled = isPy3k || isPyPy;
 
     src = pkgs.fetchurl {
       url = "https://pypi.python.org/packages/source/d/docker-compose/${name}.tar.gz";
-      sha256 = "4f5dae7685b60b70d5adc66a8572e08a97d45f26e279897d70e539277b5d9331";
+      sha256 = "0mdgpwkpss48zz36sw65crqjry87ba5p3mkl6ncbb8jqsxgqhpnz";
     };
 
+    # lots of networking and other fails
+    doCheck = false;
+    buildInputs = with self; [ mock pytest nose ];
     propagatedBuildInputs = with self; [
-      six requests pyyaml texttable docopt docker dockerpty websocket_client
-      (requests2.override {
-        src = pkgs.fetchurl {
-          url = "https://pypi.python.org/packages/source/r/requests/requests-2.6.1.tar.gz";
-          md5 = "da6e487f89e6a531699b7fd97ff182af";
-        };
-      })
+      requests2 six pyyaml texttable docopt docker dockerpty websocket_client
+      enum34 jsonschema
     ];
-
-    doCheck = false;
+    patchPhase = ''
+      sed -i "s/'requests >= 2.6.1, < 2.8'/'requests'/" setup.py
+    '';
 
     meta = {
       homepage = "https://docs.docker.com/compose/";
@@ -7166,15 +7263,16 @@ let
   };
 
   jsonschema = buildPythonPackage (rec {
-    version = "2.4.0";
+    version = "2.5.1";
     name = "jsonschema-${version}";
 
     src = pkgs.fetchurl {
       url = "https://pypi.python.org/packages/source/j/jsonschema/jsonschema-${version}.tar.gz";
-      md5 = "661f85c3d23094afbb9ac3c0673840bf";
+      sha256 = "0hddbqjm4jq63y8jf44nswina1crjs16l9snb6m3vvgyg31klrrn";
     };
 
-    buildInputs = with self; [ nose mock ];
+    buildInputs = with self; [ nose mock vcversioner ];
+    propagatedBuildInputs = with self; [ functools32 ];
 
     patchPhase = ''
       substituteInPlace jsonschema/tests/test_jsonschema_test_suite.py --replace "python" "${python}/bin/${python.executable}"
@@ -7192,6 +7290,20 @@ let
     };
   });
 
+  vcversioner = buildPythonPackage rec {
+    name = "vcversioner-${version}";
+    version = "2.14.0.0";
+
+    src = pkgs.fetchurl {
+      url = "https://pypi.python.org/packages/source/v/vcversioner/vcversioner-${version}.tar.gz";
+      sha256 = "11ivq1bm7v0yb4nsfbv9m7g7lyjn112gbvpjnjz8nv1fx633dm5c";
+    };
+
+    meta = with stdenv.lib; {
+      homepage = "https://github.com/habnabit/vcversioner";
+    };
+  };
+
   falcon = buildPythonPackage (rec {
     name = "falcon-0.3.0";
 
@@ -7293,6 +7405,8 @@ let
       sha256 = "144f4yn2nvnxh2vrnmiabpwx3s637np0d1j1w95zym790d66shir";
     };
 
+    propagatedBuildInputs = [ self.six ];
+
     meta = {
       description = "Filesystem abstraction";
       homepage    = http://pypi.python.org/pypi/fs;
@@ -7300,9 +7414,6 @@ let
       maintainers = with maintainers; [ lovek323 ];
       platforms   = platforms.unix;
     };
-
-    # Fails: "error: invalid command 'test'"
-    doCheck = false;
   };
 
   fuse = buildPythonPackage (rec {
@@ -8017,14 +8128,16 @@ let
     };
   };
 
-  hypothesis = pythonPackages.buildPythonPackage rec {
-    name = "hypothesis-0.7.0";
+  hypothesis = buildPythonPackage rec {
+    name = "hypothesis-1.14.0";
 
-    doCheck = false;
+    buildInputs = with self; [fake_factory django numpy pytz flake8 pytest ];
+
+    doCheck = false;  # no tests in source
 
     src = pkgs.fetchurl {
-      url = "https://pypi.python.org/packages/source/h/hypothesis/hypothesis-0.7.0.tar.gz";
-      md5 = "0c4112bab04b71979286387b033921b5";
+      url = "https://pypi.python.org/packages/source/h/hypothesis/${name}.tar.gz";
+      sha256 = "12dxrvn108q2j20brrk6zcb8w00kn3af1c07c0fv572nf2ngyaxy";
     };
 
     meta = {
@@ -8171,6 +8284,12 @@ let
 
     disabled = isPy3k;
 
+    patchPhase = ''
+      # transient failures
+      substituteInPlace inginious/backend/tests/TestRemoteAgent.py \
+        --replace "test_update_task_directory" "noop"
+    '';
+
     propagatedBuildInputs = with self; [
       requests2
       cgroup-utils docker-custom docutils lti mock pygments
@@ -8375,14 +8494,18 @@ let
     };
   };
 
-  ipaddress = buildPythonPackage rec {
-    name = "ipaddress-1.0.7";
+  ipaddress = if (pythonAtLeast "3.3") then null else buildPythonPackage rec {
+    name = "ipaddress-1.0.15";
 
     src = pkgs.fetchurl {
       url = "https://pypi.python.org/packages/source/i/ipaddress/${name}.tar.gz";
-      md5 = "5d9ecf415cced476f7781cf5b9ef70c4";
+      sha256 = "0dk6ky7akh5j4y3qbpnbi0qby64nyprbkrjm2s32pcfdr77qav5g";
     };
 
+    checkPhase = ''
+      ${python.interpreter} test_ipaddress.py
+    '';
+
     meta = {
       description = "Port of the 3.3+ ipaddress module to 2.6, 2.7, and 3.2";
       homepage = https://github.com/phihag/ipaddress;
@@ -8803,15 +8926,18 @@ let
   });
 
 
-  limnoria = buildPythonPackage (rec {
-    name = "limnoria-20130327";
+  limnoria = buildPythonPackage rec {
+    name = "limnoria-${version}";
+    version = "2015.10.04";
 
     src = pkgs.fetchurl {
-      url = https://pypi.python.org/packages/source/l/limnoria/limnoria-2013-06-01T10:32:51+0200.tar.gz;
-      name = "limnoria-2013-06-01.tar.gz";
-      sha256 = "1i8q9zzf43sr3n1q4h6h1z8nz31g4aa8dq94ywvfbh7hklmchq6n";
+      url = "https://pypi.python.org/packages/source/l/limnoria/${name}.tar.gz";
+      sha256 = "1hwwwr0z2vsirgwd92z17nbhnhsz0m25bpxn5sanqlbcjbwhyk9z";
     };
 
+    patchPhase = ''
+      sed -i 's/version=version/version="${version}"/' setup.py
+    '';
     buildInputs = with self; [ pkgs.git ];
     propagatedBuildInputs = with self; [ modules.sqlite3 ];
 
@@ -8823,7 +8949,7 @@ let
       license = licenses.bsd3;
       maintainers = with maintainers; [ goibhniu ];
     };
-  });
+  };
 
 
   linode = buildPythonPackage rec {
@@ -8951,6 +9077,26 @@ let
     propagatedBuildInputs = with self; [ unittest2 six ];
   };
 
+  logilab-constraint = buildPythonPackage rec {
+    name = "logilab-constraint-${version}";
+    version = "0.6.0";
+
+    src = pkgs.fetchurl {
+      url = "https://pypi.python.org/packages/source/l/logilab-constraint/${name}.tar.gz";
+      sha256 = "1n0xim4ij1n4yvyqqvyc0wllhjs22szglsd5av0j8k2qmck4njcg";
+    };
+
+    propagatedBuildInputs = with self; [
+      logilab_common six
+    ];
+
+    meta = with stdenv.lib; {
+      description = "logilab-database provides some classes to make unified access to different";
+      homepage = "http://www.logilab.org/project/logilab-database";
+    };
+  };
+
+
   lxml = buildPythonPackage ( rec {
     name = "lxml-3.3.6";
 
@@ -9096,12 +9242,12 @@ let
   };
 
   markdown = buildPythonPackage rec {
-    version = "2.3.1";
+    version = "2.6.4";
     name = "markdown-${version}";
 
     src = pkgs.fetchurl {
       url = "http://pypi.python.org/packages/source/M/Markdown/Markdown-${version}.tar.gz";
-      sha256 = "147j9hznv2r187a86d28glmg3pckfrdp0nz9yh7s1aqpawwdkszz";
+      sha256 = "1kll5b35wqkhvniwm2kh6rqc43wakv9ls0qm6g5318pjmbkywdp4";
     };
 
     # error: invalid command 'test'
@@ -9277,10 +9423,7 @@ let
     doCheck = false;
     # sed calls will be unecessary in v3.1.11+
     preConfigure = ''
-      sed -i 's/future == 0.9.0/future>=0.9.0/' setup.py
-      sed -i 's/tzlocal == 1.0/tzlocal>=1.0/' setup.py
-      sed -i 's/pep8==1.4.1/pep8>=1.4.1/' setup.py
-      sed -i 's/pyflakes==0.6.1/pyflakes>=0.6.1/' setup.py
+      sed -i 's/==/>=/' setup.py
       export LC_ALL="en_US.UTF-8"
     '';
 
@@ -9434,17 +9577,20 @@ let
     };
   };
 
+
   mitmproxy = buildPythonPackage rec {
     baseName = "mitmproxy";
-    name = "${baseName}-${meta.version}";
+    name = "${baseName}-${version}";
+    version = "0.14.0";
 
     src = pkgs.fetchurl {
       url = "${meta.homepage}/download/${name}.tar.gz";
-      sha256 = "0mpyw8iw4l4jv175qlbn0rrlgiz1k79m44jncbdxfj8ddvvvyz2j";
+      sha256 = "0mbd3m8x9a5v9skvzayjwaccn5kpgjb5p7hal5rrrcj69d8xrz6f";
     };
 
-    buildInputs = with self; [
-      pyopenssl pyasn1 urwid pil lxml flask protobuf netlib
+    propagatedBuildInputs = with self; [
+      pyopenssl pyasn1 urwid pillow lxml flask protobuf netlib click
+      ConfigArgParse pyperclip blinker construct pyparsing html2text tornado
     ];
 
     doCheck = false;
@@ -9457,7 +9603,6 @@ let
     '';
 
     meta = {
-      version = "0.10.1";
       description = ''Man-in-the-middle proxy'';
       homepage = "http://mitmproxy.org/";
       license = licenses.mit;
@@ -9638,11 +9783,11 @@ let
 
   msrplib = buildPythonPackage rec {
     name = "python-msrplib-${version}";
-    version = "0.17.0";
+    version = "0.18.0";
 
     src = pkgs.fetchurl {
       url = "http://download.ag-projects.com/MSRP/${name}.tar.gz";
-      sha256 = "fe6ee541fbb4380a5708d08f378724dbc93438ff35c0cd0400e31b070fce73c4";
+      sha256 = "0vp9g5p015g3f67rl4vz0qnn6x7hciry6nmvwf82h9h5rx11r43j";
     };
 
     propagatedBuildInputs = with self; [ eventlib application gnutls ];
@@ -9763,9 +9908,10 @@ let
     };
   });
 
-  plover = pythonPackages.buildPythonPackage rec {
+  plover = buildPythonPackage rec {
     name = "plover-${version}";
     version = "2.5.8";
+    disabled = !isPy27;
 
     meta = {
       description = "OpenSteno Plover stenography software";
@@ -10070,26 +10216,47 @@ let
     };
   };
 
+  hpack = buildPythonPackage rec {
+    name = "hpack-${version}";
+    version = "2.0.1";
+
+    src = pkgs.fetchurl {
+      url = "https://pypi.python.org/packages/source/h/hpack/hpack-${version}.tar.gz";
+      sha256 = "1k4wa8c52bd6x109bn6hc945595w6aqgzj6ipy6c2q7vxkzalzhd";
+    };
+
+    propagatedBuildInputs = with self; [
+
+    ];
+    buildInputs = with self; [
+
+    ];
+
+    meta = with stdenv.lib; {
+      description = "========================================";
+      homepage = "http://hyper.rtfd.org";
+    };
+  };
+
+
   netlib = buildPythonPackage rec {
     baseName = "netlib";
-    name = "${baseName}-${meta.version}";
+    name = "${baseName}-${version}";
     disabled = (!isPy27);
+    version = "0.14.0";
 
     src = pkgs.fetchurl {
-      url = "https://github.com/cortesi/netlib/archive/v${meta.version}.tar.gz";
-      name = "${name}.tar.gz";
-      sha256 = "1x2n126b7fal64fb5fzkp4by7ym0iswn3w9mh6pm4c1vjdpnk592";
+      url = "https://pypi.python.org/packages/source/n/netlib/${name}.tar.gz";
+      sha256 = "0xcfjym780wjr32p3g50w2gifqy3589898idzd3fwgj93akv04ng";
     };
 
-    buildInputs = with self; [
-      pyopenssl pyasn1
-    ];
+    propagatedBuildInputs = with self; [ pyopenssl pyasn1 certifi passlib
+      ipaddress backports_ssl_match_hostname_3_4_0_2 hpack ];
 
     doCheck = false;
 
     meta = {
-      version = "0.10";
-      description = ''Man-in-the-middle proxy'';
+      description = "Man-in-the-middle proxy";
       homepage = "https://github.com/cortesi/netlib";
       license = licenses.mit;
     };
@@ -10211,6 +10378,8 @@ let
       sha256 = "00qymfgwg4iam4xi0w9bnv7lcb3fypq1hzfafzgs1rfmwaj67g3n";
     };
 
+    propagatedBuildInputs = [ self.coverage ];
+
     doCheck = false;  # lot's of transient errors, too much hassle
     checkPhase = if python.is_py3k or false then ''
       ${python}/bin/${python.executable} setup.py build_tests
@@ -10509,13 +10678,10 @@ let
 
     preConfigure = ''
       sed -i 's/-faltivec//' numpy/distutils/system_info.py
-      sed -i '0,/from numpy.distutils.core/s//import setuptools;from numpy.distutils.core/' setup.py
     '';
 
     inherit (support) preBuild checkPhase;
 
-    setupPyBuildFlags = ["--fcompiler='gnu95'"];
-
     buildInputs = [ pkgs.gfortran self.nose ];
     propagatedBuildInputs = [ support.openblas ];
 
@@ -10667,7 +10833,7 @@ let
     };
   });
 
-  oauth2client = pythonPackages.buildPythonPackage rec {
+  oauth2client = buildPythonPackage rec {
     name = "oauth2client-1.4.12";
 
     src = pkgs.fetchurl {
@@ -10675,7 +10841,7 @@ let
       sha256 = "0phfk6s8bgpap5xihdk1xv2lakdk1pb3rg6hp2wsg94hxcxnrakl";
     };
 
-    propagatedBuildInputs = with pythonPackages; [ httplib2 pyasn1 pyasn1-modules rsa ];
+    propagatedBuildInputs = with self; [ six httplib2 pyasn1 pyasn1-modules rsa ];
     doCheck = false;
 
     meta = {
@@ -10717,6 +10883,10 @@ let
       sha256 = "16jb8x5hbs3g4dq10y6rqc1005bnffwnlws8x7j1d96n7k9mjn8h";
     };
 
+    patchPhase = ''
+      substituteInPlace setup.py --replace "version=versioneer.get_version()" "version='${version}'"
+    '';
+
     propagatedBuildInputs = with self;
       [ pyptlib argparse twisted pycrypto pyyaml ];
 
@@ -10877,12 +11047,11 @@ let
     disabled = isPy3k;
 
     src = pkgs.fetchgit {
-      url = git://gitorious.org/opensuse/osc.git;
+      url = https://github.com/openSUSE/osc;
       rev = "6cd541967ee2fca0b89e81470f18b97a3ffc23ce";
       sha256 = "a39ce0e321e40e9758bf7b9128d316c71b35b80eabc84f13df492083bb6f1cc6";
     };
 
-    buildPhase = "${python}/bin/${python.executable} setup.py build";
     doCheck = false;
     postInstall = "ln -s $out/bin/osc-wrapper.py $out/bin/osc";
 
@@ -10940,10 +11109,7 @@ let
       sed -i 's@python@${python.interpreter}@' os_testr/tests/files/testr-conf
     '';
 
-    # since tests depend on install results, let's do it so
-    doInstallCheck = true;
-    doCheck = false;
-    installCheckPhase = ''
+    checkPhase = ''
       export PATH=$PATH:$out/bin
       ${python.interpreter} setup.py test
     '';
@@ -10954,12 +11120,13 @@ let
 
   bandit = buildPythonPackage rec {
     name = "bandit-${version}";
-    version = "0.14.1";
-    disabled = isPyPy; # a test fails
+    version = "0.16.1";
+    disabled = isPy33;
+    doCheck = !isPyPy; # a test fails
 
     src = pkgs.fetchurl {
       url = "https://pypi.python.org/packages/source/b/bandit/${name}.tar.gz";
-      sha256 = "1hsc3qn3srzx76zl8z3hg0vjp8m6mk9ylfhhgw5bcwbjz3x82ifl";
+      sha256 = "0qd9kxknac5n5xfl5zjnlmk6jr94krkcx29zgyna8p9lyb828hsk";
     };
 
     propagatedBuildInputs = with self; [ pbr six pyyaml appdirs stevedore ];
@@ -11123,6 +11290,10 @@ let
        sha256 = "0wf0k9xf5xzmi79418xq8zxwr7w7a4g4alv3dds9afb2l8bh9crg";
      };
 
+     patchPhase = ''
+       sed -i "s/test_gather_stats/noop/" futurist/tests/test_executors.py
+     '';
+
      propagatedBuildInputs = with self; [
        contextlib2 pbr six monotonic futures eventlet
      ];
@@ -11216,7 +11387,7 @@ let
     };
 
     propagatedBuildInputs = with self; [
-      six Babel simplejson requests keystoneclient prettytable argparse pbr
+      six Babel simplejson requests2 keystoneclient prettytable argparse pbr
     ];
     buildInputs = with self; [
       testrepository requests-mock
@@ -11508,9 +11679,7 @@ let
       sha256 = "1nw827iz5g9jlfnfbdi8kva565v0kdjzba2lccziimj09r71w900";
     };
 
-    doInstallCheck = true;
-    doCheck = false;
-    installCheckPhase = ''
+    checkPhase = ''
       # remove turbogears tests as we don't have it packaged
       rm tests/test_tg*
       # remove flask since we don't have flask-restful
@@ -11552,9 +11721,7 @@ let
       rm taskflow/tests/unit/test_engines.py
     '';
 
-    doInstallCheck = true;
-    doCheck = false;
-    installCheckPhase = ''
+    checkPhase = ''
       sed -i '/doc8/d' test-requirements.txt
       ${python.interpreter} setup.py test
     '';
@@ -11932,7 +12099,7 @@ let
       sha256 = "19krvycaiximchhv1hcfhz81249m3w3jrbp2h4apn1yf4yrc4y7y";
     };
 
-    propagatedBuildInputs = with self; [ eventlet trollius ];
+    propagatedBuildInputs = with self; [ eventlet trollius asyncio ];
     buildInputs = with self; [ mock ];
 
     # 2 tests error out
@@ -12822,15 +12989,18 @@ let
 
   python-jenkins = buildPythonPackage rec {
     name = "python-jenkins-${version}";
-    version = "0.4.5";
+    version = "0.4.11";
     src = pkgs.fetchurl {
       url = "https://pypi.python.org/packages/source/p/python-jenkins/${name}.tar.gz";
-      md5 = "10f1c24d45afe9cadd43f8d60b37d04c";
+      sha256 = "153gm7pmmn0bymglsgcr2ya0752r2v1hajkx73gl1pk4jifb2gdf";
     };
+    patchPhase = ''
+      sed -i 's@python@${python.interpreter}@' .testr.conf
+    '';
 
-    buildInputs = with self; [ pbr pip ];
-    pythonPath = with self; [ pyyaml six ];
-    doCheck = false;
+    buildInputs = with self; [ mock ];
+    propagatedBuildInputs = with self; [ pbr pyyaml six multi_key_dict testtools
+     testscenarios testrepository ];
 
     meta = {
       description = "Python bindings for the remote Jenkins API";
@@ -12852,25 +13022,22 @@ let
     buildInputs = with self; [ python pkgs.libjpeg pkgs.zlib pkgs.freetype ];
 
     disabled = isPy3k;
-    doCheck = true;
 
-    postInstall = "ln -s $out/lib/${python.libPrefix}/site-packages $out/lib/${python.libPrefix}/site-packages/PIL";
+    postInstall = "ln -s $out/${python.sitePackages} $out/${python.sitePackages}/PIL";
 
     preConfigure = ''
       sed -i "setup.py" \
           -e 's|^FREETYPE_ROOT =.*$|FREETYPE_ROOT = libinclude("${pkgs.freetype}")|g ;
               s|^JPEG_ROOT =.*$|JPEG_ROOT = libinclude("${pkgs.libjpeg}")|g ;
               s|^ZLIB_ROOT =.*$|ZLIB_ROOT = libinclude("${pkgs.zlib}")|g ;'
-    ''
-    # Remove impurities
-    + stdenv.lib.optionalString stdenv.isDarwin ''
+    '' + stdenv.lib.optionalString stdenv.isDarwin ''
+      # Remove impurities
       substituteInPlace setup.py \
         --replace '"/Library/Frameworks",' "" \
         --replace '"/System/Library/Frameworks"' ""
     '';
 
-    checkPhase = "${python}/bin/${python.executable} selftest.py";
-    buildPhase = "${python}/bin/${python.executable} setup.py build_ext -i";
+    checkPhase = "${python.interpreter} selftest.py";
 
     meta = {
       homepage = http://www.pythonware.com/products/pil/;
@@ -13488,11 +13655,9 @@ let
     };
   };
 
-  pycosat = pythonPackages.buildPythonPackage rec {
+  pycosat = buildPythonPackage rec {
     name = "pycosat-0.6.0";
 
-    propagatedBuildInputs = with pythonPackages; [  ];
-
     src = pkgs.fetchurl {
       url = "https://pypi.python.org/packages/source/p/pycosat/${name}.tar.gz";
       sha256 = "02sdn2998jlrm35smn1530hix3kzwyc1jv49cjdcnvfvrqqi3rww";
@@ -13575,17 +13740,6 @@ let
         --replace '"/usr/lib"' '"${pkgs.binutils}/lib"'
     '';
 
-    # --old-and-unmanageable not supported by this setup.py
-    installPhase = ''
-      mkdir -p "$out/lib/${python.libPrefix}/site-packages"
-
-      export PYTHONPATH="$out/lib/${python.libPrefix}/site-packages:$PYTHONPATH"
-
-      ${python}/bin/${python.executable} setup.py install \
-        --install-lib=$out/lib/${python.libPrefix}/site-packages \
-        --prefix="$out"
-    '';
-
     meta = {
       homepage = https://github.com/Groundworkstech/pybfd;
       description = "A Python interface to the GNU Binary File Descriptor (BFD) library";
@@ -13613,7 +13767,7 @@ let
 
     makeFlags = [
       "USESELINUX=0"
-      "SITELIB=$(out)/lib/${python.libPrefix}/site-packages"
+      "SITELIB=$(out)/${python.sitePackages}"
     ];
 
     meta = {
@@ -13828,6 +13982,8 @@ let
 
     # Tests require a local instance of elasticsearch
     doCheck = false;
+    propagatedBuildInputs = with self; [ elasticsearch six simplejson certifi ];
+    buildInputs = with self; [ nose mock ];
 
     meta = {
       description = "A clean, future-proof, high-scale API to elasticsearch.";
@@ -13836,7 +13992,7 @@ let
     };
   });
 
-  pyenchant = pythonPackages.buildPythonPackage rec {
+  pyenchant = buildPythonPackage rec {
     name = "pyenchant-1.6.6";
 
     src = pkgs.fetchurl {
@@ -13844,7 +14000,7 @@ let
       md5 = "9f5acfd87d04432bf8df5f9710a17358";
     };
 
-    propagatedBuildInputs = with pythonPackages; [ pkgs.enchant ];
+    propagatedBuildInputs = [ pkgs.enchant ];
 
     patchPhase = let
       path_hack_script = "s|LoadLibrary(e_path)|LoadLibrary('${pkgs.enchant}/lib/' + e_path)|";
@@ -13945,7 +14101,7 @@ let
     };
   };
 
-  pygeoip = pythonPackages.buildPythonPackage rec {
+  pygeoip = buildPythonPackage rec {
     name = "pygeoip-0.3.2";
 
     src = pkgs.fetchurl {
@@ -14195,8 +14351,7 @@ let
     propagatedBuildInputs = with self; [ urlgrabber ];
 
     checkPhase = ''
-      export PYTHONPATH="$PYTHONPATH:."
-      ${python}/bin/${python.executable} tests/baseclass.py -vv
+      ${python.interpreter} tests/baseclass.py -vv
     '';
 
     meta = {
@@ -14456,7 +14611,8 @@ let
       url = "https://pypi.python.org/packages/source/p/python-fedora/${name}.tar.gz";
       sha256 = "15m8lvbb5q4rg508i4ah8my872qrq5xjwgcgca4d3kzjv2x6fhim";
     };
-    propagatedBuildInputs = with self; [ kitchen requests bunch paver ];
+    propagatedBuildInputs = with self; [ kitchen requests bunch paver six munch urllib3
+      beautifulsoup4 ];
     doCheck = false;
 
     # https://github.com/fedora-infra/python-fedora/issues/140
@@ -14618,14 +14774,7 @@ let
       sha256 = "1hmy76c5igm95rqbld7gvk0az24smvc8hplfwx2f5rhn6frj3p2i";
     };
 
-    configurePhase =  "make";
-
-    # Doesn't work with --old-and-unmanagable
-    installPhase = ''
-      ${python}/bin/${python.executable} setup.py install \
-        --install-lib=$out/lib/${python.libPrefix}/site-packages \
-        --prefix="$out"
-    '';
+    configurePhase = "make";
 
     doCheck = false;
 
@@ -14732,6 +14881,7 @@ let
     doCheck = false;
   };
 
+
   pyrax = buildPythonPackage rec {
     name = "pyrax-1.8.2";
 
@@ -14740,13 +14890,15 @@ let
       sha256 = "0hvim60bhgfj91m7pp8jfmb49f087xqlgkqa505zw28r7yl0hcfp";
     };
 
+    propagatedBuildInputs = with self; [ requests2 ];
+    doCheck = false;
+
     meta = {
+      broken = true;  # missing lots of dependencies with rackspace-novaclient
       homepage    = "https://github.com/rackspace/pyrax";
       license     = licenses.mit;
       description = "Python API to interface with Rackspace";
     };
-
-    doCheck = false;
   };
 
 
@@ -15526,18 +15678,133 @@ let
     };
   };
 
+  Whoosh = buildPythonPackage rec {
+    name = "Whoosh-${version}";
+    version = "2.7.0";
+
+    src = pkgs.fetchurl {
+      url = "https://pypi.python.org/packages/source/W/Whoosh/Whoosh-${version}.tar.gz";
+      sha256 = "1xx8rqk1v2xs7mxvy9q4sgz2qmgvhf6ygbqjng3pl83ka4f0xz6d";
+    };
+
+    propagatedBuildInputs = with self; [
+
+    ];
+    buildInputs = with self; [
+      pytest
+    ];
+
+    meta = with stdenv.lib; {
+      homepage = "http://bitbucket.org/mchaput/whoosh";
+    };
+  };
+
+  pysolr = buildPythonPackage rec {
+    name = "pysolr-${version}";
+    version = "3.3.3";
+
+    src = pkgs.fetchurl {
+      url = "https://pypi.python.org/packages/source/p/pysolr/pysolr-${version}.tar.gz";
+      sha256 = "1wapg9n7myn7c82r3nzs2gisfzx52nip8w2mrfy0yih1zn02mnd6";
+    };
+
+    propagatedBuildInputs = with self; [
+      requests2
+    ];
+    buildInputs = with self; [
+
+    ];
+
+    meta = with stdenv.lib; {
+      homepage = "http://github.com/toastdriven/pysolr/";
+    };
+  };
+
+
+  django-haystack = buildPythonPackage rec {
+    name = "django-haystack-${version}";
+    version = "2.4.1";
+
+    src = pkgs.fetchurl {
+      url = "https://pypi.python.org/packages/source/d/django-haystack/django-haystack-${version}.tar.gz";
+      sha256 = "04cva8qg79xig4zqhb4dwkpm7734dvhzqclzvrdz70fh59ki5b4f";
+    };
+
+    doCheck = false;  # no tests in source
+
+    buildInputs = with self; [ coverage mock nose geopy ];
+    propagatedBuildInputs = with self; [
+      django_1_6 dateutil_1_5 Whoosh pysolr elasticsearch
+    ];
+
+    patchPhase = ''
+      sed -i 's/geopy==/geopy>=/' setup.py
+      sed -i 's/whoosh==/Whoosh>=/' setup.py
+    '';
+
+    meta = with stdenv.lib; {
+      homepage = "http://haystacksearch.org/";
+    };
+  };
+
+  geopy = buildPythonPackage rec {
+    name = "geopy-${version}";
+    version = "1.11.0";
+    disabled = !isPy27;
+
+    src = pkgs.fetchurl {
+      url = "https://pypi.python.org/packages/source/g/geopy/geopy-${version}.tar.gz";
+      sha256 = "04j1lxcsfyv03h0n0q7p2ig7a4n13x4x20fzxn8bkazpx6lyal22";
+    };
+
+    doCheck = false;  # too much
+
+    buildInputs = with self; [ mock tox pkgs.pylint ];
+    meta = with stdenv.lib; {
+      homepage = "https://github.com/geopy/geopy";
+    };
+  };
+
+  django-multiselectfield = buildPythonPackage rec {
+    name = "django-multiselectfield-${version}";
+    version = "0.1.3";
+
+    src = pkgs.fetchurl {
+      url = "https://pypi.python.org/packages/source/d/django-multiselectfield/django-multiselectfield-${version}.tar.gz";
+      sha256 = "0v7wf82f8688srdsym9ajv1j54bxfxwvydypc03f8xyl4c1raziv";
+    };
+
+    propagatedBuildInputs = with self; [
+
+    ];
+    buildInputs = with self; [
+
+    ];
+
+    meta = with stdenv.lib; {
+      description = "django-multiselectfield";
+      homepage = "https://github.com/goinnn/django-multiselectfield";
+    };
+  };
+
+
   reviewboard = buildPythonPackage rec {
-    name = "ReviewBoard-1.6.22";
+    name = "ReviewBoard-2.5.1.1";
 
     src = pkgs.fetchurl {
-      url = "http://downloads.reviewboard.org/releases/ReviewBoard/1.6/${name}.tar.gz";
-      sha256 = "09lc3ccazlyyd63ifxw3w4kzwd60ax2alk1a95ih6da4clg73mxf";
+      url = "http://downloads.reviewboard.org/releases/ReviewBoard/2.5/${name}.tar.gz";
+      sha256 = "14m8yy2aqxnnzi822b797wc9nmkfkp2fqmq24asdnm66bxhyzjwn";
     };
 
+    patchPhase = ''
+      sed -i 's/mimeparse/python-mimeparse/' setup.py
+      sed -i 's/markdown>=2.4.0,<2.4.999/markdown/' setup.py
+    '';
+
     propagatedBuildInputs = with self;
-      [ django_1_3 recaptcha_client pytz memcached dateutil_1_5 paramiko flup pygments
-        djblets django_evolution pycrypto modules.sqlite3
-        pysvn pil psycopg2
+      [ django_1_6 recaptcha_client pytz memcached dateutil_1_5 paramiko flup
+        pygments djblets django_evolution pycrypto modules.sqlite3 pysvn pillow
+        psycopg2 django-haystack python_mimeparse markdown django-multiselectfield
       ];
   };
 
@@ -15553,7 +15820,7 @@ let
     # error: invalid command 'test'
     doCheck = false;
 
-    propagatedBuildInputs = with self; [ isodate ];
+    propagatedBuildInputs = with self; [ isodate html5lib SPARQLWrapper ];
 
     meta = {
       description = "A Python library for working with RDF, a simple yet powerful language for representing information";
@@ -15804,8 +16071,6 @@ let
 
     patches = [ ../development/python-modules/rpkg-buildfix.diff ];
 
-    # buildPhase = "python setup.py build";
-    # doCheck = false;
     propagatedBuildInputs = with self; [ pycurl pkgs.koji GitPython pkgs.git
                               pkgs.rpm pkgs.pyopenssl ];
 
@@ -15948,9 +16213,7 @@ let
       sha256 = "05qf0m32isflln1zjgxlpw0wf469lj86vdwwqyizp1h94x5l22ji";
     };
 
-    doInstallCheck = true;
-    doCheck = false;
-    installCheckPhase = ''
+    checkPhase = ''
       # this test takes too long
       sed -i 's/test_big_file/noop/' test/test_sendfile.py
       ${self.python.executable} test/test_sendfile.py
@@ -16071,23 +16334,19 @@ let
 
   scikitlearn = buildPythonPackage rec {
     name = "scikit-learn-${version}";
-    version = "0.17b1";
+    version = "0.17";
     disabled = stdenv.isi686;  # https://github.com/scikit-learn/scikit-learn/issues/5534
 
     src = pkgs.fetchurl {
       url = "https://github.com/scikit-learn/scikit-learn/archive/${version}.tar.gz";
-      sha256 = "b5965c888ae44fe3f5a1b15297e5d8e254a41d1848df99e00efc2fc643e6e8f2";
+      sha256 = "9946ab26bec8ba771a366c6c496514e37da88b9cb4cd05b3bb1c031eb1da1168";
     };
 
     buildInputs = with self; [ nose pillow pkgs.gfortran pkgs.glibcLocales ];
     propagatedBuildInputs = with self; [ numpy scipy pkgs.openblas ];
 
-    buildPhase = ''
-      ${self.python.interpreter} setup.py build_ext -i --fcompiler='gnu95'
-    '';
-
     checkPhase = ''
-      LC_ALL="en_US.UTF-8" HOME=$TMPDIR OMP_NUM_THREADS=1 nosetests
+      LC_ALL="en_US.UTF-8" HOME=$TMPDIR OMP_NUM_THREADS=1 nosetests $out/${python.sitePackages}/sklearn/
     '';
 
     meta = {
@@ -16174,10 +16433,6 @@ let
 
     buildInputs = with self; [ pip ];
 
-    preBuild = ''
-      ${python.interpreter} setup.py egg_info
-    '';
-
     meta = with stdenv.lib; {
       homepage = https://bitbucket.org/pypa/setuptools_scm/;
       description = "Handles managing your python package versions in scm metadata";
@@ -16186,23 +16441,27 @@ let
     };
   };
 
-  setuptoolsDarcs = buildPythonPackage {
-    name = "setuptools-darcs-1.2.9";
+  setuptoolsDarcs = buildPythonPackage rec {
+    name = "setuptools_darcs-${version}";
+    version = "1.2.11";
 
     src = pkgs.fetchurl {
-      url = "http://pypi.python.org/packages/source/s/setuptools_darcs/setuptools_darcs-1.2.9.tar.gz";
-      sha256 = "d37ce11030addbd729284c441facd0869cdc6e5c888dc5fa0a6f1edfe3c3e617";
+      url = "http://pypi.python.org/packages/source/s/setuptools_darcs/${name}.tar.gz";
+      sha256 = "1wsh0g1fn10msqk87l5jrvzs0yj5mp6q9ld3gghz6zrhl9kqzdn1";
     };
 
     # In order to break the dependency on darcs -> ghc, we don't add
     # darcs as a propagated build input.
     propagatedBuildInputs = with self; [ darcsver ];
 
-    meta = {
-      description = "setuptools plugin for the Darcs version control system";
+    # ugly hack to specify version that should otherwise come from darcs
+    patchPhase = ''
+      substituteInPlace setup.py --replace "name=PKG" "name=PKG, version='${version}'"
+    '';
 
+    meta = {
+      description = "Setuptools plugin for the Darcs version control system";
       homepage = http://allmydata.org/trac/setuptools_darcs;
-
       license = "BSD";
     };
   };
@@ -16304,6 +16563,8 @@ let
       sha256 = "1n8msk71lpl3kv086xr2sv68ppgz6228575xfnbszc6p1mwr64rg";
     };
 
+    doCheck = false;  # weird error
+
     meta = {
       description = "A Parser Generator for Python";
       homepage = https://pypi.python.org/pypi/SimpleParse;
@@ -16541,18 +16802,24 @@ let
   };
 
   clint = buildPythonPackage rec {
-    name = "clint-0.4.1";
+    name = "clint-0.5.1";
 
     src = pkgs.fetchurl {
       url = "http://pypi.python.org/packages/source/c/clint/${name}.tar.gz";
-      md5 = "d0a0952bfcc5f4c5e03c36854665b298";
+      sha256 = "1an5lkkqk1zha47198p42ji3m94xmzx1a03dn7866m87n4r4q8h5";
     };
 
+
+    preBuild = ''
+      export LC_ALL="en_US.UTF-8"
+    '';
+
     checkPhase = ''
-      nosetests
+      ${python.interpreter} test_clint.py
     '';
 
-    buildInputs = with self; [ pillow nose_progressive nose mock blessings nose ];
+    buildInputs = with self; [ mock blessings nose nose_progressive pkgs.glibcLocales ];
+    propagatedBuildInputs = with self; [ pillow blessings args ];
 
     meta = {
       maintainers = with maintainers; [ iElectric ];
@@ -16707,19 +16974,14 @@ let
     version = "2.5.1";
     disabled = isPy3k;
 
-    configurePhase = "find -name 'configure' -exec chmod a+x {} \\; ; find -name 'aconfigure' -exec chmod a+x {} \\; ; ${python}/bin/${python.executable} setup.py build_ext --pjsip-clean-compile";
-
     src = pkgs.fetchurl {
       url = "http://download.ag-projects.com/SipClient/python-${name}.tar.gz";
       sha256 = "0vpy2vss8667c0kp1k8vybl38nxp7kr2v2wa8sngrgzd65m6ww5p";
     };
 
     propagatedBuildInputs = with self; [ cython pkgs.openssl dns dateutil xcaplib msrplib lxml ];
-
     buildInputs = with pkgs; [ alsaLib ffmpeg libv4l pkgconfig sqlite libvpx ];
 
-    installPhase = "${python}/bin/${python.executable} setup.py install --prefix=$out";
-
     doCheck = false;
   };
 
@@ -16852,20 +17114,14 @@ let
 
     buildInputs = [ pkgs.bash ];
 
-    doCheck = !isPyPy;
-
     preConfigure = ''
       substituteInPlace test_subprocess32.py \
         --replace '/usr/' '${pkgs.bash}/'
     '';
 
+    doCheck = !isPyPy;
     checkPhase = ''
-      TMP_PREFIX=`pwd`/tmp/$name
-      TMP_INSTALL_DIR=$TMP_PREFIX/lib/${pythonPackages.python.libPrefix}/site-packages
-      PYTHONPATH="$TMP_INSTALL_DIR:$PYTHONPATH"
-      mkdir -p $TMP_INSTALL_DIR
-      python setup.py develop --prefix $TMP_PREFIX
-      python test_subprocess32.py
+      ${python.interpreter} test_subprocess32.py
     '';
 
     meta = {
@@ -17101,7 +17357,7 @@ let
   };
 
 
-  sqlalchemy_migrate = buildPythonPackage rec {
+  sqlalchemy_migrate_func = sqlalchemy: buildPythonPackage rec {
     name = "sqlalchemy-migrate-0.10.0";
 
     src = pkgs.fetchurl {
@@ -17110,11 +17366,9 @@ let
     };
 
     buildInputs = with self; [ unittest2 scripttest pytz pkgs.pylint tempest-lib mock testtools ];
-    propagatedBuildInputs = with self; [ pbr tempita decorator sqlalchemy_1_0 six sqlparse ];
+    propagatedBuildInputs = with self; [ pbr tempita decorator sqlalchemy six sqlparse ];
 
-    doInstallCheck = true;
-    doCheck = false;
-    installCheckPhase = ''
+    checkPhase = ''
       export PATH=$PATH:$out/bin
       echo sqlite:///__tmp__ > test_db.cfg
       # depends on ibm_db_sa
@@ -17132,6 +17386,8 @@ let
     };
   };
 
+  sqlalchemy_migrate = self.sqlalchemy_migrate_func self.sqlalchemy_1_0;
+  sqlalchemy_migrate_0_7 = self.sqlalchemy_migrate_func self.sqlalchemy;
 
   sqlparse = buildPythonPackage rec {
     name = "sqlparse-${version}";
@@ -17432,14 +17688,15 @@ let
 
     disabled = isPy3k;
 
-    propagatedBuildInputs = with self; [ pkgs.syncthing pygobject3 dateutil pkgs.gtk3 pyinotify pkgs.libnotify pkgs.psmisc ];
+    propagatedBuildInputs = with self; [ pkgs.syncthing dateutil pyinotify pkgs.libnotify pkgs.psmisc
+      pygobject3 pkgs.gtk3 ];
 
     patchPhase = ''
       substituteInPlace "scripts/syncthing-gtk" \
-              --replace "/usr/share" "$out/share"   \
+              --replace "/usr/share" "$out/share"
+      substituteInPlace setup.py --replace "version = get_version()" "version = '${version}'"
     '';
 
-
     meta = {
       description = " GTK3 & python based GUI for Syncthing ";
       maintainers = with maintainers; [ DamienCassou ];
@@ -17759,11 +18016,11 @@ let
   };
 
   texttable = self.buildPythonPackage rec {
-    name = "texttable-0.8.1";
+    name = "texttable-0.8.4";
 
     src = pkgs.fetchurl {
       url = "https://pypi.python.org/packages/source/t/texttable/${name}.tar.gz";
-      md5 = "4fe37704f16ecf424b91e122defedd7e";
+      sha256 = "0bkhs4dx9s6g7fpb969hygq56hyz4ncfamlynw72s0n6nqfbd1w5";
     };
 
     meta = {
@@ -18067,16 +18324,12 @@ let
 
     meta = {
       homepage = http://twistedmatrix.com/;
-
       description = "Twisted, an event-driven networking engine written in Python";
-
       longDescription = ''
         Twisted is an event-driven networking engine written in Python
         and licensed under the MIT license.
       '';
-
       license = licenses.mit;
-
       maintainers = [ ];
     };
   };
@@ -18149,9 +18402,11 @@ let
     # # 1.0.0 and up create a circle dependency with traceback2/pbr
     doCheck = false;
 
-    # fixes a transient error when collecting tests, see https://bugs.launchpad.net/python-neutronclient/+bug/1508547
     patchPhase = ''
+      # # fixes a transient error when collecting tests, see https://bugs.launchpad.net/python-neutronclient/+bug/1508547
       sed -i '510i\        return None, False' unittest2/loader.py
+      # https://github.com/pypa/packaging/pull/36
+      sed -i 's/version=VERSION/version=str(VERSION)/' setup.py
     '';
 
     propagatedBuildInputs = with self; [ six argparse traceback2 ];
@@ -18209,7 +18464,7 @@ let
       sha256 = "0f2lyi7xhvb60pvzx82dpc13ksdj5k92ww09czclkdz8k0dxa7hb";
     };
 
-    propagatedBuildInputs = with pythonPackages; [
+    propagatedBuildInputs = with self; [
       pyperclip
       urwid
     ];
@@ -18223,15 +18478,15 @@ let
     };
   };
 
-  update_checker = pythonPackages.buildPythonPackage rec {
+  update_checker = buildPythonPackage rec {
     name = "update_checker-0.11";
 
     src = pkgs.fetchurl {
-      url = "https://pypi.python.org/packages/source/u/update_checker/update_checker-0.11.tar.gz";
+      url = "https://pypi.python.org/packages/source/u/update_checker/${name}.tar.gz";
       md5 = "1daa54bac316be6624d7ee77373144bb";
     };
 
-    propagatedBuildInputs = with pythonPackages; [ requests2 ];
+    propagatedBuildInputs = with self; [ requests2 ];
 
     doCheck = false;
 
@@ -18660,7 +18915,7 @@ let
 
 
 
-  willie = pythonPackages.buildPythonPackage rec {
+  willie = buildPythonPackage rec {
     name = "willie-5.2.0";
 
     src = pkgs.fetchurl {
@@ -18668,7 +18923,7 @@ let
       md5 = "a19f8c34e10e3c2d0d915c894224e521";
     };
 
-    propagatedBuildInputs = with pythonPackages; [ feedparser pytz lxml praw pyenchant pygeoip backports_ssl_match_hostname_3_4_0_2 ];
+    propagatedBuildInputs = with self; [ feedparser pytz lxml praw pyenchant pygeoip backports_ssl_match_hostname_3_4_0_2 ];
 
     meta = {
       description = "A simple, lightweight, open source, easy-to-use IRC utility bot, written in Python";
@@ -18836,18 +19091,15 @@ let
     # Tests require `pyutil' so disable them to avoid circular references.
     doCheck = false;
 
-    buildInputs = with self; [ setuptoolsDarcs ];
+    propagatedBuildInputs = with self; [ setuptoolsDarcs ];
 
     meta = {
       description = "zbase32, a base32 encoder/decoder";
-
       homepage = http://pypi.python.org/pypi/zbase32;
-
       license = "BSD";
     };
   });
 
-
   zconfig = buildPythonPackage rec {
     name = "zconfig-${version}";
     version = "3.0.3";
@@ -19446,11 +19698,11 @@ let
 
   zope_testrunner = buildPythonPackage rec {
     name = "zope.testrunner-${version}";
-    version = "4.4.3";
+    version = "4.4.10";
 
     src = pkgs.fetchurl {
       url = "http://pypi.python.org/packages/source/z/zope.testrunner/${name}.zip";
-      sha256 = "1dwk35kg0bmj2lzp4fd2bgp6dv64q5sda09bf0y8j63y53vqbsw8";
+      sha256 = "1w09wbqiqmq6hvrammi4fzc7fr129v63gdnzlk4qi2b1xy5qpqab";
     };
 
     propagatedBuildInputs = with self; [ zope_interface zope_exceptions zope_testing six ] ++ optional (!python.is_py3k or false) subunit;
@@ -19507,18 +19759,18 @@ let
   };
 
   hgsvn = buildPythonPackage rec {
-    name = "hgsvn-0.3.5";
+    name = "hgsvn-0.3.11";
     src = pkgs.fetchurl rec {
-      url = "http://pypi.python.org/packages/source/h/hgsvn/${name}.zip";
-      sha256 = "043yvkjf9hgm0xzhmwj1qk3fsmbgwm39f4wsqkscib9wfvxs8wbg";
+      url = "https://pypi.python.org/packages/source/h/hgsvn/${name}-hotfix.zip";
+      sha256 = "0yvhwdh8xx8rvaqd3pnnyb99hfa0zjdciadlc933p27hp9rf880p";
     };
     disabled = isPy3k || isPyPy;
+    doCheck = false;  # too many assumptions
 
-    buildInputs = with self; [ pkgs.setuptools ];
-    doCheck = false;
+    buildInputs = with self; [ nose ];
+    propagatedBuildInputs = with self; [ hglib ];
 
-      meta = {
-      description = "HgSVN";
+    meta = {
       homepage = http://pypi.python.org/pypi/hgsvn;
     };
   };
@@ -19717,8 +19969,11 @@ let
       url = "http://pypi.python.org/packages/source/p/pyzmq/${name}.tar.gz";
       sha256 = "1gbpgz4ngfw5x6zlsa1k0jwy5vd5wg9iz1shdx4zav256ib08vjx";
     };
-    buildInputs = with self; [ pkgs.zeromq3 ];
-    doCheck = false;
+    buildInputs = with self; [ pkgs.zeromq3 pytest];
+    propagatedBuildInputs = [ self.py ];
+    checkPhase = ''
+      py.test $out/${python.sitePackages}/zmq/
+    '';
   };
 
   tokenserver = buildPythonPackage rec {
@@ -19732,18 +19987,29 @@ let
     };
 
     doCheck = false;
+    buildInputs = [ self.testfixtures ];
     propagatedBuildInputs = with self; [ cornice mozsvc pybrowserid tokenlib ];
 
-    patchPhase = ''
-      sed -i "s|'testfixtures'||" setup.py
-    '';
-
     meta = {
-      maintainers = [ ];
       platforms = platforms.all;
     };
   };
 
+  testfixtures = buildPythonPackage rec {
+    name = "testfixtures-${version}";
+    version = "4.5.0";
+
+    src = pkgs.fetchurl {
+      url = "https://pypi.python.org/packages/source/t/testfixtures/testfixtures-${version}.tar.gz";
+      sha256 = "0my8zq9d27mc7j78pz9971cn5wz6zi4vxlqa50szr2vq9j2xxkll";
+    };
+
+
+    meta = with stdenv.lib; {
+      homepage = "https://github.com/Simplistix/testfixtures";
+    };
+  };
+
   tissue = buildPythonPackage rec {
     name = "tissue-0.9.2";
     src = pkgs.fetchurl {
@@ -20034,7 +20300,7 @@ let
 
   };
 
-  veryprettytable = pythonPackages.buildPythonPackage rec {
+  veryprettytable = buildPythonPackage rec {
     name = "veryprettytable-${version}";
     version = "0.8.1";
 
@@ -20061,7 +20327,7 @@ let
       md5 = "8edbb61f1ffe11c181bd2cb9ec977c72";
     };
 
-    propagatedBuildInputs = with self; [ django_1_3 django_tagging modules.sqlite3 whisper pkgs.pycairo ldap memcached ];
+    propagatedBuildInputs = with self; [ django_1_5 django_tagging modules.sqlite3 whisper pkgs.pycairo ldap memcached ];
 
     postInstall = ''
       wrapProgram $out/bin/run-graphite-devel-server.py \
@@ -20741,7 +21007,8 @@ let
   serversyncstorage = buildPythonPackage rec {
     name = "serversyncstorage-${version}";
     version = "1.5.11";
-    disabled = ! isPy27;
+    disabled = !isPy27;
+
     src = pkgs.fetchgit {
       url = https://github.com/mozilla-services/server-syncstorage.git;
       rev = "refs/tags/${version}";
@@ -20750,12 +21017,33 @@ let
 
     propagatedBuildInputs = with self; [
       pyramid sqlalchemy9 simplejson mozsvc cornice pyramid_hawkauth pymysql
-      pymysqlsa umemcache wsgiproxy2 requests pybrowserid
+      pymysqlsa umemcache WSGIProxy requests pybrowserid
     ];
+    buildInputs = with self; [ testfixtures unittest2  ];
 
-    doCheck = false; # lazy packager
+    #doCheck = false; # lazy packager
   };
 
+  WSGIProxy = buildPythonPackage rec {
+    name = "WSGIProxy-${version}";
+    version = "0.2.2";
+
+    src = pkgs.fetchurl {
+      url = "https://pypi.python.org/packages/source/W/WSGIProxy/WSGIProxy-${version}.tar.gz";
+      sha256 = "0wqz1q8cvb81a37gb4kkxxpv4w7k8192a08qzyz67rn68ln2wcig";
+    };
+
+    propagatedBuildInputs = with self; [
+      paste six
+    ];
+
+    meta = with stdenv.lib; {
+      description = "WSGIProxy gives tools to proxy arbitrary(ish) WSGI requests to other";
+      homepage = "http://pythonpaste.org/wsgiproxy/";
+    };
+  };
+
+
 
   thumbor = buildPythonPackage rec {
     name = "thumbor-${version}";
@@ -20895,16 +21183,14 @@ let
   };
 
   html2text = buildPythonPackage rec {
-    name = "html2text-2014.12.29";
+    name = "html2text-2015.11.4";
     disabled = ! isPy27;
 
     src = pkgs.fetchurl {
-      url = "https://pypi.python.org/packages/source/h/html2text/html2text-2014.12.29.tar.gz";
-      md5 = "c5bd796bdf7d1bfa43f55f1e2b5e4826";
+      url = "https://pypi.python.org/packages/source/h/html2text/${name}.tar.gz";
+      sha256 = "021pqcshxajhdy4whkawz95v98m8njv5lknzgac0sp8jzl01qls4";
     };
 
-    propagatedBuildInputs = with pythonPackages; [  ];
-
     meta = {
       homepage = https://github.com/Alir3z4/html2text/;
     };
@@ -21348,17 +21634,18 @@ let
   };
 
   jenkins-job-builder = buildPythonPackage rec {
-    name = "jenkins-job-builder-1.2.0";
+    name = "jenkins-job-builder-1.3.0";
     disabled = ! (isPy26 || isPy27);
 
     src = pkgs.fetchurl {
       url = "https://pypi.python.org/packages/source/j/jenkins-job-builder/${name}.tar.gz";
-      md5 = "79e44ef0d3fffc19f415d8c0caac6b7b";
+      sha256 = "111vpf6hzzb2mcdqi0a9r1dkf28ln9w6sgfqri0qxwf1ffbdqx6x";
     };
 
-    # pbr required for jenkins-job-builder is <1.0.0 while many of the test
-    # dependencies require pbr>=1.1
-    doCheck = false;
+    patchPhase = ''
+      sed -i '/ordereddict/d' requirements.txt
+      export HOME=$TMPDIR
+    '';
 
     buildInputs = with self; [
       pip
@@ -21366,10 +21653,12 @@ let
 
     propagatedBuildInputs = with self; [
       pbr
+      mock
       python-jenkins
       pyyaml
       six
     ] ++ optionals isPy26 [
+      ordereddict
       argparse
       ordereddict
     ];
@@ -21782,4 +22071,4 @@ let
     };
   };
 
-}; in pythonPackages
+}
diff --git a/pkgs/top-level/release-python.nix b/pkgs/top-level/release-python.nix
index a7d3194cdbb6..79bbd9d21a0d 100644
--- a/pkgs/top-level/release-python.nix
+++ b/pkgs/top-level/release-python.nix
@@ -1,70 +1,26 @@
 /*
    test for example like this
-   $ nix-build pkgs/top-level/release-python.nix
+   $ hydra-eval-jobs pkgs/top-level/release-python.nix
 */
 
 { nixpkgs ? { outPath = (import ./all-packages.nix {}).lib.cleanSource ../..; revCount = 1234; shortRev = "abcdef"; }
 , officialRelease ? false
 , # The platforms for which we build Nixpkgs.
-  supportedSystems ? [ "x86_64-linux" "i686-linux" "x86_64-darwin" "x86_64-freebsd" "i686-freebsd" ]
+  supportedSystems ? [ "x86_64-linux" ]
 }:
 
+with import ../../lib;
 with import ./release-lib.nix {inherit supportedSystems; };
 
 let
-  jobsForDerivations = attrset: pkgs.lib.attrsets.listToAttrs
-    (map
-      (name: { inherit name;
-               value = { type = "job"; systems = ["x86_64-linux"]; schedulingPriority = 4; };})
-      (builtins.attrNames
-        (pkgs.lib.attrsets.filterAttrs
-          (n: v: (v.type or null) == "derivation")
-          attrset)));
-
-
-  jobs =
-    {
-
-   # } // (mapTestOn ((packagesWithMetaPlatform pkgs) // rec {
-
-    } // (mapTestOn rec {
-
-  offlineimap = { type = "job"; systems = ["x86_64-linux"]; schedulingPriority = 4; };  
-  pycairo = { type = "job"; systems = ["x86_64-linux"]; schedulingPriority = 4; };
-  pycrypto = { type = "job"; systems = ["x86_64-linux"]; schedulingPriority = 4; };
-  pycups = { type = "job"; systems = ["x86_64-linux"]; schedulingPriority = 4; };
-  pydb = { type = "job"; systems = ["x86_64-linux"]; schedulingPriority = 4; };
-  pyexiv2 = { type = "job"; systems = ["x86_64-linux"]; schedulingPriority = 4; };
-  pygame = { type = "job"; systems = ["x86_64-linux"]; schedulingPriority = 4; };
-  pygobject = { type = "job"; systems = ["x86_64-linux"]; schedulingPriority = 4; };
-  pygtk = { type = "job"; systems = ["x86_64-linux"]; schedulingPriority = 4; };
-  pygtksourceview = { type = "job"; systems = ["x86_64-linux"]; schedulingPriority = 4; };
-  pyGtkGlade = { type = "job"; systems = ["x86_64-linux"]; schedulingPriority = 4; };
-  pyIRCt = { type = "job"; systems = ["x86_64-linux"]; schedulingPriority = 4; };
-  pyMAILt = { type = "job"; systems = ["x86_64-linux"]; schedulingPriority = 4; };
-  pyopenssl = { type = "job"; systems = ["x86_64-linux"]; schedulingPriority = 4; };
-  pyqt4 = { type = "job"; systems = ["x86_64-linux"]; schedulingPriority = 4; };
-  pyrex = { type = "job"; systems = ["x86_64-linux"]; schedulingPriority = 4; };
-  pyrex096 = { type = "job"; systems = ["x86_64-linux"]; schedulingPriority = 4; };
-  pyside = { type = "job"; systems = ["x86_64-linux"]; schedulingPriority = 4; };
-  pysideApiextractor = { type = "job"; systems = ["x86_64-linux"]; schedulingPriority = 4; };
-  pysideGeneratorrunner = { type = "job"; systems = ["x86_64-linux"]; schedulingPriority = 4; };
-  pysideShiboken = { type = "job"; systems = ["x86_64-linux"]; schedulingPriority = 4; };
-  pysideTools = { type = "job"; systems = ["x86_64-linux"]; schedulingPriority = 4; };
-  pystringtemplate = { type = "job"; systems = ["x86_64-linux"]; schedulingPriority = 4; };
-  python26 = { type = "job"; systems = ["x86_64-linux"]; schedulingPriority = 4; };
-  python27 = { type = "job"; systems = ["x86_64-linux"]; schedulingPriority = 4; };
-  python26Full = { type = "job"; systems = ["x86_64-linux"]; schedulingPriority = 4; };
-  python27Full = { type = "job"; systems = ["x86_64-linux"]; schedulingPriority = 4; };
-  python26Packages = jobsForDerivations pkgs.python26Packages;
-  python27Packages = jobsForDerivations pkgs.python27Packages;
-  python3 = { type = "job"; systems = ["x86_64-linux"]; schedulingPriority = 4; };
-  pythonDBus = { type = "job"; systems = ["x86_64-linux"]; schedulingPriority = 4; };
-  pythonIRClib = { type = "job"; systems = ["x86_64-linux"]; schedulingPriority = 4; };
-  pythonmagick = { type = "job"; systems = ["x86_64-linux"]; schedulingPriority = 4; };
-  pythonSexy = { type = "job"; systems = ["x86_64-linux"]; schedulingPriority = 4; };
-  pyx = { type = "job"; systems = ["x86_64-linux"]; schedulingPriority = 4; };
-  pyxml = { type = "job"; systems = ["x86_64-linux"]; schedulingPriority = 4; };
-});
-
-in jobs
+  packagePython = mapAttrs (name: value:
+    let res = builtins.tryEval (
+      if isDerivation value then
+        value.meta.isBuildPythonPackage or []
+      else if value.recurseForDerivations or false || value.recurseForRelease or false then
+        packagePython value
+      else
+        []);
+    in if res.success then res.value else []
+    );
+in (mapTestOn (packagePython pkgs))