Commit abe61db7 authored by qbisi's avatar qbisi
Browse files

python-env: wrap python executable with --resolve-argv0

This commit, together with https://github.com/NixOS/nixpkgs/pull/442540,
changes the way python environments are built:

  * When generating wrappers for python executables, we inherit argv[0]
    from the wrapper. This causes python to initialize its configuration
    in the environment with all the correct paths.
  * We also resolve argv[0] to absolute path when invoking python from
    PATH. This helps set python's prefix correctly on Darwin.

The end result is that python environments no longer appear to be venvs,
and behave more like a vanilla python installation. In addition it's
possible to create a venv using an environment and use packages from
both the environment and the venv.
parent 839a7d6d
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@ let
                if [ "$prg" = "${python.executable}" ]; then
                  makeWrapper "${python.interpreter}" "$out/bin/$prg" \
                    --inherit-argv0 \
                    --resolve-argv0 \
                    ${lib.optionalString (!permitUserSite) ''--set PYTHONNOUSERSITE "true"''} \
                    ${lib.concatStringsSep " " makeWrapperArgs}
                elif [ "$(readlink "$prg")" = "${python.executable}" ]; then