From f665828fa374580f4b2fd725761d23e18f55e526 Mon Sep 17 00:00:00 2001 From: Frederik Rietdijk Date: Wed, 2 Jan 2019 20:09:44 +0100 Subject: Python: improve cross-compilation This changeset allows for cross-compilation of Python packages. Packages built with buildPythonPackage are not allowed to refer to the build machine. Executables that have shebangs will refer to the host. --- pkgs/development/interpreters/python/wrap.sh | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'pkgs/development/interpreters/python/wrap.sh') diff --git a/pkgs/development/interpreters/python/wrap.sh b/pkgs/development/interpreters/python/wrap.sh index 6fa8c316a17..b2d65422db4 100644 --- a/pkgs/development/interpreters/python/wrap.sh +++ b/pkgs/development/interpreters/python/wrap.sh @@ -16,8 +16,8 @@ buildPythonPath() { declare -A pythonPathsSeen=() program_PYTHONPATH= program_PATH= - pythonPathsSeen["@python@"]=1 - addToSearchPath program_PATH @python@/bin + pythonPathsSeen["@pythonHost@"]=1 + addToSearchPath program_PATH @pythonHost@/bin for path in $pythonPath; do _addToPythonPath $path done @@ -53,7 +53,13 @@ wrapPythonProgramsIn() { # Strip suffix, like "3" or "2.7m" -- we don't have any choice on which # Python to use besides one with this hook anyway. if head -n1 "$f" | grep -q '#!.*/env.*\(python\|pypy\)'; then - sed -i "$f" -e "1 s^.*/env[ ]*\(python\|pypy\)[^ ]*^#! @executable@^" + sed -i "$f" -e "1 s^.*/env[ ]*\(python\|pypy\)[^ ]*^#!@executable@^" + fi + + if head -n1 "$f" | grep -q '#!.*'; then + # Cross-compilation hack: ensure shebangs are for the host + echo "Rewriting $(head -n 1 $f) to #!@pythonHost@" + sed -i "$f" -e "1 s^#!@python@^#!@pythonHost@^" fi # catch /python and /.python-wrapped -- cgit 1.4.1