From fc5bf58111933eefad3c479ac803daf8df2b9527 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=9Clgen=20Sar=C4=B1kavak?= Date: Tue, 22 Oct 2024 09:43:24 +0300 Subject: [PATCH 1/3] Bump pyenv to 2.4.16 --- python/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/Dockerfile b/python/Dockerfile index 7729665d289..1f30f8d276a 100644 --- a/python/Dockerfile +++ b/python/Dockerfile @@ -5,7 +5,7 @@ ARG PY_3_11=3.11.9 ARG PY_3_10=3.10.15 ARG PY_3_9=3.9.18 ARG PY_3_8=3.8.20 -ARG PYENV_VERSION=v2.3.35 +ARG PYENV_VERSION=v2.4.16 FROM ghcr.io/dependabot/dependabot-updater-core as python-core ARG PY_3_12 From 63d0ba97655ca776b5d110cbced0b33ecf589c27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=9Clgen=20Sar=C4=B1kavak?= Date: Tue, 22 Oct 2024 09:43:36 +0300 Subject: [PATCH 2/3] Add Python 3.13 support --- python/Dockerfile | 27 ++++++++++++++++--- .../python/language_version_manager.rb | 1 + .../dependabot/python/file_fetcher_spec.rb | 2 +- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/python/Dockerfile b/python/Dockerfile index 1f30f8d276a..07367b5dc3f 100644 --- a/python/Dockerfile +++ b/python/Dockerfile @@ -1,5 +1,6 @@ # This list must match the versions specified in # python/lib/dependabot/python/language_version_manager.rb: PRE_INSTALLED_PYTHON_VERSIONS +ARG PY_3_13=3.13.0 ARG PY_3_12=3.12.5 ARG PY_3_11=3.11.9 ARG PY_3_10=3.10.15 @@ -8,6 +9,7 @@ ARG PY_3_8=3.8.20 ARG PYENV_VERSION=v2.4.16 FROM ghcr.io/dependabot/dependabot-updater-core as python-core +ARG PY_3_13 ARG PY_3_12 ARG PY_3_11 ARG PY_3_10 @@ -120,6 +122,24 @@ RUN find $PYTHON_INSTALL_LOCATION/bin -type f -exec sed -i "1s|^#!/usr/local/bin # Ensure pyenv works and it's the python version we expect RUN PYENV_VERSION=$PY_3_12 pyenv exec python --version | grep "Python $PY_3_12" || exit 1 RUN bash /opt/python/helpers/build $PY_3_12 +# This python environment occupies ~0.5 GB and gets used for a fraction of jobs, so store it compressed. +RUN cd $PYENV_ROOT/versions \ + && tar -acf $PY_3_12.tar.zst $PY_3_12 + +## 3.13 +# Docker doesn't support parametrizing `COPY --from:python:$PY_1_23-bookworm`, so work around it using an alias. +# TODO: If upstream adds support for Ubuntu, use that instead of Debian as the base suffix: https://github.com/docker-library/python/pull/791 +FROM docker.io/library/python:$PY_3_13-bookworm as upstream-python-3.13 +FROM python-core as python-3.13 +ARG PYTHON_INSTALL_LOCATION="$PYENV_ROOT/versions/$PY_3_13" +COPY --from=upstream-python-3.13 --chown=dependabot:dependabot /usr/local/bin $PYTHON_INSTALL_LOCATION/bin +COPY --from=upstream-python-3.13 --chown=dependabot:dependabot /usr/local/include $PYTHON_INSTALL_LOCATION/include +COPY --from=upstream-python-3.13 --chown=dependabot:dependabot /usr/local/lib $PYTHON_INSTALL_LOCATION/lib +# `pip` and other scripts need their shebangs rewritten for the new location +RUN find $PYTHON_INSTALL_LOCATION/bin -type f -exec sed -i "1s|^#!/usr/local/bin/python|#!${PYTHON_INSTALL_LOCATION}/bin/python|" {} + +# Ensure pyenv works and it's the python version we expect +RUN PYENV_VERSION=$PY_3_13 pyenv exec python --version | grep "Python $PY_3_13" || exit 1 +RUN bash /opt/python/helpers/build $PY_3_13 # This is the default Python, so no need to tar it FROM python-core @@ -152,9 +172,10 @@ COPY --from=python-3.8 $PYENV_ROOT/versions/$PY_3_8.tar.zst $PYENV_ROOT/versions COPY --from=python-3.9 $PYENV_ROOT/versions/$PY_3_9.tar.zst $PYENV_ROOT/versions/$PY_3_9.tar.zst COPY --from=python-3.10 $PYENV_ROOT/versions/$PY_3_10.tar.zst $PYENV_ROOT/versions/$PY_3_10.tar.zst COPY --from=python-3.11 $PYENV_ROOT/versions/$PY_3_11.tar.zst $PYENV_ROOT/versions/$PY_3_11.tar.zst -COPY --from=python-3.12 $PYENV_ROOT/versions/ $PYENV_ROOT/versions/ +COPY --from=python-3.12 $PYENV_ROOT/versions/$PY_3_12.tar.zst $PYENV_ROOT/versions/$PY_3_12.tar.zst +COPY --from=python-3.13 $PYENV_ROOT/versions/ $PYENV_ROOT/versions/ # Copy the output of the build script, it should be identical across Python versions -COPY --from=python-3.12 /opt/python/ /opt/python/ +COPY --from=python-3.13 /opt/python/ /opt/python/ -RUN pyenv global $PY_3_12 +RUN pyenv global $PY_3_13 diff --git a/python/lib/dependabot/python/language_version_manager.rb b/python/lib/dependabot/python/language_version_manager.rb index 4bad712e781..b5654817ed6 100644 --- a/python/lib/dependabot/python/language_version_manager.rb +++ b/python/lib/dependabot/python/language_version_manager.rb @@ -9,6 +9,7 @@ module Python class LanguageVersionManager # This list must match the versions specified at the top of `python/Dockerfile` PRE_INSTALLED_PYTHON_VERSIONS = %w( + 3.13.0 3.12.5 3.11.9 3.10.15 diff --git a/python/spec/dependabot/python/file_fetcher_spec.rb b/python/spec/dependabot/python/file_fetcher_spec.rb index 02ac193113e..38623751baa 100644 --- a/python/spec/dependabot/python/file_fetcher_spec.rb +++ b/python/spec/dependabot/python/file_fetcher_spec.rb @@ -524,7 +524,7 @@ it "exposes the expected ecosystem_versions metric" do expect(file_fetcher_instance.ecosystem_versions).to eq({ - languages: { python: { "max" => "3.12", "raw" => "unknown" } } + languages: { python: { "max" => "3.13", "raw" => "unknown" } } }) end end From 715110358217ad0e28936f9848f7ea0843535874 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=9Clgen=20Sar=C4=B1kavak?= Date: Tue, 22 Oct 2024 09:43:36 +0300 Subject: [PATCH 3/3] Update numpy for Python 3.13 support --- python/spec/fixtures/projects/unresolvable/requirements.in | 2 +- .../fixtures/requirements/pip_compile_native_dependencies.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/python/spec/fixtures/projects/unresolvable/requirements.in b/python/spec/fixtures/projects/unresolvable/requirements.in index 255640a0763..8e44befaec3 100644 --- a/python/spec/fixtures/projects/unresolvable/requirements.in +++ b/python/spec/fixtures/projects/unresolvable/requirements.in @@ -13,7 +13,7 @@ jupyter_nbextensions_configurator librosa numba==0.48 -numpy==1.26.1 +numpy==1.26.4 jax matplotlib diff --git a/python/spec/fixtures/requirements/pip_compile_native_dependencies.txt b/python/spec/fixtures/requirements/pip_compile_native_dependencies.txt index 229472434f8..1d0327d899e 100644 --- a/python/spec/fixtures/requirements/pip_compile_native_dependencies.txt +++ b/python/spec/fixtures/requirements/pip_compile_native_dependencies.txt @@ -8,7 +8,7 @@ asn1crypto==1.4.0 # via cryptography cffi==1.11.5 # via cryptography cryptography==2.2.2 # via -r requirements.in idna==2.10 # via cryptography -numpy==1.26.1 # via -r requirements.in, pandas +numpy==1.26.4 # via -r requirements.in, pandas pandas==2.1.1 # via -r requirements.in pycparser==2.18 # via cffi python-dateutil==2.8.1 # via pandas