Ticket #10192: trac_10192-remove_dot_from_PYTHONPATH_in_sage-spkg.v2.scripts.patch

File trac_10192-remove_dot_from_PYTHONPATH_in_sage-spkg.v2.scripts.patch, 1.4 KB (added by leif, 10 years ago)

SCRIPTS repo. Improved version of my previous patch. Based on Sage 4.7.2.alpha4.

  • sage-spkg

    # HG changeset patch
    # User Leif Leonhardy <not.really@online.de>
    # Date 1318527817 -7200
    # Node ID b96f4680ea682f58537327ac0c74e3a54e4b0a00
    # Parent  58c82036cc304ebc4b3fec4c3943faded4299a44
    #10192: sage-spkg: Remove current working directory ('.') from PYTHONPATH before installing an spkg (cf. also #10176).
    
    diff --git a/sage-spkg b/sage-spkg
    a b  
    304304
    305305chmod +x spkg-install
    306306
     307# Remove '.' from PYTHONPATH, which may also come from SAGE_PATH, to avoid
     308# trouble with setuptools / easy_install (cf. #10192, #10176):
     309if [ -n "$PYTHONPATH" ]; then
     310    # We also collapse multiple slashs into a single one (first substitution),
     311    # remove leading './'s and trailing '/.'s (second and third), and
     312    # remove leading, trailing and redundant ':'s (last three substitutions):
     313    new_pp=`echo ":$PYTHONPATH:" \
     314            | sed \
     315                -e 's|/\+|/|g' \
     316                -e 's|:\(\./\)\+|:|g' \
     317                -e 's|\(/\.\)\+:|:|g' \
     318                -e 's|\(:\.\)\+:|:|g' \
     319                -e 's|:\+|:|g' -e 's|^:\+||' -e 's|:\+$||'`
     320
     321    if [ "$PYTHONPATH" != "$new_pp" ]; then
     322        echo "Cleaning up PYTHONPATH:"
     323        echo "  Old: \"$PYTHONPATH\""
     324        echo "  New: \"$new_pp\""
     325        PYTHONPATH=$new_pp
     326        export PYTHONPATH # maybe redundant, but in any case safe
     327    fi
     328fi
     329
    307330# this is just wrong... (so don't do it)
    308331#echo "TOUCHING"
    309332#touch * */* */*/* */*/*/* 1>/dev/null 2>/dev/null