pythonPackages: use mkPythonDerivation

This commit is contained in:
Frederik Rietdijk 2016-08-31 11:01:16 +02:00
parent e9c4d00cac
commit 4f6b6f1472
13 changed files with 56 additions and 65 deletions

View File

@ -536,6 +536,7 @@ All parameters from `mkDerivation` function are still supported.
* `installFlags`: A list of strings. Arguments to be passed to `pip install`. To pass options to `python setup.py install`, use `--install-option`. E.g., `installFlags=["--install-option='--cpp_implementation'"]. * `installFlags`: A list of strings. Arguments to be passed to `pip install`. To pass options to `python setup.py install`, use `--install-option`. E.g., `installFlags=["--install-option='--cpp_implementation'"].
* `format`: Format of the source. Options are `setup` for when the source has a `setup.py` and `setuptools` is used to build a wheel, and `wheel` in case the source is already a binary wheel. The default value is `setup`. * `format`: Format of the source. Options are `setup` for when the source has a `setup.py` and `setuptools` is used to build a wheel, and `wheel` in case the source is already a binary wheel. The default value is `setup`.
* `catchConflicts` If `true`, abort package build if a package name appears more than once in dependency tree. Default is `true`. * `catchConflicts` If `true`, abort package build if a package name appears more than once in dependency tree. Default is `true`.
* `checkInputs` Dependencies needed for running the `checkPhase`. These are added to `buildInputs` when `doCheck = true`.
#### `buildPythonApplication` function #### `buildPythonApplication` function

View File

