diskimage-builder/elements/pypi/pre-install.d/00-configure-pypi-mirror
Robert Collins 1adf3a377e Permit using arbitrary PyPI urls.
The pypi element is cool, but some folk have local network mirrors
which we should permit them to use.

Change-Id: Ie840ad1184e72b0e01966eee0298cfd6511b6c19
2014-02-19 14:05:31 +13:00

32 lines
502 B
Bash
Executable file

#!/bin/bash
set -eu
PYPIURL=${PYPI_MIRROR_URL:-'file:///tmp/pypi'}
mkdir -p ~/.pip
if [ -e ~/.pip/pip.conf ]; then
mv ~/.pip/pip.conf{,.orig}
fi
if [ -e ~/.pydistutils.cfg ]; then
mv ~/.pydistutils.cfg{,.orig}
fi
if [ -z $DIB_OFFLINE ]; then
ONLINE="extra-index-url = https://pypi.python.org/simple"
else
ONLINE=""
fi
cat <<EOF > ~/.pip/pip.conf
[global]
index-url = $PYPIURL
$ONLINE
log = $HOME/pip.log
EOF
cat <<EOF > ~/.pydistutils.cfg
[easy_install]
index_url = $PYPIURL
EOF