pythonPackages: syntax improvements

- import pkgs.lib by default, there's no reason why not
- Define `isPy*` helper functions for all python versions
- Define `pythonName` that returns unique python name based on `isPy*`
  helpers
- Fix `python2.7` version detection
- Fix pythonPackages importing(with) for `python2.7` only packages
This commit is contained in:
Jaka Hudoklin 2014-03-10 10:29:03 +01:00
parent 0558c87288
commit a33891973a
2 changed files with 77 additions and 66 deletions

View File

@ -6075,7 +6075,6 @@ let
# regardless.
python26Packages = import ./python-packages.nix {
inherit pkgs;
inherit (lib) lowPrio;
python = python26;
};
@ -6083,31 +6082,26 @@ let
python33Packages = recurseIntoAttrs (import ./python-packages.nix {
inherit pkgs;
inherit (lib) lowPrio;
python = python33;
});
python34Packages = import ./python-packages.nix {
inherit pkgs;
inherit (lib) lowPrio;
python = python34;
};
python32Packages = import ./python-packages.nix {
inherit pkgs;
inherit (lib) lowPrio;
python = python32;
};
python27Packages = recurseIntoAttrs (import ./python-packages.nix {
inherit pkgs;
inherit (lib) lowPrio;
python = python27;
});
pypyPackages = recurseIntoAttrs (import ./python-packages.nix {
inherit pkgs;
inherit (lib) lowPrio;
python = pypy;
});

View File

