Add constraints support to python-builder
If someone drops an upper-constraints.txt into the source dir, add it to the pip interactions. Change-Id: I6b3c2a178d6fd9ee19918657c809ebf100a7724b
This commit is contained in:
parent
90fa9170dd
commit
cee7903827
@ -60,16 +60,16 @@ function install_wheels {
|
|||||||
# Only do this for the main package (i.e. only write requirements
|
# Only do this for the main package (i.e. only write requirements
|
||||||
# once).
|
# once).
|
||||||
if [ -f /tmp/src/requirements.txt ] && [ ! -f /output/requirements.txt ] ; then
|
if [ -f /tmp/src/requirements.txt ] && [ ! -f /output/requirements.txt ] ; then
|
||||||
/tmp/venv/bin/pip install --cache-dir=/output/wheels -r /tmp/src/requirements.txt
|
/tmp/venv/bin/pip install $CONSTRAINTS --cache-dir=/output/wheels -r /tmp/src/requirements.txt
|
||||||
cp /tmp/src/requirements.txt /output/requirements.txt
|
cp /tmp/src/requirements.txt /output/requirements.txt
|
||||||
fi
|
fi
|
||||||
/tmp/venv/bin/pip install --cache-dir=/output/wheels /output/wheels/*whl
|
/tmp/venv/bin/pip install $CONSTRAINTS --cache-dir=/output/wheels /output/wheels/*whl
|
||||||
|
|
||||||
# Install each of the extras so that we collect all possibly
|
# Install each of the extras so that we collect all possibly
|
||||||
# needed wheels in the wheel cache. get-extras-packages also
|
# needed wheels in the wheel cache. get-extras-packages also
|
||||||
# writes out the req files into /output/$extra/requirements.txt.
|
# writes out the req files into /output/$extra/requirements.txt.
|
||||||
for req in $(get-extras-packages) ; do
|
for req in $(get-extras-packages) ; do
|
||||||
/tmp/venv/bin/pip install --cache-dir=/output/wheels "$req"
|
/tmp/venv/bin/pip install $CONSTRAINTS --cache-dir=/output/wheels "$req"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,10 +90,17 @@ done
|
|||||||
python -m venv /tmp/venv
|
python -m venv /tmp/venv
|
||||||
/tmp/venv/bin/pip install -U pip wheel
|
/tmp/venv/bin/pip install -U pip wheel
|
||||||
|
|
||||||
|
# If there is an upper-constraints.txt file in the source tree,
|
||||||
|
# use it in the pip commands.
|
||||||
|
if [ -f /tmp/src/upper-constraints.txt ] ; then
|
||||||
|
cp /tmp/src/upper-constraints.txt /output/upper-constraints.txt
|
||||||
|
CONSTRAINTS="-c /tmp/src/upper-constraints.txt"
|
||||||
|
fi
|
||||||
|
|
||||||
# If we got a list of packages, install them, otherwise install the
|
# If we got a list of packages, install them, otherwise install the
|
||||||
# main package.
|
# main package.
|
||||||
if [[ $PACKAGES ]] ; then
|
if [[ $PACKAGES ]] ; then
|
||||||
/tmp/venv/bin/pip install --cache-dir=/output/wheels $PACKAGES
|
/tmp/venv/bin/pip install $CONSTRAINTS --cache-dir=/output/wheels $PACKAGES
|
||||||
for package in $PACKAGES ; do
|
for package in $PACKAGES ; do
|
||||||
echo "$package" >> /output/packages.txt
|
echo "$package" >> /output/packages.txt
|
||||||
done
|
done
|
||||||
|
@ -18,12 +18,18 @@ set -e
|
|||||||
|
|
||||||
apt-get update
|
apt-get update
|
||||||
apt-get -y install $(cat /output/bindep/run.txt)
|
apt-get -y install $(cat /output/bindep/run.txt)
|
||||||
|
|
||||||
|
# If there's a constraints file, use it.
|
||||||
|
if [ -f /output/upper-constraints.txt ] ; then
|
||||||
|
CONSTRAINTS="-c /output/upper-constraints.txt"
|
||||||
|
fi
|
||||||
|
|
||||||
# If a requirements.txt file exists,
|
# If a requirements.txt file exists,
|
||||||
# install it directly so that people can use git url syntax
|
# install it directly so that people can use git url syntax
|
||||||
# to do things like pick up patched but unreleased versions
|
# to do things like pick up patched but unreleased versions
|
||||||
# of dependencies.
|
# of dependencies.
|
||||||
if [ -f /output/requirements.txt ] ; then
|
if [ -f /output/requirements.txt ] ; then
|
||||||
pip install --cache-dir=/output/wheels -r /output/requirements.txt
|
pip install $CONSTRAINTS --cache-dir=/output/wheels -r /output/requirements.txt
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Add any requested extras to the list of things to install
|
# Add any requested extras to the list of things to install
|
||||||
@ -35,13 +41,13 @@ done
|
|||||||
if [ -f /output/packages.txt ] ; then
|
if [ -f /output/packages.txt ] ; then
|
||||||
# If a package list was passed to assemble, install that in the final
|
# If a package list was passed to assemble, install that in the final
|
||||||
# image.
|
# image.
|
||||||
pip install --cache-dir=/output/wheels -r /output/packages.txt $EXTRAS
|
pip install $CONSTRAINTS --cache-dir=/output/wheels -r /output/packages.txt $EXTRAS
|
||||||
else
|
else
|
||||||
# Install the wheels. Use --force here because sibling wheels might
|
# Install the wheels. Use --force here because sibling wheels might
|
||||||
# be built with the same version number as the latest release, but we
|
# be built with the same version number as the latest release, but we
|
||||||
# really want the speculatively built wheels installed over any
|
# really want the speculatively built wheels installed over any
|
||||||
# automatic dependencies.
|
# automatic dependencies.
|
||||||
pip install --force --cache-dir=/output/wheels /output/wheels/*.whl $EXTRAS
|
pip install $CONSTRAINTS --force --cache-dir=/output/wheels /output/wheels/*.whl $EXTRAS
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# clean up after ourselves
|
# clean up after ourselves
|
||||||
|
Loading…
Reference in New Issue
Block a user