Skip to content

Commit 0cfd9ca

Browse files
committed
Consolidate python version checks in ensurepip upgrade block
1 parent 53a0113 commit 0cfd9ca

1 file changed

Lines changed: 1 addition & 3 deletions

File tree

sdks/python/container/Dockerfile

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,7 @@ RUN \
9393
python3 -c 'import ensurepip, glob, re; whl = glob.glob(ensurepip.__path__[0] + "/_bundled/pip-*.whl")[-1]; version = re.search(r"pip-(.*?)-py", whl).group(1); init_py = ensurepip.__file__; content = open(init_py).read(); content = re.sub(r"_PIP_VERSION = \".*?\"", f"_PIP_VERSION = \"{version}\"", content); open(init_py, "w").write(content);' && \
9494
if [ "${py_version}" = "3.10" ] || [ "${py_version}" = "3.11" ]; then \
9595
pip download --dest /usr/local/lib/python${py_version}/ensurepip/_bundled/ --only-binary=:all: "setuptools" && \
96-
python3 -c 'import ensurepip, glob, re; whl = glob.glob(ensurepip.__path__[0] + "/_bundled/setuptools-*.whl")[-1]; version = re.search(r"setuptools-(.*?)-py", whl).group(1); init_py = ensurepip.__file__; content = open(init_py).read(); content = re.sub(r"_SETUPTOOLS_VERSION = \".*?\"", f"_SETUPTOOLS_VERSION = \"{version}\"", content); open(init_py, "w").write(content);'; \
97-
fi && \
98-
if [ "${py_version}" = "3.10" ] || [ "${py_version}" = "3.11" ]; then \
96+
python3 -c 'import ensurepip, glob, re; whl = glob.glob(ensurepip.__path__[0] + "/_bundled/setuptools-*.whl")[-1]; version = re.search(r"setuptools-(.*?)-py", whl).group(1); init_py = ensurepip.__file__; content = open(init_py).read(); content = re.sub(r"_SETUPTOOLS_VERSION = \".*?\"", f"_SETUPTOOLS_VERSION = \"{version}\"", content); open(init_py, "w").write(content);' && \
9997
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; \
10098
fi && \
10199
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)