Skip to content

Commit

Permalink
Force PIP not to upgrade any Debian-installed Python packages.
Browse files Browse the repository at this point in the history
This PR amends the `update-constraints.sh` script to automatically
extract from the filesystem the list of Python packages that have
already been installed by Debian, and that PIP should not attempt to
upgrade to any later version.

In addition to the normal `constraints.txt` file, it generates an
additional `pip-constraints.txt` file, to be used to force PIP not to do
anything with the system-managed packages.

This has the side-effect of ensuring that we never upgrade to any
version of setuptools more recent than 72 (known to cause issues with
some packages needed by the ODK), since the version provided by Debian
is 68.1.2.
  • Loading branch information
gouttegd committed Nov 4, 2024
1 parent 1471863 commit 0ef23e1
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
4 changes: 2 additions & 2 deletions constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ SecretStorage==3.3.3
semsimian==0.2.19
semsql==0.3.3
Send2Trash==1.8.3
setuptools==75.3.0
setuptools==68.1.2
ShExJSG==0.8.2
six==1.16.0
sniffio==1.3.1
Expand Down Expand Up @@ -318,7 +318,7 @@ wcwidth==0.2.13
webcolors==24.8.0
webencodings==0.5.1
websocket-client==1.8.0
wheel==0.44.0
wheel==0.42.0
widgetsnbextension==4.0.13
wrapt==1.16.0
xmltodict==0.13.0
Expand Down
2 changes: 1 addition & 1 deletion docker/builder/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ RUN apt-get update && \
COPY requirements.txt.full /build/requirements.txt
COPY requirements.txt.lite /build/requirements.txt.lite
COPY constraints.txt /build/constraints.txt
RUN echo "setuptools<72" > /build/pip-constraints.txt
COPY pip-constraints.txt /build/pip-constraints.txt
# First the packages needed by the odklite image.
RUN PIP_CONSTRAINT=/build/pip-constraints.txt python3 -m pip install \
-r /build/requirements.txt.lite \
Expand Down
6 changes: 6 additions & 0 deletions pip-constraints.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
six==1.16.0
wheel==0.42.0
pip==24.0
setuptools==68.1.2
psycopg2==2.9.9
gyp==0.1
9 changes: 9 additions & 0 deletions update-constraints.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,22 @@

set -e

if [ -d /usr/lib/python3/dist-packages ]; then
# For any Python package already provided by the system, we must
# force PIP to use the exact same version as the one installed
find /usr/lib/python3/dist-packages -type d -name '*-info' | \
sed -E 's,/usr/lib/python3/dist-packages/(.+)-([^-]+)\.(egg|dist)-info,\1==\2,' \
> pip-constraints.txt
fi

if [ "x$1" = x--install-virtualenv ]; then
apt-get update
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends python3-virtualenv
fi

virtualenv tmpdir
. tmpdir/bin/activate
export PIP_CONSTRAINT=$(pwd)/pip-constraints.txt
python3 -m pip install -U pip
python3 -m pip install -r requirements.txt.full
python3 -m pip freeze > constraints.txt
Expand Down

0 comments on commit 0ef23e1

Please sign in to comment.