From d68aba4cfb5d7998fbd087f7bf6f5d6f9fb5416a Mon Sep 17 00:00:00 2001 From: Frederik Rietdijk Date: Sun, 1 Jan 2017 17:57:26 +0100 Subject: [PATCH] Python: script names now include full path Certain programs, like zim, calibre and now also apparently mercurial, rely on sys.argv[0] providing not just the script name but the full path. The Python docs [1] state the following on the matter: > argv[0] is the script name (it is operating system dependent whether this is a full pathname or not). Therefore, scripts should not expect to receive a full path. Unfortunately some do. While this can be considered a bug, there doesn't seem any reason not to provide the full path. Therefore we now provide the full path. [1] https://docs.python.org/3.5/library/sys.html?highlight=sys.argv#sys.argv --- pkgs/development/interpreters/python/wrap-python.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/development/interpreters/python/wrap-python.nix b/pkgs/development/interpreters/python/wrap-python.nix index b965ff5350b..1efd777bb05 100644 --- a/pkgs/development/interpreters/python/wrap-python.nix +++ b/pkgs/development/interpreters/python/wrap-python.nix @@ -35,7 +35,7 @@ makeSetupHook { import sys import site import functools - sys.argv[0] = '"'$(basename "$f")'"' + sys.argv[0] = '"'$(readlink -f "$f")'"' functools.reduce(lambda k, p: site.addsitedir(p, k), ['"$([ -n "$program_PYTHONPATH" ] && (echo "'$program_PYTHONPATH'" | sed "s|:|','|g") || true)"'], site._init_pathinfo()) '';