diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 9a1fa9391dd8..2926dd9cf4c2 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -8206,6 +8206,27 @@ rec { substituteInPlace "virtualenvwrapper_lazy.sh" --replace "which" "${pkgs.which}/bin/which" ''; + postInstall = '' + # This might look like a dirty hack but we can't use the makeWrapper function because + # the wrapped file were then called via "exec". The virtualenvwrapper shell scripts + # aren't normal executables. Instead, the user has to evaluate them. + + for file in "virtualenvwrapper.sh" "virtualenvwrapper_lazy.sh"; do + local wrapper="$out/bin/$file" + local wrapped="$out/bin/.$file-wrapped" + mv "$wrapper" "$wrapped" + + cat > "$wrapper" <<- EOF + export PATH=$PATH:\$PATH + export PYTHONPATH=$PYTHONPATH:$(toPythonPath $out):\$PYTHONPATH + source "$wrapped" + EOF + + chmod -x "$wrapped" + chmod +x "$wrapper" + done + ''; + meta = { description = "Enhancements to virtualenv"; homepage = "https://pypi.python.org/pypi/virtualenvwrapper";