3
0
Fork 0
forked from mirrors/nixpkgs

Merge pull request #18143 from FRidh/buildpythonpackage

Python: split buildPythonPackage into two functions
This commit is contained in:
Frederik Rietdijk 2016-09-01 16:17:04 +02:00 committed by GitHub
commit 2a3077d2cc
20 changed files with 224 additions and 186 deletions

View file

@ -481,7 +481,7 @@ and the aliases
#### `buildPythonPackage` function #### `buildPythonPackage` function
The `buildPythonPackage` function is implemented in The `buildPythonPackage` function is implemented in
`pkgs/development/python-modules/generic/default.nix` `pkgs/development/interpreters/python/build-python-package.nix`
and can be used as: and can be used as:
@ -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

@ -3,57 +3,37 @@
(http://pypi.python.org/pypi/setuptools/), which represents a large (http://pypi.python.org/pypi/setuptools/), which represents a large
number of Python packages nowadays. */ number of Python packages nowadays. */
{ python, setuptools, unzip, wrapPython, lib, bootstrapped-pip { lib
, ensureNewerSourcesHook }: , python
, mkPythonDerivation
, bootstrapped-pip
}:
{ name { buildInputs ? []
# by default prefix `name` e.g. "python3.3-${name}"
, namePrefix ? python.libPrefix + "-"
, buildInputs ? []
# 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 ? []
# passed to "python setup.py build_ext" # passed to "python setup.py build_ext"
# https://github.com/pypa/pip/issues/881 # https://github.com/pypa/pip/issues/881
, setupPyBuildFlags ? [] , setupPyBuildFlags ? []
# DEPRECATED: use propagatedBuildInputs
, pythonPath ? []
# used to disable derivation, useful for specific python versions
, disabled ? false
, meta ? {}
# Execute before shell hook # Execute before shell hook
, preShellHook ? "" , preShellHook ? ""
# Execute after shell hook # Execute after shell hook
, postShellHook ? "" , postShellHook ? ""
# Additional arguments to pass to the makeWrapper function, which wraps
# generated binaries.
, makeWrapperArgs ? []
# Additional flags to pass to "pip install". # Additional flags to pass to "pip install".
, installFlags ? [] , installFlags ? []
# Raise an error if two packages are installed with the same name
, catchConflicts ? true
, format ? "setup" , format ? "setup"
, ... } @ attrs: , ... } @ attrs:
# Keep extra attributes from `attrs`, e.g., `patchPhase', etc.
if disabled
then throw "${name} not supported for interpreter ${python.executable}"
else
let let
# use setuptools shim (so that setuptools is imported before distutils) # use setuptools shim (so that setuptools is imported before distutils)
@ -73,14 +53,10 @@ let
installCheckPhase = attrs.checkPhase or ":"; installCheckPhase = attrs.checkPhase or ":";
# Wheels don't have any checks to run # Wheels don't have any checks to run
doInstallCheck = attrs.doCheck or false; doCheck = attrs.doCheck or false;
} }
else if format == "setup" then else if format == "setup" then
{ {
# propagate python/setuptools to active setup-hook in nix-shell
propagatedBuildInputs =
propagatedBuildInputs ++ [ python setuptools ];
# we copy nix_run_setup.py over so it's executed relative to the root of the source # we copy nix_run_setup.py over so it's executed relative to the root of the source
# many project make that assumption # many project make that assumption
buildPhase = attrs.buildPhase or '' buildPhase = attrs.buildPhase or ''
@ -100,21 +76,17 @@ let
# are typically distributed with tests. # are typically distributed with tests.
# With Python it's a common idiom to run the tests # With Python it's a common idiom to run the tests
# after the software has been installed. # after the software has been installed.
doCheck = attrs.doCheck or true;
# For backwards compatibility, let's use an alias
doInstallCheck = attrs.doCheck or true;
} }
else else
throw "Unsupported format ${format}"; throw "Unsupported format ${format}";
in
python.stdenv.mkDerivation (builtins.removeAttrs attrs ["disabled" "doCheck"] // {
name = namePrefix + name;
buildInputs = [ wrapPython bootstrapped-pip ] ++ buildInputs ++ pythonPath in mkPythonDerivation ( attrs // {
++ [ (ensureNewerSourcesHook { year = "1980"; }) ]
++ (lib.optional (lib.hasSuffix "zip" attrs.src.name or "") unzip);
pythonPath = pythonPath; # To build and install a wheel we need pip
buildInputs = buildInputs ++ [ bootstrapped-pip ];
#inherit propagatedBuildInputs;
configurePhase = attrs.configurePhase or '' configurePhase = attrs.configurePhase or ''
runHook preConfigure runHook preConfigure
@ -126,9 +98,6 @@ python.stdenv.mkDerivation (builtins.removeAttrs attrs ["disabled" "doCheck"] //
runHook postConfigure runHook postConfigure
''; '';
# Python packages don't have a checkPhase, only an installCheckPhase
doCheck = false;
installPhase = attrs.installPhase or '' installPhase = attrs.installPhase or ''
runHook preInstall runHook preInstall
@ -142,14 +111,6 @@ python.stdenv.mkDerivation (builtins.removeAttrs attrs ["disabled" "doCheck"] //
runHook postInstall runHook postInstall
''; '';
postFixup = attrs.postFixup or ''
wrapPythonPrograms
'' + lib.optionalString catchConflicts ''
# check if we have two packages 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 '' shellHook = attrs.shellHook or ''
${preShellHook} ${preShellHook}
if test -e setup.py; then if test -e setup.py; then
@ -162,13 +123,4 @@ python.stdenv.mkDerivation (builtins.removeAttrs attrs ["disabled" "doCheck"] //
${postShellHook} ${postShellHook}
''; '';
meta = with lib.maintainers; {
# default to python's platforms
platforms = python.meta.platforms;
} // meta // {
# add extra maintainer(s) to every package
maintainers = (meta.maintainers or []) ++ [ chaoflow domenkozar ];
# a marker for release utilities to discover python packages
isBuildPythonPackage = python.meta.platforms;
};
} // formatspecific) } // formatspecific)

View file

@ -0,0 +1,93 @@
/* Generic builder for Python packages that come without a setup.py. */
{ lib
, python
, wrapPython
, setuptools
, unzip
, ensureNewerSourcesHook
}:
{ name
# by default prefix `name` e.g. "python3.3-${name}"
, namePrefix ? python.libPrefix + "-"
# Dependencies for building the package
, 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,
# C can import package A propagated by B
, propagatedBuildInputs ? []
# DEPRECATED: use propagatedBuildInputs
, pythonPath ? []
# used to disable derivation, useful for specific python versions
, disabled ? false
# Raise an error if two packages are installed with the same name
, catchConflicts ? true
# Additional arguments to pass to the makeWrapper function, which wraps
# generated binaries.
, makeWrapperArgs ? []
, meta ? {}
, passthru ? {}
, ... } @ attrs:
# Keep extra attributes from `attrs`, e.g., `patchPhase', etc.
if disabled
then throw "${name} not supported for interpreter ${python.executable}"
else
python.stdenv.mkDerivation (builtins.removeAttrs attrs ["disabled"] // {
name = namePrefix + name;
inherit pythonPath;
buildInputs = [ wrapPython ] ++ buildInputs ++ pythonPath
++ [ (ensureNewerSourcesHook { year = "1980"; }) ]
++ (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
propagatedBuildInputs = propagatedBuildInputs ++ [ python setuptools ];
# Python packages don't have a checkPhase, only an installCheckPhase
doCheck = false;
doInstallCheck = attrs.doCheck or false;
postFixup = attrs.postFixup or ''
wrapPythonPrograms
'' + lib.optionalString catchConflicts ''
# check if we have two packages with the same name in closure and fail
# this shouldn't happen, something went wrong with dependencies specs
${python.interpreter} ${./catch_conflicts.py}
'';
passthru = {
inherit python; # The python interpreter
} // passthru;
meta = with lib.maintainers; {
# default to python's platforms
platforms = python.meta.platforms;
} // meta // {
# add extra maintainer(s) to every package
maintainers = (meta.maintainers or []) ++ [ chaoflow domenkozar ];
# a marker for release utilities to discover python packages
isBuildPythonPackage = python.meta.platforms;
};
})

View file

@ -0,0 +1,51 @@
{ lib
, python
, makeSetupHook
, makeWrapper }:
with lib;
makeSetupHook {
deps = makeWrapper;
substitutions.libPrefix = python.libPrefix;
substitutions.executable = python.interpreter;
substitutions.python = python;
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
# at the last position.
quoteVariants = [ "'\"'''\"'" "\"\"\"" "\"" "'\"'\"'" ]; # hey Vim: ''
mkStringSkipper = labelNum: quote: let
label = "q${toString labelNum}";
isSingle = elem quote [ "\"" "'\"'\"'" ];
endQuote = if isSingle then "[^\\\\]${quote}" else quote;
in ''
/^[a-z]?${quote}/ {
/${quote}${quote}|${quote}.*${endQuote}/{n;br}
:${label}; n; /^${quote}/{n;br}; /${endQuote}/{n;br}; b${label}
}
'';
# This preamble does two things:
# * Sets argv[0] to the original application's name; otherwise it would be .foo-wrapped.
# Python doesn't support `exec -a`.
# * Adds all required libraries to sys.path via `site.addsitedir`. It also handles *.pth files.
preamble = ''
import sys
import site
import functools
sys.argv[0] = '"'$(basename "$f")'"'
functools.reduce(lambda k, p: site.addsitedir(p, k), ['"$([ -n "$program_PYTHONPATH" ] && (echo "'$program_PYTHONPATH'" | sed "s|:|','|g") || true)"'], site._init_pathinfo())
'';
in ''
1 {
:r
/\\$|,$/{N;br}
/__future__|^ |^ *(#.*)?$/{n;br}
${concatImapStrings mkStringSkipper quoteVariants}
/^[^# ]/i ${replaceStrings ["\n"] [";"] preamble}
}
'';
} ./wrap.sh

View file

@ -6,8 +6,8 @@ let
sha256 = "ea8033fc9905804e652f75474d33410a07404c1a78dd3c949a66863bd1050ebd"; sha256 = "ea8033fc9905804e652f75474d33410a07404c1a78dd3c949a66863bd1050ebd";
}; };
setuptools_source = fetchurl { setuptools_source = fetchurl {
url = "https://pypi.python.org/packages/3.5/s/setuptools/setuptools-19.4-py2.py3-none-any.whl"; url = "https://files.pythonhosted.org/packages/3b/c7/e9724e6f81c96248fba5876054418c11d327b3093d075790903cd66fad44/setuptools-26.1.1-py2.py3-none-any.whl";
sha256 = "0801e6d862ca4ce24d918420d62f07ee2fe736dc016e3afa99d2103e7a02e9a6"; sha256 = "226c9ce65e76c6069e805982b036f36dc4b227b37dd87fc219aef721ec8604ae";
}; };
argparse_source = fetchurl { argparse_source = fetchurl {
url = "https://pypi.python.org/packages/2.7/a/argparse/argparse-1.4.0-py2.py3-none-any.whl"; url = "https://pypi.python.org/packages/2.7/a/argparse/argparse-1.4.0-py2.py3-none-any.whl";

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

@ -2,13 +2,13 @@
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
shortName = "setuptools-${version}"; shortName = "setuptools-${version}";
name = "${python.executable}-${shortName}"; name = "${python.libPrefix}-${shortName}";
version = "19.4"; # 18.4 and up breaks python34Packages.characteristic and many others version = "26.1.1"; # 18.4 and up breaks python34Packages.characteristic and many others
src = fetchurl { src = fetchurl {
url = "mirror://pypi/s/setuptools/${shortName}.tar.gz"; url = "mirror://pypi/s/setuptools/${shortName}.tar.gz";
sha256 = "214bf29933f47cf25e6faa569f710731728a07a19cae91ea64f826051f68a8cf"; sha256 = "475ce28993d7cb75335942525b9fac79f7431a7f6e8a0079c0f2680641379481";
}; };
buildInputs = [ python wrapPython ]; buildInputs = [ python wrapPython ];

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

@ -18,7 +18,10 @@ let
bootstrapped-pip = callPackage ../development/python-modules/bootstrapped-pip { }; bootstrapped-pip = callPackage ../development/python-modules/bootstrapped-pip { };
buildPythonPackage = makeOverridable (callPackage ../development/python-modules/generic { mkPythonDerivation = makeOverridable( callPackage ../development/interpreters/python/mk-python-derivation.nix {
});
buildPythonPackage = makeOverridable (callPackage ../development/interpreters/python/build-python-package.nix {
inherit mkPythonDerivation;
inherit bootstrapped-pip; inherit bootstrapped-pip;
}); });
@ -34,55 +37,11 @@ let
in modules // { in modules // {
inherit python bootstrapped-pip isPy26 isPy27 isPy33 isPy34 isPy35 isPy36 isPyPy isPy3k buildPythonPackage buildPythonApplication; inherit python bootstrapped-pip isPy26 isPy27 isPy33 isPy34 isPy35 isPy36 isPyPy isPy3k mkPythonDerivation buildPythonPackage buildPythonApplication;
# helpers # helpers
wrapPython = pkgs.makeSetupHook wrapPython = callPackage ../development/interpreters/python/wrap-python.nix {inherit python; inherit (pkgs) makeSetupHook makeWrapper; };
{ deps = pkgs.makeWrapper;
substitutions.libPrefix = python.libPrefix;
substitutions.executable = python.interpreter;
substitutions.python = python;
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
# at the last position.
quoteVariants = [ "'\"'''\"'" "\"\"\"" "\"" "'\"'\"'" ]; # hey Vim: ''
mkStringSkipper = labelNum: quote: let
label = "q${toString labelNum}";
isSingle = elem quote [ "\"" "'\"'\"'" ];
endQuote = if isSingle then "[^\\\\]${quote}" else quote;
in ''
/^[a-z]?${quote}/ {
/${quote}${quote}|${quote}.*${endQuote}/{n;br}
:${label}; n; /^${quote}/{n;br}; /${endQuote}/{n;br}; b${label}
}
'';
# This preamble does two things:
# * Sets argv[0] to the original application's name; otherwise it would be .foo-wrapped.
# Python doesn't support `exec -a`.
# * Adds all required libraries to sys.path via `site.addsitedir`. It also handles *.pth files.
preamble = ''
import sys
import site
import functools
sys.argv[0] = '"'$(basename "$f")'"'
functools.reduce(lambda k, p: site.addsitedir(p, k), ['"$([ -n "$program_PYTHONPATH" ] && (echo "'$program_PYTHONPATH'" | sed "s|:|','|g") || true)"'], site._init_pathinfo())
'';
in ''
1 {
:r
/\\$|,$/{N;br}
/__future__|^ |^ *(#.*)?$/{n;br}
${concatImapStrings mkStringSkipper quoteVariants}
/^[^# ]/i ${replaceStrings ["\n"] [";"] preamble}
}
'';
}
../development/python-modules/generic/wrap.sh;
# specials # specials
@ -6377,7 +6336,7 @@ in modules // {
buildInputs = with self; [ fudge_9 nose ]; buildInputs = with self; [ fudge_9 nose ];
}; };
fedora_cert = stdenv.mkDerivation (rec { fedora_cert = mkPythonDerivation rec {
name = "fedora-cert-0.5.9.2"; name = "fedora-cert-0.5.9.2";
meta.maintainers = with maintainers; [ mornfall ]; meta.maintainers = with maintainers; [ mornfall ];
@ -6386,12 +6345,10 @@ in modules // {
sha256 = "105swvzshgn3g6bjwk67xd8pslnhpxwa63mdsw6cl4c7cjp2blx9"; sha256 = "105swvzshgn3g6bjwk67xd8pslnhpxwa63mdsw6cl4c7cjp2blx9";
}; };
propagatedBuildInputs = with self; [ python python_fedora wrapPython ]; propagatedBuildInputs = with self; [ python_fedora modules.sqlite3 pyopenssl ];
postInstall = "mv $out/bin/fedpkg $out/bin/fedora-cert-fedpkg"; postInstall = "mv $out/bin/fedpkg $out/bin/fedora-cert-fedpkg";
doCheck = false; doCheck = false;
};
postFixup = "wrapPythonPrograms";
});
fedpkg = buildPythonPackage (rec { fedpkg = buildPythonPackage (rec {
name = "fedpkg-1.14"; name = "fedpkg-1.14";
@ -20235,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 {
@ -20243,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.
@ -20389,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";
@ -20720,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