Skip to content

Commit 2f1dc19

Browse files
authored
feat: add Python 3.13 (#10)
updates: - update coatldev/python:3 tag - get default versions for setuptools and wheel for 2.7 image
1 parent 654d4ae commit 2f1dc19

File tree

9 files changed

+318
-23
lines changed

9 files changed

+318
-23
lines changed

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ root = true
55

66
[*]
77
end_of_line = lf
8-
insert_final_newline = true
98
trim_trailing_whitespace = true
109

1110
[{*.md,*.yaml,*.yml}]
1211
indent_style = space
1312
indent_size = 2
13+
insert_final_newline = true
1414
x-soft-wrap-text = true

.github/workflows/autoupdate.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,16 @@ jobs:
2222
sed -i "s/ENV PYTHON_VERSION=.*/ENV PYTHON_VERSION=$python_version/" 3.12/slim-bookworm/Dockerfile
2323
sed -i "s/3\.12\.[0-9]\+\([-a-z]*\)/$python_version\1/g" README.md
2424
25+
- name: Fetch latest Python 3.13 release
26+
run: |
27+
python_version=$(curl -s https://www.python.org/ftp/python/ | grep -oP '3\.13\.\d+/' | uniq | sort -V | tail -n 1 | tr -d '/')
28+
29+
echo "python3.13: $python_version"
30+
31+
sed -i "s/ENV PYTHON_VERSION=.*/ENV PYTHON_VERSION=$python_version/" 3.13/bookworm/Dockerfile
32+
sed -i "s/ENV PYTHON_VERSION=.*/ENV PYTHON_VERSION=$python_version/" 3.13/slim-bookworm/Dockerfile
33+
sed -i "s/3\.13\.[0-9]\+\([-a-z]*\)/$python_version\1/g" README.md
34+
2535
- name: Detect changes
2636
id: git-diff
2737
uses: coatl-dev/actions/simple-git-diff@v3

.github/workflows/publish-3.12.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,11 @@ jobs:
4848
- version: '3.12'
4949
variant: bookworm
5050
tags: |
51-
${{ needs.tagger.outputs.major }}
5251
${{ needs.tagger.outputs.major_minor }}
5352
${{ needs.tagger.outputs.version }}
5453
- version: '3.12'
5554
variant: slim-bookworm
5655
tags: |
57-
${{ needs.tagger.outputs.major }}-slim
5856
${{ needs.tagger.outputs.major_minor }}-slim
5957
${{ needs.tagger.outputs.version }}-slim
6058
with:

.github/workflows/publish-3.13.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: publish-3.13
2+
3+
on:
4+
push:
5+
branches:
6+
- 'coatl'
7+
paths:
8+
- '.github/workflows/publish-3.13.yml'
9+
- '3.13/**'
10+
schedule:
11+
- cron: '0 20 14,28 * *'
12+
13+
jobs:
14+
tagger:
15+
runs-on: ubuntu-latest
16+
outputs:
17+
major: ${{ steps.tags.outputs.major }}
18+
major_minor: ${{ steps.tags.outputs.major_minor }}
19+
version: ${{ steps.tags.outputs.version }}
20+
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v4
24+
25+
- name: Extract version number
26+
id: tags
27+
run: |
28+
# Extract the Python version from the Dockerfile
29+
VERSION=$(grep 'ENV PYTHON_VERSION' 3.13/bookworm/Dockerfile | cut -d '=' -f 2)
30+
echo "VERSION=${VERSION}"
31+
# Trim the version to the first two segments (major.minor)
32+
MAJOR_MINOR=$(echo $VERSION | cut -d'.' -f1-2)
33+
echo "MAJOR_MINOR=${MAJOR_MINOR}"
34+
# Trim the version to the first segment (major)
35+
MAJOR=$(echo $VERSION | cut -d'.' -f1-1)
36+
echo "MAJOR=${MAJOR}"
37+
# Export the extracted version to GITHUB_OUTPUT
38+
echo "major=${MAJOR}" >> $GITHUB_OUTPUT
39+
echo "major_minor=${MAJOR_MINOR}" >> $GITHUB_OUTPUT
40+
echo "version=${VERSION}" >> $GITHUB_OUTPUT
41+
42+
publish:
43+
needs: tagger
44+
uses: ./.github/workflows/publish.yml
45+
strategy:
46+
matrix:
47+
image:
48+
- version: '3.13'
49+
variant: bookworm
50+
tags: |
51+
${{ needs.tagger.outputs.major }}
52+
${{ needs.tagger.outputs.major_minor }}
53+
${{ needs.tagger.outputs.version }}
54+
- version: '3.13'
55+
variant: slim-bookworm
56+
tags: |
57+
${{ needs.tagger.outputs.major }}-slim
58+
${{ needs.tagger.outputs.major_minor }}-slim
59+
${{ needs.tagger.outputs.version }}-slim
60+
with:
61+
image: coatldev/python
62+
version: ${{ matrix.image.version }}
63+
variant: ${{ matrix.image.variant }}
64+
tags: ${{ matrix.image.tags }}
65+
username: ${{ vars.DOCKERHUB_USERNAME }}
66+
secrets:
67+
password: ${{ secrets.DOCKERHUB_TOKEN }}

2.7/bookworm/Dockerfile

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -105,24 +105,17 @@ RUN set -eux; \
105105
\
106106
python2 --version
107107

108-
# if this is called "PIP_VERSION", pip explodes with "ValueError: invalid truth value '<VERSION>'"
109-
ENV PYTHON_PIP_VERSION=20.3.4
110-
ENV PYTHON_SETUPTOOLS_VERSION=44.1.1
111-
ENV PYTHON_WHEEL_VERSION=0.37.1
112108
# https://github.com/pypa/get-pip
113109
ENV PYTHON_GET_PIP_URL=https://raw.githubusercontent.com/pypa/get-pip/HEAD/public/2.7/get-pip.py
114110
ENV PYTHON_GET_PIP_SHA256=40ee07eac6674b8d60fce2bbabc148cf0e2f1408c167683f110fd608b8d6f416
115111

116-
117112
RUN set -ex; \
118113
\
119114
wget -q -O get-pip.py "$PYTHON_GET_PIP_URL"; \
120115
echo "$PYTHON_GET_PIP_SHA256 *get-pip.py" | sha256sum --check --strict -; \
121116
\
122117
python get-pip.py \
123118
--disable-pip-version-check \
124-
--no-cache-dir \
125-
"pip==$PYTHON_PIP_VERSION" \
126119
; \
127120
pip --version; \
128121
\
@@ -134,7 +127,4 @@ RUN set -ex; \
134127
\) -exec rm -rf '{}' +; \
135128
rm -f get-pip.py
136129

137-
# install "virtualenv", since the vast majority of users of this image will want it
138-
RUN python -m pip install virtualenv==20.15.1
139-
140130
CMD ["python2"]

2.7/slim-bookworm/Dockerfile

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,6 @@ RUN set -eux; \
142142
\
143143
python2 --version
144144

145-
# if this is called "PIP_VERSION", pip explodes with "ValueError: invalid truth value '<VERSION>'"
146-
ENV PYTHON_PIP_VERSION=20.3.4
147-
ENV PYTHON_SETUPTOOLS_VERSION=44.1.1
148-
ENV PYTHON_WHEEL_VERSION=0.37.1
149145
# https://github.com/pypa/get-pip
150146
ENV PYTHON_GET_PIP_URL=https://raw.githubusercontent.com/pypa/get-pip/HEAD/public/2.7/get-pip.py
151147
ENV PYTHON_GET_PIP_SHA256=40ee07eac6674b8d60fce2bbabc148cf0e2f1408c167683f110fd608b8d6f416
@@ -166,8 +162,6 @@ RUN set -ex; \
166162
\
167163
python get-pip.py \
168164
--disable-pip-version-check \
169-
--no-cache-dir \
170-
"pip==$PYTHON_PIP_VERSION" \
171165
; \
172166
pip --version; \
173167
\

3.13/bookworm/Dockerfile

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
FROM buildpack-deps:bookworm
2+
3+
LABEL \
4+
maintainer="César Román <cesar@coatl.dev>" \
5+
repository="https://github.com/coatl-dev/docker-python" \
6+
vendor="coatl.dev"
7+
8+
ENV DEBIAN_FRONTEND=noninteractive
9+
10+
ENV PIP_NO_CACHE_DIR=1
11+
ENV PIP_NO_PYTHON_VERSION_WARNING=1
12+
ENV PIP_ROOT_USER_ACTION=ignore
13+
14+
# ensure local python is preferred over distribution python
15+
ENV PATH=/usr/local/bin:$PATH
16+
17+
# runtime dependencies
18+
RUN set -eux; \
19+
apt-get update; \
20+
apt-get install -y --no-install-recommends \
21+
libbluetooth-dev \
22+
tk-dev \
23+
uuid-dev \
24+
; \
25+
rm -rf /var/lib/apt/lists/*
26+
27+
ENV PYTHON_VERSION=3.13.0
28+
29+
RUN set -eux; \
30+
\
31+
wget -q -O python.tar.xz "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz"; \
32+
mkdir -p /usr/src/python; \
33+
tar --extract --directory /usr/src/python --strip-components=1 --file python.tar.xz; \
34+
rm python.tar.xz; \
35+
\
36+
cd /usr/src/python; \
37+
gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \
38+
./configure \
39+
--build="$gnuArch" \
40+
--enable-loadable-sqlite-extensions \
41+
--enable-optimizations \
42+
--enable-option-checking=fatal \
43+
--enable-shared \
44+
--with-lto \
45+
--with-system-expat \
46+
--with-ensurepip \
47+
; \
48+
nproc="$(nproc)"; \
49+
EXTRA_CFLAGS="$(dpkg-buildflags --get CFLAGS)"; \
50+
LDFLAGS="$(dpkg-buildflags --get LDFLAGS)"; \
51+
make -s -j "$nproc" \
52+
"EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \
53+
"LDFLAGS=${LDFLAGS:-}" \
54+
"PROFILE_TASK=${PROFILE_TASK:-}" \
55+
; \
56+
# https://github.com/docker-library/python/issues/784
57+
# prevent accidental usage of a system installed libpython of the same version
58+
rm python; \
59+
make -s -j "$nproc" \
60+
"EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \
61+
"LDFLAGS=${LDFLAGS:--Wl},-rpath='\$\$ORIGIN/../lib'" \
62+
"PROFILE_TASK=${PROFILE_TASK:-}" \
63+
python \
64+
; \
65+
make install; \
66+
\
67+
# enable GDB to load debugging data: https://github.com/docker-library/python/pull/701
68+
bin="$(readlink -ve /usr/local/bin/python3)"; \
69+
dir="$(dirname "$bin")"; \
70+
mkdir -p "/usr/share/gdb/auto-load/$dir"; \
71+
cp -vL Tools/gdb/libpython.py "/usr/share/gdb/auto-load/$bin-gdb.py"; \
72+
\
73+
cd /; \
74+
rm -rf /usr/src/python; \
75+
\
76+
find /usr/local -depth \
77+
\( \
78+
\( -type d -a \( -name test -o -name tests -o -name idle_test \) \) \
79+
-o \( -type f -a \( -name '*.pyc' -o -name '*.pyo' -o -name 'libpython*.a' \) \) \
80+
\) -exec rm -rf '{}' + \
81+
; \
82+
\
83+
ldconfig; \
84+
\
85+
export PYTHONDONTWRITEBYTECODE=1; \
86+
python3 --version; \
87+
pip3 --version
88+
89+
# make some useful symlinks that are expected to exist ("/usr/local/bin/python" and friends)
90+
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
91+
RUN set -eux; \
92+
for src in idle3 pip3 pydoc3 python3 python3-config; do \
93+
dst="$(echo "$src" | tr -d 3)"; \
94+
[ -s "/usr/local/bin/$src" ]; \
95+
[ ! -e "/usr/local/bin/$dst" ]; \
96+
ln -svT "$src" "/usr/local/bin/$dst"; \
97+
done
98+
99+
CMD ["python3"]

0 commit comments

Comments
 (0)