Skip to content

Commit 9da38ef

Browse files
committed
use uv over pip in Python Dockerfiles
1 parent 2f300cc commit 9da38ef

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

sdks/python/container/Dockerfile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ RUN \
4747
&& \
4848
rm -rf /var/lib/apt/lists/* && \
4949

50-
pip install --upgrade pip setuptools wheel && \
50+
pip install --upgrade pip setuptools wheel uv && \
5151

5252
# Install required packages for Beam Python SDK and common dependencies used by users.
5353
# use --no-deps to ensure the list includes all transitive dependencies.
54-
pip install --no-deps -r /tmp/base_image_requirements.txt --extra-index-url https://download.pytorch.org/whl/cpu && \
54+
uv pip install --no-deps -r /tmp/base_image_requirements.txt --extra-index-url https://download.pytorch.org/whl/cpu && \
5555
rm -rf /tmp/base_image_requirements.txt && \
5656
python -c "import nltk; nltk.download('stopwords')" && \
5757
rm /root/nltk_data/corpora/stopwords.zip && \
@@ -75,17 +75,17 @@ RUN \
7575

7676
# Install Apache Beam SDK. Use --no-deps and pip check to verify that all
7777
# necessary dependencies are specified in base_image_requirements.txt.
78-
pip install --no-deps -v /opt/apache/beam/tars/apache-beam.tar.gz[gcp] && \
79-
pip check || (echo "Container does not include required Beam dependencies or has conflicting dependencies. If Beam dependencies have changed, you need to regenerate base_image_requirements.txt files. See: https://s.apache.org/beam-python-requirements-generate" && exit 1) && \
78+
uv pip install --no-deps -v /opt/apache/beam/tars/apache-beam.tar.gz[gcp] && \
79+
uv pip check || (echo "Container does not include required Beam dependencies or has conflicting dependencies. If Beam dependencies have changed, you need to regenerate base_image_requirements.txt files. See: https://s.apache.org/beam-python-requirements-generate" && exit 1) && \
8080

8181
# Log complete list of what exact packages and versions are installed.
82-
pip freeze --all && \
82+
uv pip freeze --all && \
8383

8484
# Remove pip cache.
8585
rm -rf /root/.cache/pip && \
8686

8787
# Update ensurepip to use most recent versions of setuptools and pip. This avoids some vulnerabilities which won't be fixed on older versions of python.
88-
pip install upgrade_ensurepip; \
88+
uv pip install upgrade_ensurepip; \
8989
python3 -m upgrade_ensurepip; \
9090
find /usr/local/lib/python${py_version}/ensurepip/_bundled/setuptools-* -type f ! -name $(basename $(ls -v /usr/local/lib/python${py_version}/ensurepip/_bundled/setuptools-*-py3-none-any.whl | tail -n 1)) -delete; \
9191
find /usr/local/lib/python${py_version}/ensurepip/_bundled/pip-* -type f ! -name $(basename $(ls -v /usr/local/lib/python${py_version}/ensurepip/_bundled/pip-*-py3-none-any.whl | tail -n 1)) -delete; \

0 commit comments

Comments
 (0)