@ -13,8 +13,13 @@
# by default prefix `name` e.g. "python3.3-${name}" # by default prefix `name` e.g. "python3.3-${name}"
, namePrefix ? python.libPrefix + "-" , namePrefix ? python.libPrefix + "-"
# Dependencies for building the package
, buildInputs ? [] , buildInputs ? []
# Dependencies needed for running the checkPhase.
# These are added to buildInputs when doCheck = true.
, checkInputs ? []
# propagate build dependencies so in case we have A -> B -> C, # propagate build dependencies so in case we have A -> B -> C,
# C can import package A propagated by B # C can import package A propagated by B
, propagatedBuildInputs ? [] , propagatedBuildInputs ? []
@ -52,7 +57,8 @@ python.stdenv.mkDerivation (builtins.removeAttrs attrs ["disabled"] // {
buildInputs = [ wrapPython ] ++ buildInputs ++ pythonPath buildInputs = [ wrapPython ] ++ buildInputs ++ pythonPath
++ [ (ensureNewerSourcesHook { year = "1980"; }) ] ++ [ (ensureNewerSourcesHook { year = "1980"; }) ]
++ (lib.optional (lib.hasSuffix "zip" attrs.src.name or "") unzip); ++ (lib.optional (lib.hasSuffix "zip" attrs.src.name or "") unzip)
++ lib.optionals attrs.doCheck checkInputs;
# propagate python/setuptools to active setup-hook in nix-shell # propagate python/setuptools to active setup-hook in nix-shell
propagatedBuildInputs = propagatedBuildInputs ++ [ python setuptools ]; propagatedBuildInputs = propagatedBuildInputs ++ [ python setuptools ];

View File

@ -1,7 +1,7 @@
{ stdenv, fetchurl, python, pkgconfig, dbus, dbus_glib, dbus_tools, isPyPy { lib, fetchurl, mkPythonDerivation, python, pkgconfig, dbus, dbus_glib, dbus_tools, isPyPy
, ncurses, pygobject3 }: , ncurses, pygobject3 }:
if isPyPy then throw "dbus-python not supported for interpreter ${python.executable}" else stdenv.mkDerivation rec { if isPyPy then throw "dbus-python not supported for interpreter ${python.executable}" else mkPythonDerivation rec {
name = "dbus-python-1.2.4"; name = "dbus-python-1.2.4";
src = fetchurl { src = fetchurl {
@ -11,21 +11,17 @@ if isPyPy then throw "dbus-python not supported for interpreter ${python.executa
postPatch = "patchShebangs ."; postPatch = "patchShebangs .";
buildInputs = [ python pkgconfig dbus dbus_glib ] buildInputs = [ pkgconfig dbus dbus_glib ]
++ stdenv.lib.optionals doCheck [ dbus_tools pygobject3 ] ++ lib.optionals doCheck [ dbus_tools pygobject3 ]
# My guess why it's sometimes trying to -lncurses. # My guess why it's sometimes trying to -lncurses.
# It seems not to retain the dependency anyway. # It seems not to retain the dependency anyway.
++ stdenv.lib.optional (! python ? modules) ncurses; ++ lib.optional (! python ? modules) ncurses;
doCheck = true; doCheck = true;
# Set empty pythonPath, so that the package is recognized as a python package
# for python.buildEnv
pythonPath = [];
meta = { meta = {
description = "Python DBus bindings"; description = "Python DBus bindings";
license = stdenv.lib.licenses.mit; license = lib.licenses.mit;
platforms = dbus.meta.platforms; platforms = dbus.meta.platforms;
}; };
} }

View File

@ -1,6 +1,6 @@
{ stdenv, fetchurl, fetchpatch, python, pkgconfig, cairo, xlibsWrapper, isPyPy, isPy35 }: { lib, fetchurl, fetchpatch, python, mkPythonDerivation, pkgconfig, cairo, xlibsWrapper, isPyPy, isPy35 }:
if (isPyPy) then throw "pycairo not supported for interpreter ${python.executable}" else stdenv.mkDerivation rec { if (isPyPy) then throw "pycairo not supported for interpreter ${python.executable}" else mkPythonDerivation rec {
version = "1.10.0"; version = "1.10.0";
name = "${python.libPrefix}-pycairo-${version}"; name = "${python.libPrefix}-pycairo-${version}";
src = if python.is_py3k or false src = if python.is_py3k or false
@ -32,7 +32,7 @@ if (isPyPy) then throw "pycairo not supported for interpreter ${python.executabl
cd $(${python.executable} waf unpack) cd $(${python.executable} waf unpack)
pwd pwd
patch -p1 < ${patch_waf} patch -p1 < ${patch_waf}
${stdenv.lib.optionalString isPy35 "patch -p1 < ${patch_waf-py3_5}"} ${lib.optionalString isPy35 "patch -p1 < ${patch_waf-py3_5}"}
) )
${python.executable} waf configure --prefix=$out ${python.executable} waf configure --prefix=$out
@ -40,5 +40,5 @@ if (isPyPy) then throw "pycairo not supported for interpreter ${python.executabl
buildPhase = "${python.executable} waf"; buildPhase = "${python.executable} waf";
installPhase = "${python.executable} waf install"; installPhase = "${python.executable} waf install";
meta.platforms = stdenv.lib.platforms.linux ++ stdenv.lib.platforms.darwin; meta.platforms = lib.platforms.linux ++ lib.platforms.darwin;
} }

View File

@ -1,6 +1,6 @@
{ stdenv, fetchurl, python, pkgconfig, glib, gobjectIntrospection, pycairo, cairo }: { lib, fetchurl, mkPythonDerivation, python, pkgconfig, glib, gobjectIntrospection, pycairo, cairo }:
stdenv.mkDerivation rec { mkPythonDerivation rec {
major = "3.20"; major = "3.20";
minor = "0"; minor = "0";
name = "pygobject-${major}.${minor}"; name = "pygobject-${major}.${minor}";
@ -10,14 +10,12 @@ stdenv.mkDerivation rec {
sha256 = "0ikzh3l7g1gjh8jj8vg6mdvrb25svp63gxcam4m0i404yh0lgari"; sha256 = "0ikzh3l7g1gjh8jj8vg6mdvrb25svp63gxcam4m0i404yh0lgari";
}; };
buildInputs = [ python pkgconfig glib gobjectIntrospection ]; buildInputs = [ pkgconfig glib gobjectIntrospection ];
propagatedBuildInputs = [ pycairo cairo ]; propagatedBuildInputs = [ pycairo cairo ];
passthru.pythonPath = [];
meta = { meta = {
homepage = http://live.gnome.org/PyGObject; homepage = http://live.gnome.org/PyGObject;
description = "Python bindings for Glib"; description = "Python bindings for Glib";
platforms = stdenv.lib.platforms.unix; platforms = lib.platforms.unix;
}; };
} }

