Skip to content

Commit

Permalink
refactor(requirements): create requirements files for pip (#145)
Browse files Browse the repository at this point in the history
3.12/pip.txt
3.13/pip.txt
  • Loading branch information
cesarcoatl authored Oct 8, 2024
1 parent 546d325 commit 32c3837
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 6 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/auto-update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
42 changes: 36 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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)"; \
Expand Down Expand Up @@ -253,15 +253,30 @@ RUN set -eux; \
\) -exec rm -rf '{}' + \
;

# if this is called "PIP_VERSION", pip explodes with "ValueError: invalid truth value '<VERSION>'"
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; \
\
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; \
Expand Down Expand Up @@ -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)"; \
Expand Down Expand Up @@ -328,14 +343,29 @@ RUN set -eux; \
\) -exec rm -rf '{}' + \
;

# if this is called "PIP_VERSION", pip explodes with "ValueError: invalid truth value '<VERSION>'"
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; \
Expand Down
1 change: 1 addition & 0 deletions requirements/3.12/pip.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pip
10 changes: 10 additions & 0 deletions requirements/3.12/pip.txt
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions requirements/3.13/pip.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pip
10 changes: 10 additions & 0 deletions requirements/3.13/pip.txt
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 32c3837

Please sign in to comment.