From 32c383751ec18ddd445d628af3d3f3c782551313 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20Rom=C3=A1n?= Date: Tue, 8 Oct 2024 10:57:45 -0700 Subject: [PATCH] refactor(requirements): create requirements files for pip (#145) 3.12/pip.txt 3.13/pip.txt --- .github/workflows/auto-update.yml | 25 ++++++++++++++++++ Dockerfile | 42 ++++++++++++++++++++++++++----- requirements/3.12/pip.in | 1 + requirements/3.12/pip.txt | 10 ++++++++ requirements/3.13/pip.in | 1 + requirements/3.13/pip.txt | 10 ++++++++ 6 files changed, 83 insertions(+), 6 deletions(-) create mode 100644 requirements/3.12/pip.in create mode 100644 requirements/3.12/pip.txt create mode 100644 requirements/3.13/pip.in create mode 100644 requirements/3.13/pip.txt diff --git a/.github/workflows/auto-update.yml b/.github/workflows/auto-update.yml index e868f66..17aac6d 100644 --- a/.github/workflows/auto-update.yml +++ b/.github/workflows/auto-update.yml @@ -2,6 +2,7 @@ name: auto-update on: schedule: + - cron: '0 12 * * 0,4' - cron: '0 18 14,28 * *' # Git - cron: '0 18 10 2-12/2 *' # Python release schedule workflow_dispatch: @@ -40,6 +41,30 @@ jobs: sed -i "s/ENV PYTHON313_VERSION=.*/ENV PYTHON313_VERSION=$python_version/" Dockerfile + - name: Update requirements + uses: coatl-dev/actions/pip-compile@v3 + with: + path: requirements/3.12 + python-version: '3.12' + + - name: Update requirements + uses: coatl-dev/actions/pip-compile@v3 + with: + path: requirements/3.13 + python-version: '3.13' + + - name: Extract package versions and update Dockerfile + run: | + pip312=$(grep '^pip==' requirements/3.12/pip.txt | cut -d'=' -f3) + pip313=$(grep '^pip==' requirements/3.13/pip.txt | cut -d'=' -f3) + + echo "Extracted versions:" + echo "pip3.12: $pip312" + echo "pip3.13: $pip313" + + sed -i "s/ENV PYTHON312_PIP_VERSION=.*/ENV PYTHON312_PIP_VERSION=$pip312/" Dockerfile + sed -i "s/ENV PYTHON313_PIP_VERSION=.*/ENV PYTHON313_PIP_VERSION=$pip313/" Dockerfile + - name: Detect changes id: git-diff uses: coatl-dev/actions/simple-git-diff@v3 diff --git a/Dockerfile b/Dockerfile index 45e220b..49b6937 100644 --- a/Dockerfile +++ b/Dockerfile @@ -220,7 +220,7 @@ RUN set -eux; \ --enable-shared \ --with-lto \ --with-system-expat \ - --with-ensurepip \ + --without-ensurepip \ ; \ nproc="$(nproc)"; \ EXTRA_CFLAGS="$(dpkg-buildflags --get CFLAGS)"; \ @@ -253,6 +253,23 @@ RUN set -eux; \ \) -exec rm -rf '{}' + \ ; +# if this is called "PIP_VERSION", pip explodes with "ValueError: invalid truth value ''" +ENV PYTHON312_PIP_VERSION=24.2 +# https://github.com/pypa/get-pip +ENV PYTHON_GET_PIP_URL=https://raw.githubusercontent.com/pypa/get-pip/HEAD/public/get-pip.py + +RUN set -eux; \ + \ + wget -q "$PYTHON_GET_PIP_URL"; \ + \ + export PYTHONDONTWRITEBYTECODE=1; \ + \ + "${PYTHON_ROOT}/3.12/bin/python${PYTHON312_VERSION%.*}" get-pip.py \ + --disable-pip-version-check \ + --no-cache-dir \ + --no-compile \ + "pip==$PYTHON312_PIP_VERSION" + # add some soft links for comfortable usage WORKDIR "${PYTHON_ROOT}/3.12/bin" RUN set -eux; \ @@ -260,8 +277,6 @@ RUN set -eux; \ ln -svT "2to3-${PYTHON312_VERSION%.*}" 2to3; \ ln -svT "idle${PYTHON312_VERSION%.*}" idle3; \ ln -svT "idle${PYTHON312_VERSION%.*}" idle; \ - ln -svT "pip${PYTHON312_VERSION%.*}" pip3; \ - ln -svT "pip${PYTHON312_VERSION%.*}" pip; \ ln -svT "pydoc${PYTHON312_VERSION%.*}" pydoc; \ ln -svT "python${PYTHON312_VERSION%.*}" python3; \ ln -svT "python${PYTHON312_VERSION%.*}" python; \ @@ -295,7 +310,7 @@ RUN set -eux; \ --enable-shared \ --with-lto \ --with-system-expat \ - --with-ensurepip \ + --without-ensurepip \ ; \ nproc="$(nproc)"; \ EXTRA_CFLAGS="$(dpkg-buildflags --get CFLAGS)"; \ @@ -328,14 +343,29 @@ RUN set -eux; \ \) -exec rm -rf '{}' + \ ; +# if this is called "PIP_VERSION", pip explodes with "ValueError: invalid truth value ''" +ENV PYTHON313_PIP_VERSION=24.2 +# https://github.com/pypa/get-pip +ENV PYTHON_GET_PIP_URL=https://raw.githubusercontent.com/pypa/get-pip/HEAD/public/get-pip.py + +RUN set -eux; \ + \ + wget -q "$PYTHON_GET_PIP_URL"; \ + \ + export PYTHONDONTWRITEBYTECODE=1; \ + \ + "${PYTHON_ROOT}/3.13/bin/python${PYTHON313_VERSION%.*}" get-pip.py \ + --disable-pip-version-check \ + --no-cache-dir \ + --no-compile \ + "pip==$PYTHON313_PIP_VERSION" + # add some soft links for comfortable usage WORKDIR "${PYTHON_ROOT}/3.13/bin" RUN set -eux; \ \ ln -svT "idle${PYTHON313_VERSION%.*}" idle3; \ ln -svT "idle${PYTHON313_VERSION%.*}" idle; \ - ln -svT "pip${PYTHON313_VERSION%.*}" pip3; \ - ln -svT "pip${PYTHON313_VERSION%.*}" pip; \ ln -svT "pydoc${PYTHON313_VERSION%.*}" pydoc; \ ln -svT "python${PYTHON313_VERSION%.*}" python3; \ ln -svT "python${PYTHON313_VERSION%.*}" python; \ diff --git a/requirements/3.12/pip.in b/requirements/3.12/pip.in new file mode 100644 index 0000000..4d6aa0d --- /dev/null +++ b/requirements/3.12/pip.in @@ -0,0 +1 @@ +pip \ No newline at end of file diff --git a/requirements/3.12/pip.txt b/requirements/3.12/pip.txt new file mode 100644 index 0000000..8668f38 --- /dev/null +++ b/requirements/3.12/pip.txt @@ -0,0 +1,10 @@ +# +# This file is autogenerated by pip-compile with Python 3.12 +# by the following command: +# +# pip-compile --allow-unsafe pip.in +# + +# The following packages are considered to be unsafe in a requirements file: +pip==24.2 + # via -r pip.in diff --git a/requirements/3.13/pip.in b/requirements/3.13/pip.in new file mode 100644 index 0000000..4d6aa0d --- /dev/null +++ b/requirements/3.13/pip.in @@ -0,0 +1 @@ +pip \ No newline at end of file diff --git a/requirements/3.13/pip.txt b/requirements/3.13/pip.txt new file mode 100644 index 0000000..7ae486e --- /dev/null +++ b/requirements/3.13/pip.txt @@ -0,0 +1,10 @@ +# +# This file is autogenerated by pip-compile with Python 3.13 +# by the following command: +# +# pip-compile --allow-unsafe pip.in +# + +# The following packages are considered to be unsafe in a requirements file: +pip==24.2 + # via -r pip.in