View File

@ -1,6 +1,6 @@
{ stdenv, fetchurl, python, pkgconfig, glib }: { stdenv, fetchurl, python, mkPythonDerivation, pkgconfig, glib }:
stdenv.mkDerivation rec { mkPythonDerivation rec {
name = "pygobject-2.28.6"; name = "pygobject-2.28.6";
src = fetchurl { src = fetchurl {
@ -18,9 +18,7 @@ stdenv.mkDerivation rec {
configureFlags = "--disable-introspection"; configureFlags = "--disable-introspection";
buildInputs = [ python pkgconfig glib ]; buildInputs = [ pkgconfig glib ];
passthru.pythonPath = [];
# in a "normal" setup, pygobject and pygtk are installed into the # in a "normal" setup, pygobject and pygtk are installed into the
# same site-packages: we need a pth file for both. pygtk.py would be # same site-packages: we need a pth file for both. pygtk.py would be

View File

@ -1,8 +1,8 @@
{ stdenv, fetchurl, python, pkgconfig, pygobject, glib, pygtk, gnome2 }: { lib, fetchurl, python, mkPythonDerivation, pkgconfig, pygobject, glib, pygtk, gnome2 }:
let version = "2.10.1"; in let version = "2.10.1"; in
stdenv.mkDerivation { mkPythonDerivation {
name = "pygtksourceview-${version}"; name = "pygtksourceview-${version}";
src = fetchurl { src = fetchurl {
@ -15,6 +15,6 @@ stdenv.mkDerivation {
buildInputs = [ python pkgconfig pygobject glib pygtk gnome2.gtksourceview ]; buildInputs = [ python pkgconfig pygobject glib pygtk gnome2.gtksourceview ];
meta = { meta = {
platforms = stdenv.lib.platforms.unix; platforms = lib.platforms.unix;
}; };
} }

View File

@ -1,10 +1,10 @@
{ stdenv, fetchurl, pythonPackages, qt4, pkgconfig, lndir, dbus_libs, makeWrapper }: { lib, fetchurl, pythonPackages, qt4, pkgconfig, lndir, dbus_libs, makeWrapper }:
let let
version = "4.11.3"; version = "4.11.3";
inherit (pythonPackages) python dbus-python sip; inherit (pythonPackages) mkPythonDerivation python dbus-python sip;
in stdenv.mkDerivation { in mkPythonDerivation {
name = "${python.libPrefix}-PyQt-x11-gpl-${version}"; name = "$PyQt-x11-gpl-${version}";
src = fetchurl { src = fetchurl {
url = "mirror://sourceforge/pyqt/PyQt4/PyQt-${version}/PyQt-x11-gpl-${version}.tar.gz"; url = "mirror://sourceforge/pyqt/PyQt4/PyQt-${version}/PyQt-x11-gpl-${version}.tar.gz";
@ -31,7 +31,7 @@ in stdenv.mkDerivation {
buildInputs = [ pkgconfig makeWrapper qt4 lndir dbus_libs ]; buildInputs = [ pkgconfig makeWrapper qt4 lndir dbus_libs ];
propagatedBuildInputs = [ sip python ]; propagatedBuildInputs = [ sip ];
postInstall = '' postInstall = ''
for i in $out/bin/*; do for i in $out/bin/*; do
@ -42,7 +42,6 @@ in stdenv.mkDerivation {
enableParallelBuilding = true; enableParallelBuilding = true;
passthru = { passthru = {
pythonPath = [];
qt = qt4; qt = qt4;
}; };
@ -50,7 +49,7 @@ in stdenv.mkDerivation {
description = "Python bindings for Qt"; description = "Python bindings for Qt";
license = "GPL"; license = "GPL";
homepage = http://www.riverbankcomputing.co.uk; homepage = http://www.riverbankcomputing.co.uk;
maintainers = [ stdenv.lib.maintainers.sander ]; maintainers = [ lib.maintainers.sander ];
platforms = stdenv.lib.platforms.mesaPlatforms; platforms = lib.platforms.mesaPlatforms;
}; };
} }

View File

@ -1,13 +1,13 @@
{ stdenv, fetchurl, pythonPackages, pkgconfig, qtbase, qtsvg, qtwebkit, dbus_libs { lib, fetchurl, pythonPackages, pkgconfig, qtbase, qtsvg, qtwebkit, dbus_libs
, lndir, makeWrapper, qmakeHook }: , lndir, makeWrapper, qmakeHook }:
let let
version = "5.6"; version = "5.6";
inherit (pythonPackages) python dbus-python sip; inherit (pythonPackages) mkPythonDerivation python dbus-python sip;
in stdenv.mkDerivation { in mkPythonDerivation {
name = "${python.libPrefix}-PyQt-${version}"; name = "PyQt-${version}";
meta = with stdenv.lib; { meta = with lib; {
description = "Python bindings for Qt5"; description = "Python bindings for Qt5";
homepage = http://www.riverbankcomputing.co.uk; homepage = http://www.riverbankcomputing.co.uk;
license = licenses.gpl3; license = licenses.gpl3;
@ -25,7 +25,7 @@ in stdenv.mkDerivation {
qtbase qtsvg qtwebkit dbus_libs qmakeHook qtbase qtsvg qtwebkit dbus_libs qmakeHook
]; ];
propagatedBuildInputs = [ sip python ]; propagatedBuildInputs = [ sip ];
configurePhase = '' configurePhase = ''
runHook preConfigure runHook preConfigure
@ -60,6 +60,4 @@ in stdenv.mkDerivation {
''; '';
enableParallelBuilding = true; enableParallelBuilding = true;
passthru.pythonPath = [];
} }

View File

@ -1,6 +1,6 @@
{ stdenv, fetchurl, cmake, python, pysideGeneratorrunner, pysideShiboken, qt4 }: { stdenv, fetchurl, cmake, python, pysideGeneratorrunner, pysideShiboken, qt4 }:
stdenv.mkDerivation rec { stdenv.mkPythonDerivation rec {
name = "${python.libPrefix}-pyside-${version}"; name = "${python.libPrefix}-pyside-${version}";
version = "1.2.4"; version = "1.2.4";

View File

@ -1,22 +1,21 @@
{stdenv, fetchurl, python, makeWrapper}: {lib, fetchurl, python, mkPythonDerivation, makeWrapper}:
stdenv.mkDerivation rec { mkPythonDerivation rec {
name = "PyXML-0.8.4"; name = "PyXML-0.8.4";
src = fetchurl { src = fetchurl {
url = "mirror://sourceforge/pyxml/${name}.tar.gz"; url = "mirror://sourceforge/pyxml/${name}.tar.gz";
sha256 = "04wc8i7cdkibhrldy6j65qp5l75zjxf5lx6qxdxfdf2gb3wndawz"; sha256 = "04wc8i7cdkibhrldy6j65qp5l75zjxf5lx6qxdxfdf2gb3wndawz";
}; };
buildInputs = [python makeWrapper]; buildInputs = [ makeWrapper ];
buildPhase = "python ./setup.py build"; buildPhase = "${python.interpreter} ./setup.py build";
installPhase = '' installPhase = ''
python ./setup.py install --prefix="$out" || exit 1 ${python.interpreter} ./setup.py install --prefix="$out" || exit 1
for i in "$out/bin/"* for i in "$out/bin/"*
do do
# FIXME: We're assuming Python 2.4.
wrapProgram "$i" --prefix PYTHONPATH : \ wrapProgram "$i" --prefix PYTHONPATH : \
"$out/lib/python2.4/site-packages" || \ "$out/${python.sitePackages}" || \
exit 2 exit 2
done done
''; '';

View File

@ -1,6 +1,6 @@
{ stdenv, fetchurl, python, isPyPy }: { lib, fetchurl, mkPythonDerivation, python, isPyPy }:
if isPyPy then throw "sip not supported for interpreter ${python.executable}" else stdenv.mkDerivation rec { if isPyPy then throw "sip not supported for interpreter ${python.executable}" else mkPythonDerivation rec {
name = "sip-4.18.1"; name = "sip-4.18.1";
src = fetchurl { src = fetchurl {
@ -14,11 +14,7 @@ if isPyPy then throw "sip not supported for interpreter ${python.executable}" el
-b $out/bin -e $out/include -b $out/bin -e $out/include
''; '';
buildInputs = [ python ]; meta = with lib; {
passthru.pythonPath = [];
meta = with stdenv.lib; {
description = "Creates C++ bindings for Python modules"; description = "Creates C++ bindings for Python modules";
homepage = "http://www.riverbankcomputing.co.uk/"; homepage = "http://www.riverbankcomputing.co.uk/";
license = licenses.gpl2Plus; license = licenses.gpl2Plus;

View File

@ -20192,7 +20192,7 @@ in modules // {
}); });
pysvn = pkgs.stdenv.mkDerivation rec { pysvn = mkPythonDerivation rec {
name = "pysvn-1.8.0"; name = "pysvn-1.8.0";
src = pkgs.fetchurl { src = pkgs.fetchurl {
@ -20200,7 +20200,7 @@ in modules // {
sha256 = "0srjr2qgxfs69p65d9vvdib2lc142x10w8afbbdrqs7dhi46yn9r"; sha256 = "0srjr2qgxfs69p65d9vvdib2lc142x10w8afbbdrqs7dhi46yn9r";
}; };
buildInputs = with self; [ python pkgs.subversion pkgs.apr pkgs.aprutil pkgs.expat pkgs.neon pkgs.openssl ] buildInputs = with self; [ pkgs.subversion pkgs.apr pkgs.aprutil pkgs.expat pkgs.neon pkgs.openssl ]
++ (if stdenv.isLinux then [pkgs.e2fsprogs] else []); ++ (if stdenv.isLinux then [pkgs.e2fsprogs] else []);
# There seems to be no way to pass that path to configure. # There seems to be no way to pass that path to configure.
@ -20346,7 +20346,7 @@ in modules // {
}); });
pywebkitgtk = stdenv.mkDerivation rec { pywebkitgtk = mkPythonDerivation rec {
name = "pywebkitgtk-${version}"; name = "pywebkitgtk-${version}";
version = "1.1.8"; version = "1.1.8";
@ -20677,14 +20677,14 @@ in modules // {
qscintilla = if isPy3k || isPyPy qscintilla = if isPy3k || isPyPy
then throw "qscintilla-${pkgs.qscintilla.version} not supported for interpreter ${python.executable}" then throw "qscintilla-${pkgs.qscintilla.version} not supported for interpreter ${python.executable}"
else pkgs.stdenv.mkDerivation rec { else mkPythonDerivation rec {
# TODO: Qt5 support # TODO: Qt5 support
name = "qscintilla-${version}"; name = "qscintilla-${version}";
version = pkgs.qscintilla.version; version = pkgs.qscintilla.version;
src = pkgs.qscintilla.src; src = pkgs.qscintilla.src;
buildInputs = with self; [ pkgs.xorg.lndir pyqt4.qt pyqt4 python ]; buildInputs = with self; [ pkgs.xorg.lndir pyqt4.qt pyqt4 ];
preConfigure = '' preConfigure = ''
mkdir -p $out mkdir -p $out