Skip to content

Commit 0516feb

Browse files
authored
refactor: use get-pip.py to install pip (#11)
add requirement files for 3.12 and 3.13 update ci to keep the cache alive
1 parent 2f1dc19 commit 0516feb

File tree

14 files changed

+195
-42
lines changed

14 files changed

+195
-42
lines changed

.github/workflows/autoupdate.yml

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ name: auto-update
22

33
on:
44
schedule:
5-
- cron: '0 18 10 2-12/2 *'
5+
- cron: '0 0 14,28 * *'
6+
- cron: '0 0 10 2-12/2 *'
67
workflow_dispatch:
78

89
jobs:
@@ -13,6 +14,7 @@ jobs:
1314
uses: actions/checkout@v4
1415

1516
- name: Fetch latest Python 3.12 release
17+
if: ${{ github.event.schedule == '0 18 10 2-12/2 *' || github.event_name == 'workflow_dispatch' }}
1618
run: |
1719
python_version=$(curl -s https://www.python.org/ftp/python/ | grep -oP '3\.12\.\d+/' | uniq | sort -V | tail -n 1 | tr -d '/')
1820
@@ -23,6 +25,7 @@ jobs:
2325
sed -i "s/3\.12\.[0-9]\+\([-a-z]*\)/$python_version\1/g" README.md
2426
2527
- name: Fetch latest Python 3.13 release
28+
if: ${{ github.event.schedule == '0 18 10 2-12/2 *' || github.event_name == 'workflow_dispatch' }}
2629
run: |
2730
python_version=$(curl -s https://www.python.org/ftp/python/ | grep -oP '3\.13\.\d+/' | uniq | sort -V | tail -n 1 | tr -d '/')
2831
@@ -32,6 +35,32 @@ jobs:
3235
sed -i "s/ENV PYTHON_VERSION=.*/ENV PYTHON_VERSION=$python_version/" 3.13/slim-bookworm/Dockerfile
3336
sed -i "s/3\.13\.[0-9]\+\([-a-z]*\)/$python_version\1/g" README.md
3437
38+
- name: Update requirements
39+
uses: coatl-dev/actions/pip-compile@v3
40+
with:
41+
path: requirements/3.12
42+
python-version: '3.12'
43+
44+
- name: Update requirements
45+
uses: coatl-dev/actions/pip-compile@v3
46+
with:
47+
path: requirements/3.13
48+
python-version: '3.13'
49+
50+
- name: Extract package versions and update Dockerfile
51+
run: |
52+
pip312=$(grep '^pip==' requirements/3.12/pip.txt | cut -d'=' -f3)
53+
pip313=$(grep '^pip==' requirements/3.13/pip.txt | cut -d'=' -f3)
54+
55+
echo "Extracted versions:"
56+
echo "pip3.12: $pip312"
57+
echo "pip3.13: $pip313"
58+
59+
sed -i "s/ENV PYTHON_PIP_VERSION=.*/ENV PYTHON_PIP_VERSION=$pip312/" 3.12/bookworm/Dockerfile
60+
sed -i "s/ENV PYTHON_PIP_VERSION=.*/ENV PYTHON_PIP_VERSION=$pip312/" 3.12/slim-bookworm/Dockerfile
61+
sed -i "s/ENV PYTHON_PIP_VERSION=.*/ENV PYTHON_PIP_VERSION=$pip313/" 3.13/bookworm/Dockerfile
62+
sed -i "s/ENV PYTHON_PIP_VERSION=.*/ENV PYTHON_PIP_VERSION=$pip313/" 3.13/slim-bookworm/Dockerfile
63+
3564
- name: Detect changes
3665
id: git-diff
3766
uses: coatl-dev/actions/simple-git-diff@v3

.github/workflows/publish-3.12.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
- '.github/workflows/publish-3.12.yml'
99
- '3.12/**'
1010
schedule:
11-
- cron: '0 20 14,28 * *'
11+
- cron: '0 20 * * 1,5'
1212

1313
jobs:
1414
tagger:

.github/workflows/publish-3.13.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ name: publish-3.13
22

33
on:
44
push:
5-
branches:
5+
branches:
66
- 'coatl'
7-
paths:
7+
paths:
88
- '.github/workflows/publish-3.13.yml'
99
- '3.13/**'
1010
schedule:
11-
- cron: '0 20 14,28 * *'
11+
- cron: '0 20 * * 0,4'
1212

1313
jobs:
1414
tagger:
@@ -64,4 +64,4 @@ jobs:
6464
tags: ${{ matrix.image.tags }}
6565
username: ${{ vars.DOCKERHUB_USERNAME }}
6666
secrets:
67-
password: ${{ secrets.DOCKERHUB_TOKEN }}
67+
password: ${{ secrets.DOCKERHUB_TOKEN }}

2.7/bookworm/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ RUN set -eux; \
2626
\
2727
apt-get update --quiet; \
2828
apt-get upgrade --yes; \
29-
apt-get install --yes --no-install-recommends \
29+
apt-get install -y --no-install-recommends \
3030
tk-dev \
3131
; \
3232
rm -rf /var/lib/apt/lists/*
@@ -52,7 +52,7 @@ RUN set -eux; \
5252
--enable-shared \
5353
--enable-unicode=ucs4 \
5454
; \
55-
make -s -j "$(nproc)" \
55+
make -j "$(nproc)" \
5656
# setting PROFILE_TASK makes "--enable-optimizations" reasonable: https://bugs.python.org/issue36044 / https://github.com/docker-library/python/issues/160#issuecomment-509426916
5757
PROFILE_TASK='-m test.regrtest --pgo \
5858
test_array \

2.7/slim-bookworm/Dockerfile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ RUN set -eux; \
2727
\
2828
apt-get update --quiet; \
2929
apt-get upgrade --yes; \
30-
apt-get install --yes --no-install-recommends \
30+
apt-get install -y --no-install-recommends \
3131
ca-certificates \
3232
netbase \
3333
tzdata \
@@ -42,7 +42,7 @@ RUN set -eux; \
4242
\
4343
savedAptMark="$(apt-mark showmanual)"; \
4444
apt-get update --quiet; \
45-
apt-get install --yes --no-install-recommends \
45+
apt-get install -y --no-install-recommends \
4646
dpkg-dev \
4747
gcc \
4848
gnupg \
@@ -76,7 +76,7 @@ RUN set -eux; \
7676
--enable-shared \
7777
--enable-unicode=ucs4 \
7878
; \
79-
make -s -j "$(nproc)" \
79+
make -j "$(nproc)" \
8080
# setting PROFILE_TASK makes "--enable-optimizations" reasonable: https://bugs.python.org/issue36044 / https://github.com/docker-library/python/issues/160#issuecomment-509426916
8181
PROFILE_TASK='-m test.regrtest --pgo \
8282
test_array \
@@ -127,7 +127,7 @@ RUN set -eux; \
127127
| sort -u \
128128
| xargs -r apt-mark manual \
129129
; \
130-
apt-get purge --yes --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
130+
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
131131
rm -rf /var/lib/apt/lists/*; \
132132
\
133133
cd /; \
@@ -150,14 +150,14 @@ RUN set -ex; \
150150
\
151151
savedAptMark="$(apt-mark showmanual)"; \
152152
apt-get update --quiet; \
153-
apt-get install --yes --no-install-recommends wget; \
153+
apt-get install -y --no-install-recommends wget; \
154154
\
155155
wget -q -O get-pip.py "$PYTHON_GET_PIP_URL"; \
156156
echo "$PYTHON_GET_PIP_SHA256 *get-pip.py" | sha256sum --check --strict -; \
157157
\
158158
apt-mark auto '.*' > /dev/null; \
159159
[ -z "$savedAptMark" ] || apt-mark manual $savedAptMark; \
160-
apt-get purge --yes --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
160+
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
161161
rm -rf /var/lib/apt/lists/*; \
162162
\
163163
python get-pip.py \

3.12/bookworm/Dockerfile

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,20 @@ RUN set -eux; \
4848
--enable-shared \
4949
--with-lto \
5050
--with-system-expat \
51-
--with-ensurepip \
51+
--without-ensurepip \
5252
; \
5353
nproc="$(nproc)"; \
5454
EXTRA_CFLAGS="$(dpkg-buildflags --get CFLAGS)"; \
5555
LDFLAGS="$(dpkg-buildflags --get LDFLAGS)"; \
56-
make -s -j "$nproc" \
56+
make -j "$nproc" \
5757
"EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \
5858
"LDFLAGS=${LDFLAGS:-}" \
5959
"PROFILE_TASK=${PROFILE_TASK:-}" \
6060
; \
6161
# https://github.com/docker-library/python/issues/784
6262
# prevent accidental usage of a system installed libpython of the same version
6363
rm python; \
64-
make -s -j "$nproc" \
64+
make -j "$nproc" \
6565
"EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \
6666
"LDFLAGS=${LDFLAGS:--Wl},-rpath='\$\$ORIGIN/../lib'" \
6767
"PROFILE_TASK=${PROFILE_TASK:-}" \
@@ -88,17 +88,38 @@ RUN set -eux; \
8888
ldconfig; \
8989
\
9090
export PYTHONDONTWRITEBYTECODE=1; \
91-
python3 --version; \
92-
pip3 --version
91+
python3 --version
9392

9493
# make some useful symlinks that are expected to exist ("/usr/local/bin/python" and friends)
9594
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
9695
RUN set -eux; \
97-
for src in idle3 pip3 pydoc3 python3 python3-config; do \
96+
for src in idle3 pydoc3 python3 python3-config; do \
9897
dst="$(echo "$src" | tr -d 3)"; \
9998
[ -s "/usr/local/bin/$src" ]; \
10099
[ ! -e "/usr/local/bin/$dst" ]; \
101100
ln -svT "$src" "/usr/local/bin/$dst"; \
102101
done
103102

103+
# if this is called "PIP_VERSION", pip explodes with "ValueError: invalid truth value '<VERSION>'"
104+
ENV PYTHON_PIP_VERSION=24.2
105+
# https://github.com/pypa/get-pip
106+
ENV PYTHON_GET_PIP_URL=https://raw.githubusercontent.com/pypa/get-pip/HEAD/public/get-pip.py
107+
108+
RUN set -eux; \
109+
\
110+
wget -q -O get-pip.py "$PYTHON_GET_PIP_URL"; \
111+
\
112+
export PYTHONDONTWRITEBYTECODE=1; \
113+
\
114+
python get-pip.py \
115+
--disable-pip-version-check \
116+
--no-compile \
117+
"pip==$PYTHON_PIP_VERSION" \
118+
--no-setuptools \
119+
--no-wheel \
120+
; \
121+
rm -f get-pip.py; \
122+
\
123+
pip --version
124+
104125
CMD ["python3"]

3.12/slim-bookworm/Dockerfile

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,21 +75,21 @@ RUN set -eux; \
7575
--enable-shared \
7676
--with-lto \
7777
--with-system-expat \
78-
--with-ensurepip \
78+
--without-ensurepip \
7979
; \
8080
nproc="$(nproc)"; \
8181
EXTRA_CFLAGS="$(dpkg-buildflags --get CFLAGS)"; \
8282
LDFLAGS="$(dpkg-buildflags --get LDFLAGS)"; \
8383
LDFLAGS="${LDFLAGS:--Wl},--strip-all"; \
84-
make -s -j "$nproc" \
84+
make -j "$nproc" \
8585
"EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \
8686
"LDFLAGS=${LDFLAGS:-}" \
8787
"PROFILE_TASK=${PROFILE_TASK:-}" \
8888
; \
8989
# https://github.com/docker-library/python/issues/784
9090
# prevent accidental usage of a system installed libpython of the same version
9191
rm python; \
92-
make -s -j "$nproc" \
92+
make -j "$nproc" \
9393
"EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \
9494
"LDFLAGS=${LDFLAGS:--Wl},-rpath='\$\$ORIGIN/../lib'" \
9595
"PROFILE_TASK=${PROFILE_TASK:-}" \
@@ -123,16 +123,46 @@ RUN set -eux; \
123123
rm -rf /var/lib/apt/lists/*; \
124124
\
125125
export PYTHONDONTWRITEBYTECODE=1; \
126-
python3 --version; \
127-
pip3 --version
126+
python3 --version
128127

129128
# make some useful symlinks that are expected to exist ("/usr/local/bin/python" and friends)
130129
RUN set -eux; \
131-
for src in idle3 pip3 pydoc3 python3 python3-config; do \
130+
for src in idle3 pydoc3 python3 python3-config; do \
132131
dst="$(echo "$src" | tr -d 3)"; \
133132
[ -s "/usr/local/bin/$src" ]; \
134133
[ ! -e "/usr/local/bin/$dst" ]; \
135134
ln -svT "$src" "/usr/local/bin/$dst"; \
136135
done
137136

137+
# if this is called "PIP_VERSION", pip explodes with "ValueError: invalid truth value '<VERSION>'"
138+
ENV PYTHON_PIP_VERSION=24.2
139+
# https://github.com/pypa/get-pip
140+
ENV PYTHON_GET_PIP_URL=https://raw.githubusercontent.com/pypa/get-pip/HEAD/public/get-pip.py
141+
142+
RUN set -eux; \
143+
\
144+
savedAptMark="$(apt-mark showmanual)"; \
145+
apt-get update; \
146+
apt-get install -y --no-install-recommends wget; \
147+
\
148+
wget -q -O get-pip.py "$PYTHON_GET_PIP_URL"; \
149+
\
150+
apt-mark auto '.*' > /dev/null; \
151+
[ -z "$savedAptMark" ] || apt-mark manual $savedAptMark > /dev/null; \
152+
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
153+
rm -rf /var/lib/apt/lists/*; \
154+
\
155+
export PYTHONDONTWRITEBYTECODE=1; \
156+
\
157+
python get-pip.py \
158+
--disable-pip-version-check \
159+
--no-compile \
160+
"pip==$PYTHON_PIP_VERSION" \
161+
--no-setuptools \
162+
--no-wheel \
163+
; \
164+
rm -f get-pip.py; \
165+
\
166+
pip --version
167+
138168
CMD ["python3"]

3.13/bookworm/Dockerfile

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,20 +43,20 @@ RUN set -eux; \
4343
--enable-shared \
4444
--with-lto \
4545
--with-system-expat \
46-
--with-ensurepip \
46+
--without-ensurepip \
4747
; \
4848
nproc="$(nproc)"; \
4949
EXTRA_CFLAGS="$(dpkg-buildflags --get CFLAGS)"; \
5050
LDFLAGS="$(dpkg-buildflags --get LDFLAGS)"; \
51-
make -s -j "$nproc" \
51+
make -j "$nproc" \
5252
"EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \
5353
"LDFLAGS=${LDFLAGS:-}" \
5454
"PROFILE_TASK=${PROFILE_TASK:-}" \
5555
; \
5656
# https://github.com/docker-library/python/issues/784
5757
# prevent accidental usage of a system installed libpython of the same version
5858
rm python; \
59-
make -s -j "$nproc" \
59+
make -j "$nproc" \
6060
"EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \
6161
"LDFLAGS=${LDFLAGS:--Wl},-rpath='\$\$ORIGIN/../lib'" \
6262
"PROFILE_TASK=${PROFILE_TASK:-}" \
@@ -83,17 +83,38 @@ RUN set -eux; \
8383
ldconfig; \
8484
\
8585
export PYTHONDONTWRITEBYTECODE=1; \
86-
python3 --version; \
87-
pip3 --version
86+
python3 --version
8887

8988
# make some useful symlinks that are expected to exist ("/usr/local/bin/python" and friends)
9089
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
9190
RUN set -eux; \
92-
for src in idle3 pip3 pydoc3 python3 python3-config; do \
91+
for src in idle3 pydoc3 python3 python3-config; do \
9392
dst="$(echo "$src" | tr -d 3)"; \
9493
[ -s "/usr/local/bin/$src" ]; \
9594
[ ! -e "/usr/local/bin/$dst" ]; \
9695
ln -svT "$src" "/usr/local/bin/$dst"; \
9796
done
9897

98+
# if this is called "PIP_VERSION", pip explodes with "ValueError: invalid truth value '<VERSION>'"
99+
ENV PYTHON_PIP_VERSION=24.2
100+
# https://github.com/pypa/get-pip
101+
ENV PYTHON_GET_PIP_URL=https://raw.githubusercontent.com/pypa/get-pip/HEAD/public/get-pip.py
102+
103+
RUN set -eux; \
104+
\
105+
wget -q -O get-pip.py "$PYTHON_GET_PIP_URL"; \
106+
\
107+
export PYTHONDONTWRITEBYTECODE=1; \
108+
\
109+
python get-pip.py \
110+
--disable-pip-version-check \
111+
--no-compile \
112+
"pip==$PYTHON_PIP_VERSION" \
113+
--no-setuptools \
114+
--no-wheel \
115+
; \
116+
rm -f get-pip.py; \
117+
\
118+
pip --version
119+
99120
CMD ["python3"]

0 commit comments

Comments
 (0)