Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions sdks/python/container/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ RUN \
&& \
rm -rf /var/lib/apt/lists/* && \

pip install --upgrade pip setuptools wheel && \
pip install --upgrade "pip>=26.1" setuptools wheel && \

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pip install --upgrade pip should install the latest version. are we seeing different behavior here?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Saw some container images still using 25.0.1. Is there a better way to do this? Thanks.


# Install required packages for Beam Python SDK and common dependencies used by users.
# use --no-deps to ensure the list includes all transitive dependencies.
Expand Down Expand Up @@ -101,7 +101,8 @@ RUN \
if [ "${py_version}" = "3.10" ] || [ "${py_version}" = "3.11" ]; then \
pip uninstall upgrade_ensurepip -y; \
fi; \
python3 -m ensurepip;
python3 -m ensurepip && \
python3 -c "import ensurepip; assert list(map(int, ensurepip._PIP_VERSION.split('.'))) >= [26, 1], f'Bundled pip version {ensurepip._PIP_VERSION} is older than 26.1';"
Comment on lines +104 to +105

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

Using ensurepip._PIP_VERSION checks the version of pip bundled with the Python standard library's ensurepip module, rather than the upgraded version of pip installed in the environment. Since Python 3.10 and 3.11 bundle older versions of pip (e.g., 23.x), this assertion will always fail and break the Docker build.

To verify the actual installed version of pip, you should import pip and check pip.__version__ instead.

    python3 -m ensurepip && \
    python3 -c "import pip; assert list(map(int, pip.__version__.split('.')[:2])) >= [26, 1], f'Installed pip version {pip.__version__} is older than 26.1';"


ENTRYPOINT ["/opt/apache/beam/boot"]

Expand Down
Loading