Skip to content

Commit d2d7ef8

Browse files
authored
Prefer binary wheels when installing Python container dependencies (#39402)
* Speed up Python container builds with prefer-binary and registry cache * Address review * Drop docker registry cache --------- Co-authored-by: Abdelrahman Ibrahim <aeldsouky.c>
1 parent 22a5951 commit d2d7ef8

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

sdks/python/container/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ RUN \
5353

5454
# Install required packages for Beam Python SDK and common dependencies used by users.
5555
# use --no-deps to ensure the list includes all transitive dependencies.
56-
pip install --no-deps -r /tmp/base_image_requirements.txt --extra-index-url https://download.pytorch.org/whl/cpu && \
56+
# use --prefer-binary to avoid compiling wheels from source when prebuilt wheels exist.
57+
pip install --prefer-binary --no-deps -r /tmp/base_image_requirements.txt --extra-index-url https://download.pytorch.org/whl/cpu && \
5758
rm -rf /tmp/base_image_requirements.txt && \
5859
python -c "import nltk; nltk.download('stopwords')" && \
5960
rm /root/nltk_data/corpora/stopwords.zip && \

sdks/python/container/run_generate_requirements.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ fi
9393
# Force torch dependencies to be pulled from the PyTorch CPU wheel
9494
# repository so that they don't include GPU dependencies with
9595
# non-compliant licenses
96-
pip install ${PIP_EXTRA_OPTIONS:+"$PIP_EXTRA_OPTIONS"} --no-cache-dir "$SDK_TARBALL""$EXTRAS" $INDEX_URL_OPTION
97-
pip install ${PIP_EXTRA_OPTIONS:+"$PIP_EXTRA_OPTIONS"} --no-cache-dir -r "$PWD"/sdks/python/container/base_image_requirements_manual.txt
96+
pip install --prefer-binary ${PIP_EXTRA_OPTIONS:+"$PIP_EXTRA_OPTIONS"} --no-cache-dir "$SDK_TARBALL""$EXTRAS" $INDEX_URL_OPTION
97+
pip install --prefer-binary ${PIP_EXTRA_OPTIONS:+"$PIP_EXTRA_OPTIONS"} --no-cache-dir -r "$PWD"/sdks/python/container/base_image_requirements_manual.txt
9898

9999
pip uninstall -y apache-beam
100100
echo "Checking for broken dependencies:"

0 commit comments

Comments
 (0)