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 <