3
0
Fork 0
forked from mirrors/nixpkgs

python-wrapper: Fix fixup for wrapped argv[0].

Fixes issues introduced by 24ef871e6a.

The problem here is that "import sys; sys.argv[0] = ..." is just
appended after the first "#!", which in turn breaks things such as
encoding specifications. A second problem - although not very common -
is when there's another #! within the script.

This should take care of both cases.

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
This commit is contained in:
aszlig 2014-07-28 04:18:21 +02:00
parent e57249ab20
commit 5f01cc70d3
No known key found for this signature in database
GPG key ID: D0EBD0EC8C2DC961

View file

@ -26,7 +26,9 @@ wrapPythonProgramsIn() {
# dont wrap EGG-INFO scripts since they are called from python
if echo "$i" | grep -v EGG-INFO/scripts; then
echo "wrapping \`$i'..."
sed -i "$i" -e "/^#\!/a import sys; sys.argv[0] = '$(basename $i)'"
sed -i "$i" -e '1,/#!/ { /^#\!/,/^[^#]/ {
/^[^#]/i import sys; sys.argv[0] = '"'$(basename "$i")'"'
}}'
wrapProgram "$i" \
--prefix PYTHONPATH ":" $program_PYTHONPATH \
--prefix PATH ":" $program_PATH