{ stdenv, python, buildEnv, makeWrapper, recursivePthLoader, extraLibs ? [] }:

# Create a python executable that knows about additional packages.

(buildEnv {
  name = "python-${python.version}-wrapper";
  paths = extraLibs ++ [ python makeWrapper recursivePthLoader ];
  ignoreCollisions = false;

  postBuild = ''
    . "${makeWrapper}/nix-support/setup-hook"
    mkdir -p "$out/bin"
    cd "${python}/bin"
    for prg in *; do
      echo "$prg --> $out/bin/$prg"
      rm -f "$out/bin/$prg"
      makeWrapper "${python}/bin/$prg" "$out/bin/$prg" --set PYTHONHOME "$out"
    done
  '';
}) // {
  inherit python;
  inherit (python) meta;
}

{ stdenv, python, buildEnv, makeWrapper, recursivePthLoader, extraLibs ? [] }:

# Create a python executable that knows about additional packages.

(buildEnv {
  name = "python-${python.version}-wrapper";
  paths = extraLibs ++ [ python makeWrapper recursivePthLoader ];
  ignoreCollisions = false;

  postBuild = ''
    . "${makeWrapper}/nix-support/setup-hook"
    if [ -L "$out/bin" ]; then
        unlink "$out/bin"
    fi
    mkdir -p "$out/bin"
    cd "${python}/bin"
    for prg in *; do
      echo "$prg --> $out/bin/$prg"
      rm -f "$out/bin/$prg"
      makeWrapper "${python}/bin/$prg" "$out/bin/$prg" --set PYTHONHOME "$out"
    done
  '';
}) // {
  inherit python;
  inherit (python) meta;
}

Fix pythonWrapper when all of the binaries come from python
Fix pythonWrapper when all of the binaries come from python

See discussion in #834

Signed-off-by: Shea Levy <2ad57049e5a4c55c398e1a2fc9bf3e78fb5d7c3a@shealevy.com>
