2014-10-19 21:48:07 +04:00
|
|
|
{ stdenv, python, buildEnv, makeWrapper
|
|
|
|
, extraLibs ? []
|
|
|
|
, postBuild ? ""
|
2014-10-12 16:59:31 +04:00
|
|
|
, ignoreCollisions ? false }:
|
2012-02-26 21:23:22 +04:00
|
|
|
|
2013-08-15 11:52:25 +04:00
|
|
|
# Create a python executable that knows about additional packages.
|
2014-10-19 21:48:07 +04:00
|
|
|
let
|
|
|
|
recursivePthLoader = import ../../python-modules/recursive-pth-loader/default.nix { stdenv = stdenv; python = python; };
|
2015-08-14 14:06:15 +03:00
|
|
|
env = (buildEnv {
|
|
|
|
name = "${python.name}-env";
|
|
|
|
paths = stdenv.lib.filter (x : x ? pythonPath) (stdenv.lib.closePropagation extraLibs) ++ [ python recursivePthLoader ];
|
2014-02-24 15:41:12 +04:00
|
|
|
|
2015-08-14 14:06:15 +03:00
|
|
|
inherit ignoreCollisions;
|
2010-08-16 21:03:35 +04:00
|
|
|
|
2015-08-14 14:06:15 +03:00
|
|
|
postBuild = ''
|
|
|
|
. "${makeWrapper}/nix-support/setup-hook"
|
2013-11-07 16:59:44 +04:00
|
|
|
|
2015-08-14 14:06:15 +03:00
|
|
|
if [ -L "$out/bin" ]; then
|
|
|
|
unlink "$out/bin"
|
|
|
|
fi
|
|
|
|
mkdir -p "$out/bin"
|
2013-11-07 16:59:44 +04:00
|
|
|
|
2015-08-14 14:06:15 +03:00
|
|
|
cd "${python}/bin"
|
|
|
|
for prg in *; do
|
|
|
|
rm -f "$out/bin/$prg"
|
|
|
|
makeWrapper "${python}/bin/$prg" "$out/bin/$prg" --set PYTHONHOME "$out"
|
|
|
|
done
|
|
|
|
'' + postBuild;
|
|
|
|
|
|
|
|
passthru.env = stdenv.mkDerivation {
|
|
|
|
name = "interactive-${python.name}-environment";
|
|
|
|
nativeBuildInputs = [ env ];
|
|
|
|
|
|
|
|
buildCommand = ''
|
|
|
|
echo >&2 ""
|
|
|
|
echo >&2 "*** Python 'env' attributes are intended for interactive nix-shell sessions, not for building! ***"
|
|
|
|
echo >&2 ""
|
|
|
|
exit 1
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
}) // {
|
|
|
|
inherit python;
|
|
|
|
inherit (python) meta;
|
|
|
|
};
|
|
|
|
in env
|