From 0aac7ba34408d395b30c65e9280a53d23819e5b1 Mon Sep 17 00:00:00 2001 From: Andrew Scheller Date: Mon, 14 Apr 2014 12:26:12 +0100 Subject: [PATCH] Make pip-micropython more portable Replace /tmp with a $TMPDIR variable Replace multiple occurrences of /tmp/pip-micropy-venv with a $TMPVENV variable Replace ~ with $HOME --- tools/pip-micropython | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/tools/pip-micropython b/tools/pip-micropython index d5b84b0e25..b4fad90865 100755 --- a/tools/pip-micropython +++ b/tools/pip-micropython @@ -12,6 +12,11 @@ if [ "$1" != "install" ]; then fi shift +if [ -n "$TMPDIR" ]; then + TMPDIR=/tmp +fi +TMPVENV="$TMPDIR/pip-micropy-venv" + if [ -n "$PIP_MICROPY_DEST" ]; then dest="$PIP_MICROPY_DEST" echo "Destination snapshot directory: $dest" @@ -20,7 +25,7 @@ elif [ -n "$MICROPYPATH" ]; then echo "Destination library directory: $libdest" else echo "Warning: MICROPYPATH is not set, assuming default value" - libdest=~/.micropython/lib + libdest=$HOME/.micropython/lib echo "Destination library directory: $libdest" fi @@ -28,15 +33,15 @@ fi # The issue (at least with pip 1.0 which is still what's shipped with many # distros) is that even if --ignore-installed is used, package is not # installed if it's already installed for main python distribution. -if [ ! -d /tmp/pip-micropy-venv ]; then - virtualenv --no-site-packages /tmp/pip-micropy-venv +if [ ! -d "$TMPVENV" ]; then + virtualenv --no-site-packages "$TMPVENV" # distutils, setuptools, pip are buggy and allow target packages affect # their execution environment. For example, if distribution they install # has re.py, they will import that instead of system re. So, we need # to remove current dir from sys.path, but that appear to be quite uneasy # with CPython, so we hook __import__ and exterminate it persistently. # See also https://bitbucket.org/pypa/setuptools/issue/187/ - cat > $(ls -1d /tmp/pip-micropy-venv/lib/python*/)/sitecustomize.py < $(ls -1d "$TMPVENV"/lib/python*/)/sitecustomize.py <