@ -1,24 +1,38 @@
{ pkgs, python, lowPrio }:
{ pkgs, python }:
with pkgs.lib;
let
isPy26 = python.majorVersion == "2.6";
isPy27 = python.majorVersion == "2.7";
optional = pkgs.lib.optional;
optionals = pkgs.lib.optionals;
modules = python.modules or { readline = null; sqlite3 = null; curses = null; curses_panel = null; ssl = null; crypt = null; };
isPy26 = python.majorVersion == "2.6";
isPy27 = python.majorVersion == "2.7";
isPy33 = python.majorVersion == "3.3";
isPy34 = python.majorVersion == "3.4";
isPyPy = python.executable == "pypy";
# Unique python version identifier
pythonName =
if isPy26 then "python26" else
if isPy27 then "python27" else
if isPy33 then "python33" else
if isPy34 then "python34" else
if isPyPy then "pypy" else "";
modules = python.modules or { readline = null; sqlite3 = null; curses = null; curses_panel = null; ssl = null; crypt = null; };
pythonPackages = modules // import ./python-packages-generated.nix {
inherit pkgs python;
inherit (pkgs) stdenv fetchurl;
self = pythonPackages;
} // rec {
} //
inherit python;
# Python packages for all python versions
rec {
inherit python isPy26 isPy27 isPy33 isPy34 isPyPy pythonName;
inherit (pkgs) fetchurl fetchsvn fetchgit stdenv unzip;
# helpers
callPackage = pkgs.lib.callPackageWith (pkgs // pythonPackages);
callPackage = callPackageWith (pkgs // pythonPackages);
# global distutils config used by buildPythonPackage
distutils-cfg = callPackage ../development/python-modules/distutils-cfg { };
@ -554,7 +568,7 @@ pythonPackages = modules // import ./python-packages-generated.nix {
meta = {
homepage = http://beets.radbox.org;
description = "Music tagger and library organizer";
license = pkgs.lib.licenses.mit;
license = licenses.mit;
maintainers = [ stdenv.lib.maintainers.iElectric ];
};
};
@ -575,7 +589,7 @@ pythonPackages = modules // import ./python-packages-generated.nix {
meta = {
homepage = https://github.com/Sheeprider/BitBucket-api;
description = "Python library to interact with BitBucket REST API";
license = pkgs.lib.licenses.mit;
license = licenses.mit;
};
};
@ -767,7 +781,7 @@ pythonPackages = modules // import ./python-packages-generated.nix {
meta = {
homepage = "http://www.buildout.org";
description = "A software build and configuration system";
license = pkgs.lib.licenses.zpt21;
license = licenses.zpt21;
maintainers = [ stdenv.lib.maintainers.garbas ];
};
};
@ -782,7 +796,7 @@ pythonPackages = modules // import ./python-packages-generated.nix {
meta = {
homepage = "http://www.buildout.org";
description = "A software build and configuration system";
license = pkgs.lib.licenses.zpt21;
license = licenses.zpt21;
maintainers = [ stdenv.lib.maintainers.garbas ];
};
};
@ -803,7 +817,7 @@ pythonPackages = modules // import ./python-packages-generated.nix {
meta = {
homepage = "http://www.buildout.org";
description = "A software build and configuration system";
license = pkgs.lib.licenses.zpt21;
license = licenses.zpt21;
maintainers = [ stdenv.lib.maintainers.garbas ];
};
};
@ -981,7 +995,7 @@ pythonPackages = modules // import ./python-packages-generated.nix {
meta = {
description = "Simple, lightweight, and easily extensible STOMP message broker";
homepage = http://code.google.com/p/coilmq/;
license = pkgs.lib.licenses.asl20;
license = licenses.asl20;
};
});
@ -1023,7 +1037,7 @@ pythonPackages = modules // import ./python-packages-generated.nix {
meta = {
description = "Autogenerate Colander schemas based on SQLAlchemy models.";
homepage = https://github.com/stefanofontanelli/ColanderAlchemy;
license = pkgs.lib.licenses.mit;
license = licenses.mit;
};
};
@ -1042,7 +1056,7 @@ pythonPackages = modules // import ./python-packages-generated.nix {
meta = {
description = "Config file reading, writing and validation.";
homepage = http://pypi.python.org/pypi/configobj;
license = pkgs.lib.licenses.bsd3;
license = licenses.bsd3;
maintainers = [ stdenv.lib.maintainers.garbas ];
};
});
@ -1102,7 +1116,7 @@ pythonPackages = modules // import ./python-packages-generated.nix {
meta = {
description = "Code coverage measurement for python";
homepage = http://nedbatchelder.com/code/coverage/;
license = pkgs.lib.licenses.bsd3;
license = licenses.bsd3;
};
};
@ -2738,7 +2752,7 @@ pythonPackages = modules // import ./python-packages-generated.nix {
meta = {
description = "code checking using pep8 and pyflakes.";
homepage = http://pypi.python.org/pypi/flake8;
license = pkgs.lib.licenses.mit;
license = licenses.mit;
maintainers = [ stdenv.lib.maintainers.garbas ];
};
});
@ -3216,7 +3230,7 @@ pythonPackages = modules // import ./python-packages-generated.nix {
meta = {
homepage = http://code.google.com/p/httplib2;
description = "A comprehensive HTTP client library";
license = pkgs.lib.licenses.mit;
license = licenses.mit;
maintainers = [ stdenv.lib.maintainers.garbas ];
};
};
@ -3278,7 +3292,7 @@ pythonPackages = modules // import ./python-packages-generated.nix {
meta = {
description = "Google's IP address manipulation library";
homepage = http://code.google.com/p/ipaddr-py/;
license = pkgs.lib.licenses.asl20;
license = licenses.asl20;
};
};
@ -3312,7 +3326,7 @@ pythonPackages = modules // import ./python-packages-generated.nix {
meta = {
homepage = "https://github.com/davidhalter/jedi";
description = "An autocompletion tool for Python that can be used for text editors.";
license = pkgs.lib.licenses.lgpl3Plus;
license = licenses.lgpl3Plus;
maintainers = [ stdenv.lib.maintainers.garbas ];
};
});
@ -3402,7 +3416,7 @@ pythonPackages = modules // import ./python-packages-generated.nix {
meta = {
homepage = http://code.google.com/p/pylast/;
description = "A python interface to last.fm (and compatibles)";
license = pkgs.lib.licenses.asl20;
license = licenses.asl20;
};
};
@ -3687,7 +3701,7 @@ pythonPackages = modules // import ./python-packages-generated.nix {
meta = {
description = "McCabe checker, plugin for flake8";
homepage = "https://github.com/flintwork/mccabe";
license = pkgs.lib.licenses.mit;
license = licenses.mit;
maintainers = [ stdenv.lib.maintainers.garbas ];
};
});
@ -3790,7 +3804,7 @@ pythonPackages = modules // import ./python-packages-generated.nix {
version = "0.9";
description = ''Man-in-the-middle proxy'';
homepage = "http://mitmproxy.org/";
license = pkgs.lib.licenses.mit;
license = licenses.mit;
};
};
@ -3892,7 +3906,7 @@ pythonPackages = modules // import ./python-packages-generated.nix {
meta = {
homepage = http://bmc.github.com/munkres/;
description = "Munkres algorithm for the Assignment Problem";
license = pkgs.lib.licenses.bsd3;
license = licenses.bsd3;
maintainers = [ stdenv.lib.maintainers.iElectric ];
};
};
@ -3909,7 +3923,7 @@ pythonPackages = modules // import ./python-packages-generated.nix {
meta = {
homepage = http://alastair/python-musicbrainz-ngs;
description = "Python bindings for musicbrainz NGS webservice";
license = pkgs.lib.licenses.bsd2;
license = licenses.bsd2;
maintainers = [ stdenv.lib.maintainers.iElectric ];
};
};
@ -4078,7 +4092,7 @@ pythonPackages = modules // import ./python-packages-generated.nix {
version = "0.9";
description = ''Man-in-the-middle proxy'';
homepage = "https://github.com/cortesi/netlib";
license = pkgs.lib.licenses.mit;
license = licenses.mit;
};
};
@ -4223,7 +4237,7 @@ pythonPackages = modules // import ./python-packages-generated.nix {
sha256 = "1kh4spwgqxm534qlzzf2ijchckvs0pwjxl1irhicjmlg7mybnfvx";
};
patches = pkgs.lib.singleton (fetchurl {
patches = singleton (fetchurl {
name = "libnotify07.patch";
url = "http://pkgs.fedoraproject.org/cgit/notify-python.git/plain/"
+ "libnotify07.patch?id2=289573d50ae4838a1658d573d2c9f4c75e86db0c";
@ -4336,7 +4350,7 @@ pythonPackages = modules // import ./python-packages-generated.nix {
meta = {
homepage = "https://github.com/simplegeo/python-oauth2";
description = "library for OAuth version 1.0";
license = pkgs.lib.licenses.mit;
license = licenses.mit;
maintainers = [ stdenv.lib.maintainers.garbas ];
platforms = stdenv.lib.platforms.linux;
};
@ -4601,7 +4615,7 @@ pythonPackages = modules // import ./python-packages-generated.nix {
meta = {
homepage = "http://pep8.readthedocs.org/";
description = "Python style guide checker";
license = pkgs.lib.licenses.mit;
license = licenses.mit;
maintainers = [ stdenv.lib.maintainers.garbas ];
};
};
@ -4751,7 +4765,7 @@ pythonPackages = modules // import ./python-packages-generated.nix {
meta = {
description = "A library to manipulate gettext files (po and mo files)";
homepage = "http://bitbucket.org/izi/polib/";
license = pkgs.lib.licenses.mit;
license = licenses.mit;
};
};
@ -4875,7 +4889,7 @@ pythonPackages = modules // import ./python-packages-generated.nix {
meta = {
description = "Allows to get the public suffix of a domain name";
homepage = "http://pypi.python.org/pypi/publicsuffix/";
license = pkgs.lib.licenses.mit;
license = licenses.mit;
};
};
@ -5128,7 +5142,7 @@ pythonPackages = modules // import ./python-packages-generated.nix {
meta = {
homepage = "https://launchpad.net/pyflakes";
description = "A simple program which checks Python source files for errors.";
license = pkgs.lib.licenses.mit;
license = licenses.mit;
maintainers = [ stdenv.lib.maintainers.garbas ];
};
};
@ -5143,7 +5157,7 @@ pythonPackages = modules // import ./python-packages-generated.nix {
patchPhase = let
libs = [ pkgs.mesa pkgs.xlibs.libX11 pkgs.freetype pkgs.fontconfig ];
paths = pkgs.lib.concatStringsSep "," (map (l: "\"${l}/lib\"") libs);
paths = concatStringsSep "," (map (l: "\"${l}/lib\"") libs);
in "sed -i -e 's|directories\.extend.*lib[^]]*|&,${paths}|' pyglet/lib.py";
doCheck = false;
@ -5188,7 +5202,7 @@ pythonPackages = modules // import ./python-packages-generated.nix {
meta = {
homepage = "https://launchpad.net/pygpgme";
description = "A Python wrapper for the GPGME library.";
license = pkgs.lib.licenses.lgpl21;
license = licenses.lgpl21;
maintainers = [ stdenv.lib.maintainers.garbas ];
};
};
@ -5213,7 +5227,7 @@ pythonPackages = modules // import ./python-packages-generated.nix {
meta = {
homepage = https://github.com/seb-m/pyinotify/wiki;
description = "Monitor filesystems events on Linux platforms with inotify";
license = pkgs.lib.licenses.mit;
license = licenses.mit;
};
};
@ -5243,7 +5257,7 @@ pythonPackages = modules // import ./python-packages-generated.nix {
meta = {
homepage = "http://fedoraproject.org/wiki/Pykickstart";
description = "Read and write Fedora kickstart files";
license = pkgs.lib.licenses.gpl2Plus;
license = licenses.gpl2Plus;
};
};
@ -5300,7 +5314,7 @@ pythonPackages = modules // import ./python-packages-generated.nix {
sed -i -e '
s|e\.path\.startswith("/tmp/temp-device-")|"temp-device-" in e.path|
' tests/test__ped_ped.py
'' + pkgs.lib.optionalString stdenv.isi686 ''
'' + optionalString stdenv.isi686 ''
# remove some integers in this test case which overflow on 32bit systems
sed -i -r -e '/class *UnitGetSizeTestCase/,/^$/{/[0-9]{11}/d}' \
tests/test__ped_ped.py
@ -5825,7 +5839,7 @@ pythonPackages = modules // import ./python-packages-generated.nix {
reportlab =
let freetype = pkgs.lib.overrideDerivation pkgs.freetype (args: { configureFlags = "--enable-static --enable-shared"; });
let freetype = overrideDerivation pkgs.freetype (args: { configureFlags = "--enable-static --enable-shared"; });
in buildPythonPackage rec {
name = "reportlab-2.5";
@ -6623,7 +6637,7 @@ pythonPackages = modules // import ./python-packages-generated.nix {
meta = {
description = "Joyent SmartDataCenter CloudAPI connector using http-signature authentication via Requests";
homepage = https://github.com/atl/py-smartdc;
license = pkgs.lib.licenses.mit;
license = licenses.mit;
};
};
@ -6811,7 +6825,7 @@ pythonPackages = modules // import ./python-packages-generated.nix {
meta = {
homepage = https://github.com/crosspop/sqlalchemy-imageattach;
description = "SQLAlchemy extension for attaching images to entity objects";
license = pkgs.lib.licenses.mit;
license = licenses.mit;
};
};
@ -6857,7 +6871,7 @@ pythonPackages = modules // import ./python-packages-generated.nix {
meta = {
description = "A client for Etsy's node-js statsd server";
homepage = https://github.com/WoLpH/python-statsd;
license = pkgs.lib.licenses.bsd3;
license = licenses.bsd3;
};
};
@ -6877,7 +6891,7 @@ pythonPackages = modules // import ./python-packages-generated.nix {
meta = {
description = "Lightweight and extensible STOMP messaging client";
homepage = http://bitbucket.org/hozn/stompclient;
license = pkgs.lib.licenses.asl20;
license = licenses.asl20;
};
});
@ -6896,7 +6910,7 @@ pythonPackages = modules // import ./python-packages-generated.nix {
meta = {
description = "A streaming protocol for test results";
homepage = https://launchpad.net/subunit;
license = pkgs.lib.licenses.asl20;
license = licenses.asl20;
};
};
@ -7014,7 +7028,7 @@ pythonPackages = modules // import ./python-packages-generated.nix {
meta = {
description = "A set of extensions to the Python standard library's unit testing framework";
homepage = http://pypi.python.org/pypi/testtools;
license = pkgs.lib.licenses.mit;
license = licenses.mit;
};
};
@ -7034,7 +7048,7 @@ pythonPackages = modules // import ./python-packages-generated.nix {
meta = {
description = "A module provides basic functions for parsing mime-type names and matching them against a list of media-ranges.";
homepage = https://code.google.com/p/mimeparse/;
license = pkgs.lib.licenses.mit;
license = licenses.mit;
};
};
@ -7054,7 +7068,7 @@ pythonPackages = modules // import ./python-packages-generated.nix {
meta = {
description = "A module provides basic functions for parsing mime-type names and matching them against a list of media-ranges.";
homepage = https://code.google.com/p/mimeparse/;
license = pkgs.lib.licenses.mit;
license = licenses.mit;
};
};
@ -7165,7 +7179,7 @@ pythonPackages = modules // import ./python-packages-generated.nix {
meta = {
homepage = "https://github.com/alejandrogomez/turses";
description = "A Twitter client for the console.";
license = pkgs.lib.licenses.gpl3;
license = licenses.gpl3;
maintainers = [ stdenv.lib.maintainers.garbas ];
platforms = stdenv.lib.platforms.linux;
};
@ -7182,7 +7196,7 @@ pythonPackages = modules // import ./python-packages-generated.nix {
meta = {
homepage = "https://github.com/tweepy/tweepy";
description = "Twitter library for python";
license = pkgs.lib.licenses.mit;
license = licenses.mit;
maintainers = [ stdenv.lib.maintainers.garbas ];
platforms = stdenv.lib.platforms.linux;
};
@ -7216,7 +7230,7 @@ pythonPackages = modules // import ./python-packages-generated.nix {
and licensed under the MIT license.
'';
license = pkgs.lib.licenses.mit;
license = licenses.mit;
maintainers = [ ];
};
@ -7285,7 +7299,7 @@ pythonPackages = modules // import ./python-packages-generated.nix {
description = "A full-featured console (xterm et al.) user interface library";
homepage = http://excess.org/urwid;
repositories.git = git://github.com/wardi/urwid.git;
license = pkgs.lib.licenses.lgpl21;
license = licenses.lgpl21;
maintainers = [ stdenv.lib.maintainers.garbas ];
};
});
@ -7485,7 +7499,7 @@ pythonPackages = modules // import ./python-packages-generated.nix {
wokkel = buildPythonPackage (rec {
url = "http://wokkel.ik.nu/releases/0.7.0/wokkel-0.7.0.tar.gz";
name = pkgs.lib.nameFromURL url ".tar";
name = nameFromURL url ".tar";
src = fetchurl {
inherit url;
sha256 = "0rnshrzw8605x05mpd8ndrx3ri8h6cx713mp8sl4f04f4gcrz8ml";
@ -8395,7 +8409,7 @@ pythonPackages = modules // import ./python-packages-generated.nix {
meta = {
homepage = http://pypi.python.org/pypi/Unidecode/;
description = "ASCII transliterations of Unicode text";
license = pkgs.lib.licenses.gpl2;
license = licenses.gpl2;
maintainers = [ stdenv.lib.maintainers.iElectric ];
};
};
@ -8557,7 +8571,7 @@ pythonPackages = modules // import ./python-packages-generated.nix {
meta = {
homepage = https://code.google.com/p/gdata-python-client/;
description = "Python client library for Google data APIs";
license = pkgs.lib.licenses.asl20;
license = licenses.asl20;
};
};
@ -8577,7 +8591,7 @@ pythonPackages = modules // import ./python-packages-generated.nix {
meta = {
homepage = http://imapclient.freshfoo.com/;
description = "Easy-to-use, Pythonic and complete IMAP client library";
license = pkgs.lib.licenses.bsd3;
license = licenses.bsd3;
};
};
@ -8594,7 +8608,7 @@ pythonPackages = modules // import ./python-packages-generated.nix {
meta = {
homepage = http://pythonhosted.org/Logbook/;
description = "A logging replacement for Python";
license = pkgs.lib.licenses.bsd3;
license = licenses.bsd3;
};
};
@ -8691,8 +8705,11 @@ pythonPackages = modules // import ./python-packages-generated.nix {
};
};
# python2.7 specific eggs
} // pkgs.lib.optionalAttrs (python.majorVersion == "2.7") {
# python2.7 specific packages
} // optionalAttrs isPy27 (
with pythonPackages;
{
pypi2nix = pythonPackages.buildPythonPackage rec {
rev = "04a68d8577acbceb88bdf51b1231a9dbdead7003";
@ -8713,4 +8730,4 @@ pythonPackages = modules // import ./python-packages-generated.nix {
};
};
}; in pythonPackages
}); in pythonPackages