diff --git a/elements/pypi/README.md b/elements/pypi/README.md index 10002fd2d..f83ffc491 100644 --- a/elements/pypi/README.md +++ b/elements/pypi/README.md @@ -1,13 +1,15 @@ Inject a PyPI mirror ==================== -Bind mounts a PyPI mirror from ~/.cache/image-create/pypi/mirror into the build -environment and temporarily overwrites /root/.pip.conf and .pydistutils.cfg to -use it. +Use a custom PyPI mirror to build images. The default is to bind mount one from +~/.cache/image-create/pypi/mirror into the build environment. The element +temporarily overwrites /root/.pip.conf and .pydistutils.cfg to use it. -When online, the master pypi index is supplied as an extra-url, so uncached -dependencies will still be available. When offline, only the mirror is used - a -stale mirror will cause build failures. +When online, the official pypi.python.org pypi index is supplied as an +extra-url, so uncached dependencies will still be available. When offline, only +the mirror is used - be warned that a stale mirror will cause build failures. + +To use an arbitrary mirror set PYPI\_MIRROR\_URL=http[s]://somevalue/ [jeepyb](https://git.openstack.org/cgit/openstack-infra/jeepyb) can be useful in making a partial PyPI mirror suitable for building images. For instance: diff --git a/elements/pypi/extra-data.d/00-mount-pypi-mirror b/elements/pypi/extra-data.d/00-mount-pypi-mirror index 8aa01611e..6cc12534b 100755 --- a/elements/pypi/extra-data.d/00-mount-pypi-mirror +++ b/elements/pypi/extra-data.d/00-mount-pypi-mirror @@ -2,6 +2,11 @@ set -eu +PYPI_MIRROR_URL=${PYPI_MIRROR_URL:-''} +if [ -n "$PYPI_MIRROR_URL" ]; then + # External mirror URL being used - no need to bind mount anything. + exit 0 +fi MIRROR_SOURCE=~/.cache/image-create/pypi/mirror/ MIRROR_TARGET=$TMP_MOUNT_PATH/tmp/pypi diff --git a/elements/pypi/pre-install.d/00-configure-pypi-mirror b/elements/pypi/pre-install.d/00-configure-pypi-mirror index 402951c51..89c48ec3a 100755 --- a/elements/pypi/pre-install.d/00-configure-pypi-mirror +++ b/elements/pypi/pre-install.d/00-configure-pypi-mirror @@ -2,7 +2,7 @@ set -eu -PYPIURL=file:///tmp/pypi +PYPIURL=${PYPI_MIRROR_URL:-'file:///tmp/pypi'} mkdir -p ~/.pip if [ -e ~/.pip/pip.conf ]; then