@@ -12,6 +12,11 @@ if [ "$1" != "install" ]; then
1212fi
1313shift
1414
15+ if [ -n " $TMPDIR " ]; then
16+ TMPDIR=/tmp
17+ fi
18+ TMPVENV=" $TMPDIR /pip-micropy-venv"
19+
1520if [ -n " $PIP_MICROPY_DEST " ]; then
1621 dest=" $PIP_MICROPY_DEST "
1722 echo " Destination snapshot directory: $dest "
@@ -20,23 +25,23 @@ elif [ -n "$MICROPYPATH" ]; then
2025 echo " Destination library directory: $libdest "
2126else
2227 echo " Warning: MICROPYPATH is not set, assuming default value"
23- libdest=~ /.micropython/lib
28+ libdest=$HOME /.micropython/lib
2429 echo " Destination library directory: $libdest "
2530fi
2631
2732# Due to bugs in pip, installation should happen with active virtualenv
2833# The issue (at least with pip 1.0 which is still what's shipped with many
2934# distros) is that even if --ignore-installed is used, package is not
3035# installed if it's already installed for main python distribution.
31- if [ ! -d /tmp/pip-micropy-venv ]; then
32- virtualenv --no-site-packages /tmp/pip-micropy-venv
36+ if [ ! -d " $TMPVENV " ]; then
37+ virtualenv --no-site-packages " $TMPVENV "
3338 # distutils, setuptools, pip are buggy and allow target packages affect
3439 # their execution environment. For example, if distribution they install
3540 # has re.py, they will import that instead of system re. So, we need
3641 # to remove current dir from sys.path, but that appear to be quite uneasy
3742 # with CPython, so we hook __import__ and exterminate it persistently.
3843 # See also https://bitbucket.org/pypa/setuptools/issue/187/
39- cat > $( ls -1d /tmp/pip-micropy-venv /lib/python* /) /sitecustomize.py << EOF
44+ cat > $( ls -1d " $TMPVENV " /lib/python* /) /sitecustomize.py << EOF
4045import sys
4146import __builtin__
4247old_imp = __import__
@@ -46,7 +51,7 @@ def new_imp(*a, **kw):
4651__builtin__.__import__ = new_imp
4752EOF
4853fi
49- . /tmp/pip-micropy-venv /bin/activate
54+ . " $TMPVENV " /bin/activate
5055
5156# We need to specify --record to override this switch as passed by pip
5257# pip will try to parse this file (at the location in specifies), and try to
@@ -61,22 +66,22 @@ pip install "$@" \
6166 --install-option=" --install-scripts=." \
6267 --install-option=" --install-headers=headers" \
6368 --install-option=" --install-data=lib" \
64- --install-option=" --record=/tmp /setuptools-record.txt" \
69+ --install-option=" --record=$TMPDIR /setuptools-record.txt" \
6570 --install-option=" --no-compile" \
6671 --install-option=" --root=$dest "
6772else
6873# Here we assume that base dir is lib dir, and install scripts a level
69- # higher. For default value of ~/ micropython/lib/ , this should give
74+ # higher. For default value of $HOME/. micropython/lib/ , this should give
7075# reasonable behavior, though better would make it overridable (or
71- # go bold and use ~ /bin ?)
76+ # go bold and use $HOME /bin ?)
7277pip install " $@ " \
7378 --install-option=" --install-base=." \
7479 --install-option=" --install-purelib=." \
7580 --install-option=" --install-platlib=." \
7681 --install-option=" --install-scripts=.." \
7782 --install-option=" --install-headers=../headers" \
7883 --install-option=" --install-data=." \
79- --install-option=" --record=/tmp /setuptools-record.txt" \
84+ --install-option=" --record=$TMPDIR /setuptools-record.txt" \
8085 --install-option=" --no-compile" \
8186 --install-option=" --root=$libdest "
8287fi
0 commit comments