Always bind-mount pypi mirror if dir exists
It may be desirable to specify file://tmp/pypi as one of the list of mirrors specified by PYPI_MIRROR_URL, so the local pypi mirror should be mounted as long as the directory exists. Even though the path is mounted, it is only used by pip if there is no specified PYPI_MIRROR_URL, or if one PYPI_MIRROR_URL entry specifies file://tmp/pypi. The pypi element previously assumed that a local mirror would be a complete offline mirror. This change allows for a mixture of local mirror plus remote mirrors. This means that the local mirror could (for example) contain a few locally built pip packages from arbitrary git checkouts for gate testing of those projects. In this scenario, most packages would be downloaded from the configured remote mirrors. This change is required for synchronous gating on the os-*-config tools. Change-Id: I0f6d153c06993ffd0d90bd8ca1717462e8b6b541
This commit is contained in:
parent
20879b2ec9
commit
e822a0ff5a
@ -2,8 +2,9 @@ Inject a PyPI mirror
|
||||
====================
|
||||
|
||||
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.
|
||||
~/.cache/image-create/pypi/mirror into the build environment as mirror URL
|
||||
file:///tmp/pypi. The element temporarily overwrites /root/.pip.conf
|
||||
and .pydistutils.cfg to use it.
|
||||
|
||||
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
|
||||
@ -23,6 +24,7 @@ you have more than 9 additional mirrors, some care will be needed.
|
||||
A typical use of this element is thus:
|
||||
export PYPI\_MIRROR\_URL=http://site/pypi/Ubuntu-13.10
|
||||
export PYPI\_MIRROR\_URL\_1=http://site/pypi/
|
||||
export PYPI\_MIRROR\_URL\_2=file:///tmp/pypi
|
||||
|
||||
[pypi-mirror](https://git.openstack.org/cgit/openstack-infra/pypi-mirror) can
|
||||
be useful in making a partial PyPI mirror suitable for building images. For
|
||||
|
@ -3,13 +3,10 @@
|
||||
set -eu
|
||||
set -o pipefail
|
||||
|
||||
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/
|
||||
if [ -d "$MIRROR_SOURCE" ]; then
|
||||
MIRROR_TARGET=$TMP_MOUNT_PATH/tmp/pypi
|
||||
|
||||
sudo mkdir -p $MIRROR_SOURCE $MIRROR_TARGET
|
||||
sudo mount --bind $MIRROR_SOURCE $TMP_MOUNT_PATH/tmp/pypi
|
||||
sudo mount --bind $MIRROR_SOURCE $MIRROR_TARGET
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user