├── .gitignore ├── .gitattributes ├── update.sh ├── .github └── workflows │ ├── verify-templating.yml │ └── ci.yml ├── LICENSE ├── README.md ├── apply-templates.sh ├── Dockerfile-windows.template ├── 3.13 ├── windows │ ├── windowsservercore-ltsc2022 │ │ └── Dockerfile │ └── windowsservercore-ltsc2025 │ │ └── Dockerfile ├── trixie │ └── Dockerfile ├── bookworm │ └── Dockerfile ├── alpine3.22 │ └── Dockerfile ├── alpine3.23 │ └── Dockerfile ├── slim-trixie │ └── Dockerfile └── slim-bookworm │ └── Dockerfile ├── 3.14 ├── windows │ ├── windowsservercore-ltsc2022 │ │ └── Dockerfile │ └── windowsservercore-ltsc2025 │ │ └── Dockerfile ├── alpine3.22 │ └── Dockerfile ├── alpine3.23 │ └── Dockerfile ├── trixie │ └── Dockerfile ├── bookworm │ └── Dockerfile ├── slim-trixie │ └── Dockerfile └── slim-bookworm │ └── Dockerfile ├── 3.15-rc ├── windows │ ├── windowsservercore-ltsc2022 │ │ └── Dockerfile │ └── windowsservercore-ltsc2025 │ │ └── Dockerfile ├── alpine3.22 │ └── Dockerfile ├── alpine3.23 │ └── Dockerfile ├── trixie │ └── Dockerfile ├── bookworm │ └── Dockerfile ├── slim-trixie │ └── Dockerfile └── slim-bookworm │ └── Dockerfile ├── versions.json ├── 3.10 ├── trixie │ └── Dockerfile ├── bookworm │ └── Dockerfile ├── alpine3.22 │ └── Dockerfile ├── alpine3.23 │ └── Dockerfile ├── slim-trixie │ └── Dockerfile └── slim-bookworm │ └── Dockerfile ├── 3.11 ├── trixie │ └── Dockerfile ├── bookworm │ └── Dockerfile ├── alpine3.22 │ └── Dockerfile ├── alpine3.23 │ └── Dockerfile ├── slim-trixie │ └── Dockerfile └── slim-bookworm │ └── Dockerfile ├── 3.12 ├── trixie │ └── Dockerfile ├── bookworm │ └── Dockerfile ├── alpine3.22 │ └── Dockerfile ├── alpine3.23 │ └── Dockerfile ├── slim-trixie │ └── Dockerfile └── slim-bookworm │ └── Dockerfile ├── generate-stackbrew-library.sh ├── versions.sh └── Dockerfile-linux.template /.gitignore: -------------------------------------------------------------------------------- 1 | .jq-template.awk 2 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | /*/**/Dockerfile linguist-generated 2 | /Dockerfile*.template linguist-language=Dockerfile 3 | * text=auto eol=lf 4 | -------------------------------------------------------------------------------- /update.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -Eeuo pipefail 3 | 4 | cd "$(dirname "$(readlink -f "$BASH_SOURCE")")" 5 | 6 | ./versions.sh "$@" 7 | ./apply-templates.sh "$@" 8 | -------------------------------------------------------------------------------- /.github/workflows/verify-templating.yml: -------------------------------------------------------------------------------- 1 | name: Verify Templating 2 | 3 | on: 4 | pull_request: 5 | push: 6 | workflow_dispatch: 7 | 8 | defaults: 9 | run: 10 | shell: 'bash -Eeuo pipefail -x {0}' 11 | 12 | jobs: 13 | apply-templates: 14 | name: Check For Uncomitted Changes 15 | runs-on: ubuntu-latest 16 | steps: 17 | - uses: actions/checkout@v4 18 | - run: ./apply-templates.sh 19 | - run: git diff --exit-code 20 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014 Docker, Inc. 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included 12 | in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 18 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 19 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 20 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # https://github.com/docker-library/python 2 | 3 | ## Maintained by: [the Docker Community](https://github.com/docker-library/python) 4 | 5 | This is the Git repo of the [Docker "Official Image"](https://github.com/docker-library/official-images#what-are-official-images) for [`python`](https://hub.docker.com/_/python/) (not to be confused with any official `python` image provided by `python` upstream). See [the Docker Hub page](https://hub.docker.com/_/python/) for the full readme on how to use this Docker image and for information regarding contributing and issues. 6 | 7 | The [full image description on Docker Hub](https://hub.docker.com/_/python/) is generated/maintained over in [the docker-library/docs repository](https://github.com/docker-library/docs), specifically in [the `python` directory](https://github.com/docker-library/docs/tree/master/python). 8 | 9 | ## See a change merged here that doesn't show up on Docker Hub yet? 10 | 11 | For more information about the full official images change lifecycle, see [the "An image's source changed in Git, now what?" FAQ entry](https://github.com/docker-library/faq#an-images-source-changed-in-git-now-what). 12 | 13 | For outstanding `python` image PRs, check [PRs with the "library/python" label on the official-images repository](https://github.com/docker-library/official-images/labels/library%2Fpython). For the current "source of truth" for [`python`](https://hub.docker.com/_/python/), see [the `library/python` file in the official-images repository](https://github.com/docker-library/official-images/blob/master/library/python). 14 | 15 | 16 | -------------------------------------------------------------------------------- /apply-templates.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -Eeuo pipefail 3 | 4 | [ -f versions.json ] # run "versions.sh" first 5 | 6 | jqt='.jq-template.awk' 7 | if [ -n "${BASHBREW_SCRIPTS:-}" ]; then 8 | jqt="$BASHBREW_SCRIPTS/jq-template.awk" 9 | elif [ "$BASH_SOURCE" -nt "$jqt" ]; then 10 | # https://github.com/docker-library/bashbrew/blob/master/scripts/jq-template.awk 11 | wget -qO "$jqt" 'https://github.com/docker-library/bashbrew/raw/9f6a35772ac863a0241f147c820354e4008edf38/scripts/jq-template.awk' 12 | fi 13 | 14 | if [ "$#" -eq 0 ]; then 15 | versions="$(jq -r 'keys | map(@sh) | join(" ")' versions.json)" 16 | eval "set -- $versions" 17 | fi 18 | 19 | generated_warning() { 20 | cat <<-EOH 21 | # 22 | # NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh" 23 | # 24 | # PLEASE DO NOT EDIT IT DIRECTLY. 25 | # 26 | 27 | EOH 28 | } 29 | 30 | for version; do 31 | export version 32 | 33 | rm -rf "$version/" 34 | 35 | variants="$(jq -r '.[env.version].variants | map(@sh) | join(" ")' versions.json)" 36 | eval "variants=( $variants )" 37 | 38 | for dir in "${variants[@]}"; do 39 | variant="$(basename "$dir")" # "buster", "windowsservercore-1809", etc 40 | export variant 41 | 42 | case "$dir" in 43 | windows/*) 44 | windowsVariant="${variant%%-*}" # "windowsservercore", "nanoserver" 45 | windowsRelease="${variant#$windowsVariant-}" # "ltsc2022", "1809", etc 46 | windowsVariant="${windowsVariant#windows}" # "servercore", "nanoserver" 47 | export windowsVariant windowsRelease 48 | template='Dockerfile-windows.template' 49 | ;; 50 | 51 | *) 52 | template='Dockerfile-linux.template' 53 | ;; 54 | esac 55 | 56 | echo "processing $version/$dir ..." 57 | mkdir -p "$version/$dir" 58 | 59 | { 60 | generated_warning 61 | gawk -f "$jqt" "$template" 62 | } > "$version/$dir/Dockerfile" 63 | done 64 | done 65 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: GitHub CI 2 | 3 | on: 4 | pull_request: 5 | push: 6 | workflow_dispatch: 7 | schedule: 8 | - cron: 0 0 * * 0 9 | 10 | defaults: 11 | run: 12 | shell: 'bash -Eeuo pipefail -x {0}' 13 | 14 | concurrency: 15 | group: ${{ github.ref }} 16 | cancel-in-progress: true 17 | 18 | jobs: 19 | 20 | generate-jobs: 21 | name: Generate Jobs 22 | runs-on: ubuntu-latest 23 | outputs: 24 | strategy: ${{ steps.generate-jobs.outputs.strategy }} 25 | steps: 26 | - uses: actions/checkout@v4 27 | - uses: docker-library/bashbrew@HEAD 28 | - id: generate-jobs 29 | name: Generate Jobs 30 | run: | 31 | strategy="$("$BASHBREW_SCRIPTS/github-actions/generate.sh")" 32 | 33 | # https://github.com/docker-library/python/pull/706 (ensure we don't have any unexpected ".a" leftovers in "/usr/local") 34 | strategy="$(jq <<<"$strategy" -c ' 35 | .matrix.include |= map( 36 | if .os == "ubuntu-latest" then 37 | .runs.test += "\n" + ( 38 | .meta.entries 39 | | map( 40 | .tags[0] 41 | | "aFiles=\"$(docker run --rm \(. | @sh) find /usr/local -name \"*.a\" | tee /dev/stderr)\"; [ -z \"$aFiles\" ]" 42 | ) 43 | | join("\n") 44 | ) 45 | else . end 46 | ) 47 | ')" 48 | 49 | EOF="EOF-$RANDOM-$RANDOM-$RANDOM" 50 | echo "strategy<<$EOF" >> "$GITHUB_OUTPUT" 51 | jq <<<"$strategy" . | tee -a "$GITHUB_OUTPUT" 52 | echo "$EOF" >> "$GITHUB_OUTPUT" 53 | 54 | test: 55 | needs: generate-jobs 56 | strategy: ${{ fromJson(needs.generate-jobs.outputs.strategy) }} 57 | name: ${{ matrix.name }} 58 | runs-on: ${{ matrix.os }} 59 | steps: 60 | - uses: actions/checkout@v4 61 | - name: Prepare Environment 62 | run: ${{ matrix.runs.prepare }} 63 | - name: Pull Dependencies 64 | run: ${{ matrix.runs.pull }} 65 | - name: Build ${{ matrix.name }} 66 | run: ${{ matrix.runs.build }} 67 | - name: History ${{ matrix.name }} 68 | run: ${{ matrix.runs.history }} 69 | - name: Test ${{ matrix.name }} 70 | run: ${{ matrix.runs.test }} 71 | - name: '"docker images"' 72 | run: ${{ matrix.runs.images }} 73 | -------------------------------------------------------------------------------- /Dockerfile-windows.template: -------------------------------------------------------------------------------- 1 | FROM mcr.microsoft.com/windows/{{ env.windowsVariant }}:{{ env.windowsRelease }} 2 | 3 | SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] 4 | 5 | # https://github.com/docker-library/python/pull/557 6 | ENV PYTHONIOENCODING UTF-8 7 | 8 | ENV PYTHON_VERSION {{ .version }} 9 | {{ if .checksums.windows.sha256 then ( -}} 10 | ENV PYTHON_SHA256 {{ .checksums.windows.sha256 }} 11 | {{ ) else "" end -}} 12 | 13 | RUN $url = ('https://www.python.org/ftp/python/{0}/python-{1}-amd64.exe' -f ($env:PYTHON_VERSION -replace '[a-z]+[0-9]*$', ''), $env:PYTHON_VERSION); \ 14 | Write-Host ('Downloading {0} ...' -f $url); \ 15 | [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; \ 16 | Invoke-WebRequest -Uri $url -OutFile 'python.exe'; \ 17 | {{ if .checksums.windows.sha256 then ( -}} 18 | \ 19 | Write-Host ('Verifying sha256 ({0}) ...' -f $env:PYTHON_SHA256); \ 20 | if ((Get-FileHash python.exe -Algorithm sha256).Hash -ne $env:PYTHON_SHA256) { \ 21 | Write-Host 'FAILED!'; \ 22 | exit 1; \ 23 | }; \ 24 | {{ ) else "" end -}} 25 | \ 26 | Write-Host 'Installing ...'; \ 27 | # https://docs.python.org/3/using/windows.html#installing-without-ui 28 | $exitCode = (Start-Process python.exe -Wait -NoNewWindow -PassThru \ 29 | -ArgumentList @( \ 30 | '/quiet', \ 31 | 'InstallAllUsers=1', \ 32 | 'TargetDir=C:\Python', \ 33 | 'PrependPath=1', \ 34 | 'Shortcuts=0', \ 35 | 'Include_doc=0', \ 36 | 'Include_pip=1', \ 37 | 'Include_test=0' \ 38 | ) \ 39 | ).ExitCode; \ 40 | if ($exitCode -ne 0) { \ 41 | Write-Host ('Running python installer failed with exit code: {0}' -f $exitCode); \ 42 | Get-ChildItem $env:TEMP | Sort-Object -Descending -Property LastWriteTime | Select-Object -First 1 | Get-Content; \ 43 | exit $exitCode; \ 44 | } \ 45 | \ 46 | # the installer updated PATH, so we should refresh our local value 47 | $env:PATH = [Environment]::GetEnvironmentVariable('PATH', [EnvironmentVariableTarget]::Machine); \ 48 | \ 49 | Write-Host 'Verifying install ...'; \ 50 | Write-Host ' python --version'; python --version; \ 51 | \ 52 | Write-Host 'Removing ...'; \ 53 | Remove-Item python.exe -Force; \ 54 | Remove-Item $env:TEMP/Python*.log -Force; \ 55 | \ 56 | $env:PYTHONDONTWRITEBYTECODE = '1'; \ 57 | \ 58 | Write-Host 'Verifying pip install ...'; \ 59 | pip --version; \ 60 | \ 61 | Write-Host 'Complete.' 62 | 63 | CMD ["python"] 64 | -------------------------------------------------------------------------------- /3.13/windows/windowsservercore-ltsc2022/Dockerfile: -------------------------------------------------------------------------------- 1 | # 2 | # NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh" 3 | # 4 | # PLEASE DO NOT EDIT IT DIRECTLY. 5 | # 6 | 7 | FROM mcr.microsoft.com/windows/servercore:ltsc2022 8 | 9 | SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] 10 | 11 | # https://github.com/docker-library/python/pull/557 12 | ENV PYTHONIOENCODING UTF-8 13 | 14 | ENV PYTHON_VERSION 3.13.11 15 | ENV PYTHON_SHA256 30d4654b3eac7ddfdf2682db4c8dcb490f3055f4f33c6906d6b828f680152101 16 | 17 | RUN $url = ('https://www.python.org/ftp/python/{0}/python-{1}-amd64.exe' -f ($env:PYTHON_VERSION -replace '[a-z]+[0-9]*$', ''), $env:PYTHON_VERSION); \ 18 | Write-Host ('Downloading {0} ...' -f $url); \ 19 | [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; \ 20 | Invoke-WebRequest -Uri $url -OutFile 'python.exe'; \ 21 | \ 22 | Write-Host ('Verifying sha256 ({0}) ...' -f $env:PYTHON_SHA256); \ 23 | if ((Get-FileHash python.exe -Algorithm sha256).Hash -ne $env:PYTHON_SHA256) { \ 24 | Write-Host 'FAILED!'; \ 25 | exit 1; \ 26 | }; \ 27 | \ 28 | Write-Host 'Installing ...'; \ 29 | # https://docs.python.org/3/using/windows.html#installing-without-ui 30 | $exitCode = (Start-Process python.exe -Wait -NoNewWindow -PassThru \ 31 | -ArgumentList @( \ 32 | '/quiet', \ 33 | 'InstallAllUsers=1', \ 34 | 'TargetDir=C:\Python', \ 35 | 'PrependPath=1', \ 36 | 'Shortcuts=0', \ 37 | 'Include_doc=0', \ 38 | 'Include_pip=1', \ 39 | 'Include_test=0' \ 40 | ) \ 41 | ).ExitCode; \ 42 | if ($exitCode -ne 0) { \ 43 | Write-Host ('Running python installer failed with exit code: {0}' -f $exitCode); \ 44 | Get-ChildItem $env:TEMP | Sort-Object -Descending -Property LastWriteTime | Select-Object -First 1 | Get-Content; \ 45 | exit $exitCode; \ 46 | } \ 47 | \ 48 | # the installer updated PATH, so we should refresh our local value 49 | $env:PATH = [Environment]::GetEnvironmentVariable('PATH', [EnvironmentVariableTarget]::Machine); \ 50 | \ 51 | Write-Host 'Verifying install ...'; \ 52 | Write-Host ' python --version'; python --version; \ 53 | \ 54 | Write-Host 'Removing ...'; \ 55 | Remove-Item python.exe -Force; \ 56 | Remove-Item $env:TEMP/Python*.log -Force; \ 57 | \ 58 | $env:PYTHONDONTWRITEBYTECODE = '1'; \ 59 | \ 60 | Write-Host 'Verifying pip install ...'; \ 61 | pip --version; \ 62 | \ 63 | Write-Host 'Complete.' 64 | 65 | CMD ["python"] 66 | -------------------------------------------------------------------------------- /3.13/windows/windowsservercore-ltsc2025/Dockerfile: -------------------------------------------------------------------------------- 1 | # 2 | # NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh" 3 | # 4 | # PLEASE DO NOT EDIT IT DIRECTLY. 5 | # 6 | 7 | FROM mcr.microsoft.com/windows/servercore:ltsc2025 8 | 9 | SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] 10 | 11 | # https://github.com/docker-library/python/pull/557 12 | ENV PYTHONIOENCODING UTF-8 13 | 14 | ENV PYTHON_VERSION 3.13.11 15 | ENV PYTHON_SHA256 30d4654b3eac7ddfdf2682db4c8dcb490f3055f4f33c6906d6b828f680152101 16 | 17 | RUN $url = ('https://www.python.org/ftp/python/{0}/python-{1}-amd64.exe' -f ($env:PYTHON_VERSION -replace '[a-z]+[0-9]*$', ''), $env:PYTHON_VERSION); \ 18 | Write-Host ('Downloading {0} ...' -f $url); \ 19 | [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; \ 20 | Invoke-WebRequest -Uri $url -OutFile 'python.exe'; \ 21 | \ 22 | Write-Host ('Verifying sha256 ({0}) ...' -f $env:PYTHON_SHA256); \ 23 | if ((Get-FileHash python.exe -Algorithm sha256).Hash -ne $env:PYTHON_SHA256) { \ 24 | Write-Host 'FAILED!'; \ 25 | exit 1; \ 26 | }; \ 27 | \ 28 | Write-Host 'Installing ...'; \ 29 | # https://docs.python.org/3/using/windows.html#installing-without-ui 30 | $exitCode = (Start-Process python.exe -Wait -NoNewWindow -PassThru \ 31 | -ArgumentList @( \ 32 | '/quiet', \ 33 | 'InstallAllUsers=1', \ 34 | 'TargetDir=C:\Python', \ 35 | 'PrependPath=1', \ 36 | 'Shortcuts=0', \ 37 | 'Include_doc=0', \ 38 | 'Include_pip=1', \ 39 | 'Include_test=0' \ 40 | ) \ 41 | ).ExitCode; \ 42 | if ($exitCode -ne 0) { \ 43 | Write-Host ('Running python installer failed with exit code: {0}' -f $exitCode); \ 44 | Get-ChildItem $env:TEMP | Sort-Object -Descending -Property LastWriteTime | Select-Object -First 1 | Get-Content; \ 45 | exit $exitCode; \ 46 | } \ 47 | \ 48 | # the installer updated PATH, so we should refresh our local value 49 | $env:PATH = [Environment]::GetEnvironmentVariable('PATH', [EnvironmentVariableTarget]::Machine); \ 50 | \ 51 | Write-Host 'Verifying install ...'; \ 52 | Write-Host ' python --version'; python --version; \ 53 | \ 54 | Write-Host 'Removing ...'; \ 55 | Remove-Item python.exe -Force; \ 56 | Remove-Item $env:TEMP/Python*.log -Force; \ 57 | \ 58 | $env:PYTHONDONTWRITEBYTECODE = '1'; \ 59 | \ 60 | Write-Host 'Verifying pip install ...'; \ 61 | pip --version; \ 62 | \ 63 | Write-Host 'Complete.' 64 | 65 | CMD ["python"] 66 | -------------------------------------------------------------------------------- /3.14/windows/windowsservercore-ltsc2022/Dockerfile: -------------------------------------------------------------------------------- 1 | # 2 | # NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh" 3 | # 4 | # PLEASE DO NOT EDIT IT DIRECTLY. 5 | # 6 | 7 | FROM mcr.microsoft.com/windows/servercore:ltsc2022 8 | 9 | SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] 10 | 11 | # https://github.com/docker-library/python/pull/557 12 | ENV PYTHONIOENCODING UTF-8 13 | 14 | ENV PYTHON_VERSION 3.14.2 15 | ENV PYTHON_SHA256 9db919cefe30a0051658c600a9912acb0cd2b872aaf35842c9ec2bf401efa848 16 | 17 | RUN $url = ('https://www.python.org/ftp/python/{0}/python-{1}-amd64.exe' -f ($env:PYTHON_VERSION -replace '[a-z]+[0-9]*$', ''), $env:PYTHON_VERSION); \ 18 | Write-Host ('Downloading {0} ...' -f $url); \ 19 | [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; \ 20 | Invoke-WebRequest -Uri $url -OutFile 'python.exe'; \ 21 | \ 22 | Write-Host ('Verifying sha256 ({0}) ...' -f $env:PYTHON_SHA256); \ 23 | if ((Get-FileHash python.exe -Algorithm sha256).Hash -ne $env:PYTHON_SHA256) { \ 24 | Write-Host 'FAILED!'; \ 25 | exit 1; \ 26 | }; \ 27 | \ 28 | Write-Host 'Installing ...'; \ 29 | # https://docs.python.org/3/using/windows.html#installing-without-ui 30 | $exitCode = (Start-Process python.exe -Wait -NoNewWindow -PassThru \ 31 | -ArgumentList @( \ 32 | '/quiet', \ 33 | 'InstallAllUsers=1', \ 34 | 'TargetDir=C:\Python', \ 35 | 'PrependPath=1', \ 36 | 'Shortcuts=0', \ 37 | 'Include_doc=0', \ 38 | 'Include_pip=1', \ 39 | 'Include_test=0' \ 40 | ) \ 41 | ).ExitCode; \ 42 | if ($exitCode -ne 0) { \ 43 | Write-Host ('Running python installer failed with exit code: {0}' -f $exitCode); \ 44 | Get-ChildItem $env:TEMP | Sort-Object -Descending -Property LastWriteTime | Select-Object -First 1 | Get-Content; \ 45 | exit $exitCode; \ 46 | } \ 47 | \ 48 | # the installer updated PATH, so we should refresh our local value 49 | $env:PATH = [Environment]::GetEnvironmentVariable('PATH', [EnvironmentVariableTarget]::Machine); \ 50 | \ 51 | Write-Host 'Verifying install ...'; \ 52 | Write-Host ' python --version'; python --version; \ 53 | \ 54 | Write-Host 'Removing ...'; \ 55 | Remove-Item python.exe -Force; \ 56 | Remove-Item $env:TEMP/Python*.log -Force; \ 57 | \ 58 | $env:PYTHONDONTWRITEBYTECODE = '1'; \ 59 | \ 60 | Write-Host 'Verifying pip install ...'; \ 61 | pip --version; \ 62 | \ 63 | Write-Host 'Complete.' 64 | 65 | CMD ["python"] 66 | -------------------------------------------------------------------------------- /3.14/windows/windowsservercore-ltsc2025/Dockerfile: -------------------------------------------------------------------------------- 1 | # 2 | # NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh" 3 | # 4 | # PLEASE DO NOT EDIT IT DIRECTLY. 5 | # 6 | 7 | FROM mcr.microsoft.com/windows/servercore:ltsc2025 8 | 9 | SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] 10 | 11 | # https://github.com/docker-library/python/pull/557 12 | ENV PYTHONIOENCODING UTF-8 13 | 14 | ENV PYTHON_VERSION 3.14.2 15 | ENV PYTHON_SHA256 9db919cefe30a0051658c600a9912acb0cd2b872aaf35842c9ec2bf401efa848 16 | 17 | RUN $url = ('https://www.python.org/ftp/python/{0}/python-{1}-amd64.exe' -f ($env:PYTHON_VERSION -replace '[a-z]+[0-9]*$', ''), $env:PYTHON_VERSION); \ 18 | Write-Host ('Downloading {0} ...' -f $url); \ 19 | [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; \ 20 | Invoke-WebRequest -Uri $url -OutFile 'python.exe'; \ 21 | \ 22 | Write-Host ('Verifying sha256 ({0}) ...' -f $env:PYTHON_SHA256); \ 23 | if ((Get-FileHash python.exe -Algorithm sha256).Hash -ne $env:PYTHON_SHA256) { \ 24 | Write-Host 'FAILED!'; \ 25 | exit 1; \ 26 | }; \ 27 | \ 28 | Write-Host 'Installing ...'; \ 29 | # https://docs.python.org/3/using/windows.html#installing-without-ui 30 | $exitCode = (Start-Process python.exe -Wait -NoNewWindow -PassThru \ 31 | -ArgumentList @( \ 32 | '/quiet', \ 33 | 'InstallAllUsers=1', \ 34 | 'TargetDir=C:\Python', \ 35 | 'PrependPath=1', \ 36 | 'Shortcuts=0', \ 37 | 'Include_doc=0', \ 38 | 'Include_pip=1', \ 39 | 'Include_test=0' \ 40 | ) \ 41 | ).ExitCode; \ 42 | if ($exitCode -ne 0) { \ 43 | Write-Host ('Running python installer failed with exit code: {0}' -f $exitCode); \ 44 | Get-ChildItem $env:TEMP | Sort-Object -Descending -Property LastWriteTime | Select-Object -First 1 | Get-Content; \ 45 | exit $exitCode; \ 46 | } \ 47 | \ 48 | # the installer updated PATH, so we should refresh our local value 49 | $env:PATH = [Environment]::GetEnvironmentVariable('PATH', [EnvironmentVariableTarget]::Machine); \ 50 | \ 51 | Write-Host 'Verifying install ...'; \ 52 | Write-Host ' python --version'; python --version; \ 53 | \ 54 | Write-Host 'Removing ...'; \ 55 | Remove-Item python.exe -Force; \ 56 | Remove-Item $env:TEMP/Python*.log -Force; \ 57 | \ 58 | $env:PYTHONDONTWRITEBYTECODE = '1'; \ 59 | \ 60 | Write-Host 'Verifying pip install ...'; \ 61 | pip --version; \ 62 | \ 63 | Write-Host 'Complete.' 64 | 65 | CMD ["python"] 66 | -------------------------------------------------------------------------------- /3.15-rc/windows/windowsservercore-ltsc2022/Dockerfile: -------------------------------------------------------------------------------- 1 | # 2 | # NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh" 3 | # 4 | # PLEASE DO NOT EDIT IT DIRECTLY. 5 | # 6 | 7 | FROM mcr.microsoft.com/windows/servercore:ltsc2022 8 | 9 | SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] 10 | 11 | # https://github.com/docker-library/python/pull/557 12 | ENV PYTHONIOENCODING UTF-8 13 | 14 | ENV PYTHON_VERSION 3.15.0a3 15 | ENV PYTHON_SHA256 05d0a8932ca359e349571b193858be1af72a3cff086bfe08cbe6d1e2140726c9 16 | 17 | RUN $url = ('https://www.python.org/ftp/python/{0}/python-{1}-amd64.exe' -f ($env:PYTHON_VERSION -replace '[a-z]+[0-9]*$', ''), $env:PYTHON_VERSION); \ 18 | Write-Host ('Downloading {0} ...' -f $url); \ 19 | [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; \ 20 | Invoke-WebRequest -Uri $url -OutFile 'python.exe'; \ 21 | \ 22 | Write-Host ('Verifying sha256 ({0}) ...' -f $env:PYTHON_SHA256); \ 23 | if ((Get-FileHash python.exe -Algorithm sha256).Hash -ne $env:PYTHON_SHA256) { \ 24 | Write-Host 'FAILED!'; \ 25 | exit 1; \ 26 | }; \ 27 | \ 28 | Write-Host 'Installing ...'; \ 29 | # https://docs.python.org/3/using/windows.html#installing-without-ui 30 | $exitCode = (Start-Process python.exe -Wait -NoNewWindow -PassThru \ 31 | -ArgumentList @( \ 32 | '/quiet', \ 33 | 'InstallAllUsers=1', \ 34 | 'TargetDir=C:\Python', \ 35 | 'PrependPath=1', \ 36 | 'Shortcuts=0', \ 37 | 'Include_doc=0', \ 38 | 'Include_pip=1', \ 39 | 'Include_test=0' \ 40 | ) \ 41 | ).ExitCode; \ 42 | if ($exitCode -ne 0) { \ 43 | Write-Host ('Running python installer failed with exit code: {0}' -f $exitCode); \ 44 | Get-ChildItem $env:TEMP | Sort-Object -Descending -Property LastWriteTime | Select-Object -First 1 | Get-Content; \ 45 | exit $exitCode; \ 46 | } \ 47 | \ 48 | # the installer updated PATH, so we should refresh our local value 49 | $env:PATH = [Environment]::GetEnvironmentVariable('PATH', [EnvironmentVariableTarget]::Machine); \ 50 | \ 51 | Write-Host 'Verifying install ...'; \ 52 | Write-Host ' python --version'; python --version; \ 53 | \ 54 | Write-Host 'Removing ...'; \ 55 | Remove-Item python.exe -Force; \ 56 | Remove-Item $env:TEMP/Python*.log -Force; \ 57 | \ 58 | $env:PYTHONDONTWRITEBYTECODE = '1'; \ 59 | \ 60 | Write-Host 'Verifying pip install ...'; \ 61 | pip --version; \ 62 | \ 63 | Write-Host 'Complete.' 64 | 65 | CMD ["python"] 66 | -------------------------------------------------------------------------------- /3.15-rc/windows/windowsservercore-ltsc2025/Dockerfile: -------------------------------------------------------------------------------- 1 | # 2 | # NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh" 3 | # 4 | # PLEASE DO NOT EDIT IT DIRECTLY. 5 | # 6 | 7 | FROM mcr.microsoft.com/windows/servercore:ltsc2025 8 | 9 | SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] 10 | 11 | # https://github.com/docker-library/python/pull/557 12 | ENV PYTHONIOENCODING UTF-8 13 | 14 | ENV PYTHON_VERSION 3.15.0a3 15 | ENV PYTHON_SHA256 05d0a8932ca359e349571b193858be1af72a3cff086bfe08cbe6d1e2140726c9 16 | 17 | RUN $url = ('https://www.python.org/ftp/python/{0}/python-{1}-amd64.exe' -f ($env:PYTHON_VERSION -replace '[a-z]+[0-9]*$', ''), $env:PYTHON_VERSION); \ 18 | Write-Host ('Downloading {0} ...' -f $url); \ 19 | [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; \ 20 | Invoke-WebRequest -Uri $url -OutFile 'python.exe'; \ 21 | \ 22 | Write-Host ('Verifying sha256 ({0}) ...' -f $env:PYTHON_SHA256); \ 23 | if ((Get-FileHash python.exe -Algorithm sha256).Hash -ne $env:PYTHON_SHA256) { \ 24 | Write-Host 'FAILED!'; \ 25 | exit 1; \ 26 | }; \ 27 | \ 28 | Write-Host 'Installing ...'; \ 29 | # https://docs.python.org/3/using/windows.html#installing-without-ui 30 | $exitCode = (Start-Process python.exe -Wait -NoNewWindow -PassThru \ 31 | -ArgumentList @( \ 32 | '/quiet', \ 33 | 'InstallAllUsers=1', \ 34 | 'TargetDir=C:\Python', \ 35 | 'PrependPath=1', \ 36 | 'Shortcuts=0', \ 37 | 'Include_doc=0', \ 38 | 'Include_pip=1', \ 39 | 'Include_test=0' \ 40 | ) \ 41 | ).ExitCode; \ 42 | if ($exitCode -ne 0) { \ 43 | Write-Host ('Running python installer failed with exit code: {0}' -f $exitCode); \ 44 | Get-ChildItem $env:TEMP | Sort-Object -Descending -Property LastWriteTime | Select-Object -First 1 | Get-Content; \ 45 | exit $exitCode; \ 46 | } \ 47 | \ 48 | # the installer updated PATH, so we should refresh our local value 49 | $env:PATH = [Environment]::GetEnvironmentVariable('PATH', [EnvironmentVariableTarget]::Machine); \ 50 | \ 51 | Write-Host 'Verifying install ...'; \ 52 | Write-Host ' python --version'; python --version; \ 53 | \ 54 | Write-Host 'Removing ...'; \ 55 | Remove-Item python.exe -Force; \ 56 | Remove-Item $env:TEMP/Python*.log -Force; \ 57 | \ 58 | $env:PYTHONDONTWRITEBYTECODE = '1'; \ 59 | \ 60 | Write-Host 'Verifying pip install ...'; \ 61 | pip --version; \ 62 | \ 63 | Write-Host 'Complete.' 64 | 65 | CMD ["python"] 66 | -------------------------------------------------------------------------------- /versions.json: -------------------------------------------------------------------------------- 1 | { 2 | "3.10": { 3 | "checksums": { 4 | "source": { 5 | "sha256": "c8f4a596572201d81dd7df91f70e177e19a70f1d489968b54b5fbbf29a97c076" 6 | } 7 | }, 8 | "setuptools": { 9 | "version": "79.0.1" 10 | }, 11 | "variants": [ 12 | "trixie", 13 | "slim-trixie", 14 | "bookworm", 15 | "slim-bookworm", 16 | "alpine3.23", 17 | "alpine3.22" 18 | ], 19 | "version": "3.10.19" 20 | }, 21 | "3.11": { 22 | "checksums": { 23 | "source": { 24 | "sha256": "8d3ed8ec5c88c1c95f5e558612a725450d2452813ddad5e58fdb1a53b1209b78" 25 | } 26 | }, 27 | "setuptools": { 28 | "version": "79.0.1" 29 | }, 30 | "variants": [ 31 | "trixie", 32 | "slim-trixie", 33 | "bookworm", 34 | "slim-bookworm", 35 | "alpine3.23", 36 | "alpine3.22" 37 | ], 38 | "version": "3.11.14" 39 | }, 40 | "3.12": { 41 | "checksums": { 42 | "source": { 43 | "sha256": "fb85a13414b028c49ba18bbd523c2d055a30b56b18b92ce454ea2c51edc656c4" 44 | } 45 | }, 46 | "variants": [ 47 | "trixie", 48 | "slim-trixie", 49 | "bookworm", 50 | "slim-bookworm", 51 | "alpine3.23", 52 | "alpine3.22" 53 | ], 54 | "version": "3.12.12" 55 | }, 56 | "3.13": { 57 | "checksums": { 58 | "source": { 59 | "sha256": "16ede7bb7cdbfa895d11b0642fa0e523f291e6487194d53cf6d3b338c3a17ea2" 60 | }, 61 | "windows": { 62 | "sha256": "30d4654b3eac7ddfdf2682db4c8dcb490f3055f4f33c6906d6b828f680152101" 63 | } 64 | }, 65 | "variants": [ 66 | "trixie", 67 | "slim-trixie", 68 | "bookworm", 69 | "slim-bookworm", 70 | "alpine3.23", 71 | "alpine3.22", 72 | "windows/windowsservercore-ltsc2025", 73 | "windows/windowsservercore-ltsc2022" 74 | ], 75 | "version": "3.13.11" 76 | }, 77 | "3.14": { 78 | "checksums": { 79 | "source": { 80 | "sha256": "ce543ab854bc256b61b71e9b27f831ffd1bfd60a479d639f8be7f9757cf573e9" 81 | }, 82 | "windows": { 83 | "sha256": "9db919cefe30a0051658c600a9912acb0cd2b872aaf35842c9ec2bf401efa848" 84 | } 85 | }, 86 | "variants": [ 87 | "trixie", 88 | "slim-trixie", 89 | "bookworm", 90 | "slim-bookworm", 91 | "alpine3.23", 92 | "alpine3.22", 93 | "windows/windowsservercore-ltsc2025", 94 | "windows/windowsservercore-ltsc2022" 95 | ], 96 | "version": "3.14.2" 97 | }, 98 | "3.15-rc": { 99 | "checksums": { 100 | "source": { 101 | "sha256": "6ab02cdac24505779877bb1d9189432d67e90ddf2a9b8b7b373ead54ac07b607" 102 | }, 103 | "windows": { 104 | "sha256": "05d0a8932ca359e349571b193858be1af72a3cff086bfe08cbe6d1e2140726c9" 105 | } 106 | }, 107 | "variants": [ 108 | "trixie", 109 | "slim-trixie", 110 | "bookworm", 111 | "slim-bookworm", 112 | "alpine3.23", 113 | "alpine3.22", 114 | "windows/windowsservercore-ltsc2025", 115 | "windows/windowsservercore-ltsc2022" 116 | ], 117 | "version": "3.15.0a3" 118 | } 119 | } 120 | -------------------------------------------------------------------------------- /3.10/trixie/Dockerfile: -------------------------------------------------------------------------------- 1 | # 2 | # NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh" 3 | # 4 | # PLEASE DO NOT EDIT IT DIRECTLY. 5 | # 6 | 7 | FROM buildpack-deps:trixie 8 | 9 | # ensure local python is preferred over distribution python 10 | ENV PATH /usr/local/bin:$PATH 11 | 12 | # cannot remove LANG even though https://bugs.python.org/issue19846 is fixed 13 | # last attempted removal of LANG broke many users: 14 | # https://github.com/docker-library/python/pull/570 15 | ENV LANG C.UTF-8 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 | apt-get dist-clean 26 | 27 | ENV GPG_KEY A035C8C19219BA821ECEA86B64E628F8D684696D 28 | ENV PYTHON_VERSION 3.10.19 29 | ENV PYTHON_SHA256 c8f4a596572201d81dd7df91f70e177e19a70f1d489968b54b5fbbf29a97c076 30 | 31 | RUN set -eux; \ 32 | \ 33 | wget -O python.tar.xz "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz"; \ 34 | echo "$PYTHON_SHA256 *python.tar.xz" | sha256sum -c -; \ 35 | wget -O python.tar.xz.asc "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz.asc"; \ 36 | GNUPGHOME="$(mktemp -d)"; export GNUPGHOME; \ 37 | gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$GPG_KEY"; \ 38 | gpg --batch --verify python.tar.xz.asc python.tar.xz; \ 39 | gpgconf --kill all; \ 40 | rm -rf "$GNUPGHOME" python.tar.xz.asc; \ 41 | mkdir -p /usr/src/python; \ 42 | tar --extract --directory /usr/src/python --strip-components=1 --file python.tar.xz; \ 43 | rm python.tar.xz; \ 44 | \ 45 | cd /usr/src/python; \ 46 | gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \ 47 | ./configure \ 48 | --build="$gnuArch" \ 49 | --enable-loadable-sqlite-extensions \ 50 | --enable-optimizations \ 51 | --enable-option-checking=fatal \ 52 | --enable-shared \ 53 | $(test "${gnuArch%%-*}" != 'riscv64' && echo '--with-lto') \ 54 | --with-ensurepip \ 55 | ; \ 56 | nproc="$(nproc)"; \ 57 | EXTRA_CFLAGS="$(dpkg-buildflags --get CFLAGS)"; \ 58 | LDFLAGS="$(dpkg-buildflags --get LDFLAGS)"; \ 59 | make -j "$nproc" \ 60 | "EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \ 61 | "LDFLAGS=${LDFLAGS:-}" \ 62 | ; \ 63 | # https://github.com/docker-library/python/issues/784 64 | # prevent accidental usage of a system installed libpython of the same version 65 | rm python; \ 66 | make -j "$nproc" \ 67 | "EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \ 68 | "LDFLAGS=${LDFLAGS:--Wl},-rpath='\$\$ORIGIN/../lib'" \ 69 | python \ 70 | ; \ 71 | make install; \ 72 | \ 73 | # enable GDB to load debugging data: https://github.com/docker-library/python/pull/701 74 | bin="$(readlink -ve /usr/local/bin/python3)"; \ 75 | dir="$(dirname "$bin")"; \ 76 | mkdir -p "/usr/share/gdb/auto-load/$dir"; \ 77 | cp -vL Tools/gdb/libpython.py "/usr/share/gdb/auto-load/$bin-gdb.py"; \ 78 | \ 79 | cd /; \ 80 | rm -rf /usr/src/python; \ 81 | \ 82 | find /usr/local -depth \ 83 | \( \ 84 | \( -type d -a \( -name test -o -name tests -o -name idle_test \) \) \ 85 | -o \( -type f -a \( -name '*.pyc' -o -name '*.pyo' -o -name 'libpython*.a' \) \) \ 86 | \) -exec rm -rf '{}' + \ 87 | ; \ 88 | \ 89 | ldconfig; \ 90 | \ 91 | export PYTHONDONTWRITEBYTECODE=1; \ 92 | python3 --version; \ 93 | \ 94 | pip3 install \ 95 | --disable-pip-version-check \ 96 | --no-cache-dir \ 97 | --no-compile \ 98 | 'setuptools==79.0.1' \ 99 | # https://github.com/docker-library/python/issues/1023 100 | 'wheel<0.46' \ 101 | ; \ 102 | pip3 --version 103 | 104 | # make some useful symlinks that are expected to exist ("/usr/local/bin/python" and friends) 105 | RUN set -eux; \ 106 | for src in idle3 pip3 pydoc3 python3 python3-config; do \ 107 | dst="$(echo "$src" | tr -d 3)"; \ 108 | [ -s "/usr/local/bin/$src" ]; \ 109 | [ ! -e "/usr/local/bin/$dst" ]; \ 110 | ln -svT "$src" "/usr/local/bin/$dst"; \ 111 | done 112 | 113 | CMD ["python3"] 114 | -------------------------------------------------------------------------------- /3.11/trixie/Dockerfile: -------------------------------------------------------------------------------- 1 | # 2 | # NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh" 3 | # 4 | # PLEASE DO NOT EDIT IT DIRECTLY. 5 | # 6 | 7 | FROM buildpack-deps:trixie 8 | 9 | # ensure local python is preferred over distribution python 10 | ENV PATH /usr/local/bin:$PATH 11 | 12 | # cannot remove LANG even though https://bugs.python.org/issue19846 is fixed 13 | # last attempted removal of LANG broke many users: 14 | # https://github.com/docker-library/python/pull/570 15 | ENV LANG C.UTF-8 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 | apt-get dist-clean 26 | 27 | ENV GPG_KEY A035C8C19219BA821ECEA86B64E628F8D684696D 28 | ENV PYTHON_VERSION 3.11.14 29 | ENV PYTHON_SHA256 8d3ed8ec5c88c1c95f5e558612a725450d2452813ddad5e58fdb1a53b1209b78 30 | 31 | RUN set -eux; \ 32 | \ 33 | wget -O python.tar.xz "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz"; \ 34 | echo "$PYTHON_SHA256 *python.tar.xz" | sha256sum -c -; \ 35 | wget -O python.tar.xz.asc "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz.asc"; \ 36 | GNUPGHOME="$(mktemp -d)"; export GNUPGHOME; \ 37 | gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$GPG_KEY"; \ 38 | gpg --batch --verify python.tar.xz.asc python.tar.xz; \ 39 | gpgconf --kill all; \ 40 | rm -rf "$GNUPGHOME" python.tar.xz.asc; \ 41 | mkdir -p /usr/src/python; \ 42 | tar --extract --directory /usr/src/python --strip-components=1 --file python.tar.xz; \ 43 | rm python.tar.xz; \ 44 | \ 45 | cd /usr/src/python; \ 46 | gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \ 47 | ./configure \ 48 | --build="$gnuArch" \ 49 | --enable-loadable-sqlite-extensions \ 50 | --enable-optimizations \ 51 | --enable-option-checking=fatal \ 52 | --enable-shared \ 53 | $(test "${gnuArch%%-*}" != 'riscv64' && echo '--with-lto') \ 54 | --with-ensurepip \ 55 | ; \ 56 | nproc="$(nproc)"; \ 57 | EXTRA_CFLAGS="$(dpkg-buildflags --get CFLAGS)"; \ 58 | LDFLAGS="$(dpkg-buildflags --get LDFLAGS)"; \ 59 | make -j "$nproc" \ 60 | "EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \ 61 | "LDFLAGS=${LDFLAGS:-}" \ 62 | ; \ 63 | # https://github.com/docker-library/python/issues/784 64 | # prevent accidental usage of a system installed libpython of the same version 65 | rm python; \ 66 | make -j "$nproc" \ 67 | "EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \ 68 | "LDFLAGS=${LDFLAGS:--Wl},-rpath='\$\$ORIGIN/../lib'" \ 69 | python \ 70 | ; \ 71 | make install; \ 72 | \ 73 | # enable GDB to load debugging data: https://github.com/docker-library/python/pull/701 74 | bin="$(readlink -ve /usr/local/bin/python3)"; \ 75 | dir="$(dirname "$bin")"; \ 76 | mkdir -p "/usr/share/gdb/auto-load/$dir"; \ 77 | cp -vL Tools/gdb/libpython.py "/usr/share/gdb/auto-load/$bin-gdb.py"; \ 78 | \ 79 | cd /; \ 80 | rm -rf /usr/src/python; \ 81 | \ 82 | find /usr/local -depth \ 83 | \( \ 84 | \( -type d -a \( -name test -o -name tests -o -name idle_test \) \) \ 85 | -o \( -type f -a \( -name '*.pyc' -o -name '*.pyo' -o -name 'libpython*.a' \) \) \ 86 | \) -exec rm -rf '{}' + \ 87 | ; \ 88 | \ 89 | ldconfig; \ 90 | \ 91 | export PYTHONDONTWRITEBYTECODE=1; \ 92 | python3 --version; \ 93 | \ 94 | pip3 install \ 95 | --disable-pip-version-check \ 96 | --no-cache-dir \ 97 | --no-compile \ 98 | 'setuptools==79.0.1' \ 99 | # https://github.com/docker-library/python/issues/1023 100 | 'wheel<0.46' \ 101 | ; \ 102 | pip3 --version 103 | 104 | # make some useful symlinks that are expected to exist ("/usr/local/bin/python" and friends) 105 | RUN set -eux; \ 106 | for src in idle3 pip3 pydoc3 python3 python3-config; do \ 107 | dst="$(echo "$src" | tr -d 3)"; \ 108 | [ -s "/usr/local/bin/$src" ]; \ 109 | [ ! -e "/usr/local/bin/$dst" ]; \ 110 | ln -svT "$src" "/usr/local/bin/$dst"; \ 111 | done 112 | 113 | CMD ["python3"] 114 | -------------------------------------------------------------------------------- /3.10/bookworm/Dockerfile: -------------------------------------------------------------------------------- 1 | # 2 | # NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh" 3 | # 4 | # PLEASE DO NOT EDIT IT DIRECTLY. 5 | # 6 | 7 | FROM buildpack-deps:bookworm 8 | 9 | # ensure local python is preferred over distribution python 10 | ENV PATH /usr/local/bin:$PATH 11 | 12 | # cannot remove LANG even though https://bugs.python.org/issue19846 is fixed 13 | # last attempted removal of LANG broke many users: 14 | # https://github.com/docker-library/python/pull/570 15 | ENV LANG C.UTF-8 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 GPG_KEY A035C8C19219BA821ECEA86B64E628F8D684696D 28 | ENV PYTHON_VERSION 3.10.19 29 | ENV PYTHON_SHA256 c8f4a596572201d81dd7df91f70e177e19a70f1d489968b54b5fbbf29a97c076 30 | 31 | RUN set -eux; \ 32 | \ 33 | wget -O python.tar.xz "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz"; \ 34 | echo "$PYTHON_SHA256 *python.tar.xz" | sha256sum -c -; \ 35 | wget -O python.tar.xz.asc "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz.asc"; \ 36 | GNUPGHOME="$(mktemp -d)"; export GNUPGHOME; \ 37 | gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$GPG_KEY"; \ 38 | gpg --batch --verify python.tar.xz.asc python.tar.xz; \ 39 | gpgconf --kill all; \ 40 | rm -rf "$GNUPGHOME" python.tar.xz.asc; \ 41 | mkdir -p /usr/src/python; \ 42 | tar --extract --directory /usr/src/python --strip-components=1 --file python.tar.xz; \ 43 | rm python.tar.xz; \ 44 | \ 45 | cd /usr/src/python; \ 46 | gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \ 47 | ./configure \ 48 | --build="$gnuArch" \ 49 | --enable-loadable-sqlite-extensions \ 50 | --enable-optimizations \ 51 | --enable-option-checking=fatal \ 52 | --enable-shared \ 53 | $(test "${gnuArch%%-*}" != 'riscv64' && echo '--with-lto') \ 54 | --with-ensurepip \ 55 | ; \ 56 | nproc="$(nproc)"; \ 57 | EXTRA_CFLAGS="$(dpkg-buildflags --get CFLAGS)"; \ 58 | LDFLAGS="$(dpkg-buildflags --get LDFLAGS)"; \ 59 | make -j "$nproc" \ 60 | "EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \ 61 | "LDFLAGS=${LDFLAGS:-}" \ 62 | ; \ 63 | # https://github.com/docker-library/python/issues/784 64 | # prevent accidental usage of a system installed libpython of the same version 65 | rm python; \ 66 | make -j "$nproc" \ 67 | "EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \ 68 | "LDFLAGS=${LDFLAGS:--Wl},-rpath='\$\$ORIGIN/../lib'" \ 69 | python \ 70 | ; \ 71 | make install; \ 72 | \ 73 | # enable GDB to load debugging data: https://github.com/docker-library/python/pull/701 74 | bin="$(readlink -ve /usr/local/bin/python3)"; \ 75 | dir="$(dirname "$bin")"; \ 76 | mkdir -p "/usr/share/gdb/auto-load/$dir"; \ 77 | cp -vL Tools/gdb/libpython.py "/usr/share/gdb/auto-load/$bin-gdb.py"; \ 78 | \ 79 | cd /; \ 80 | rm -rf /usr/src/python; \ 81 | \ 82 | find /usr/local -depth \ 83 | \( \ 84 | \( -type d -a \( -name test -o -name tests -o -name idle_test \) \) \ 85 | -o \( -type f -a \( -name '*.pyc' -o -name '*.pyo' -o -name 'libpython*.a' \) \) \ 86 | \) -exec rm -rf '{}' + \ 87 | ; \ 88 | \ 89 | ldconfig; \ 90 | \ 91 | export PYTHONDONTWRITEBYTECODE=1; \ 92 | python3 --version; \ 93 | \ 94 | pip3 install \ 95 | --disable-pip-version-check \ 96 | --no-cache-dir \ 97 | --no-compile \ 98 | 'setuptools==79.0.1' \ 99 | # https://github.com/docker-library/python/issues/1023 100 | 'wheel<0.46' \ 101 | ; \ 102 | pip3 --version 103 | 104 | # make some useful symlinks that are expected to exist ("/usr/local/bin/python" and friends) 105 | RUN set -eux; \ 106 | for src in idle3 pip3 pydoc3 python3 python3-config; do \ 107 | dst="$(echo "$src" | tr -d 3)"; \ 108 | [ -s "/usr/local/bin/$src" ]; \ 109 | [ ! -e "/usr/local/bin/$dst" ]; \ 110 | ln -svT "$src" "/usr/local/bin/$dst"; \ 111 | done 112 | 113 | CMD ["python3"] 114 | -------------------------------------------------------------------------------- /3.11/bookworm/Dockerfile: -------------------------------------------------------------------------------- 1 | # 2 | # NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh" 3 | # 4 | # PLEASE DO NOT EDIT IT DIRECTLY. 5 | # 6 | 7 | FROM buildpack-deps:bookworm 8 | 9 | # ensure local python is preferred over distribution python 10 | ENV PATH /usr/local/bin:$PATH 11 | 12 | # cannot remove LANG even though https://bugs.python.org/issue19846 is fixed 13 | # last attempted removal of LANG broke many users: 14 | # https://github.com/docker-library/python/pull/570 15 | ENV LANG C.UTF-8 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 GPG_KEY A035C8C19219BA821ECEA86B64E628F8D684696D 28 | ENV PYTHON_VERSION 3.11.14 29 | ENV PYTHON_SHA256 8d3ed8ec5c88c1c95f5e558612a725450d2452813ddad5e58fdb1a53b1209b78 30 | 31 | RUN set -eux; \ 32 | \ 33 | wget -O python.tar.xz "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz"; \ 34 | echo "$PYTHON_SHA256 *python.tar.xz" | sha256sum -c -; \ 35 | wget -O python.tar.xz.asc "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz.asc"; \ 36 | GNUPGHOME="$(mktemp -d)"; export GNUPGHOME; \ 37 | gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$GPG_KEY"; \ 38 | gpg --batch --verify python.tar.xz.asc python.tar.xz; \ 39 | gpgconf --kill all; \ 40 | rm -rf "$GNUPGHOME" python.tar.xz.asc; \ 41 | mkdir -p /usr/src/python; \ 42 | tar --extract --directory /usr/src/python --strip-components=1 --file python.tar.xz; \ 43 | rm python.tar.xz; \ 44 | \ 45 | cd /usr/src/python; \ 46 | gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \ 47 | ./configure \ 48 | --build="$gnuArch" \ 49 | --enable-loadable-sqlite-extensions \ 50 | --enable-optimizations \ 51 | --enable-option-checking=fatal \ 52 | --enable-shared \ 53 | $(test "${gnuArch%%-*}" != 'riscv64' && echo '--with-lto') \ 54 | --with-ensurepip \ 55 | ; \ 56 | nproc="$(nproc)"; \ 57 | EXTRA_CFLAGS="$(dpkg-buildflags --get CFLAGS)"; \ 58 | LDFLAGS="$(dpkg-buildflags --get LDFLAGS)"; \ 59 | make -j "$nproc" \ 60 | "EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \ 61 | "LDFLAGS=${LDFLAGS:-}" \ 62 | ; \ 63 | # https://github.com/docker-library/python/issues/784 64 | # prevent accidental usage of a system installed libpython of the same version 65 | rm python; \ 66 | make -j "$nproc" \ 67 | "EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \ 68 | "LDFLAGS=${LDFLAGS:--Wl},-rpath='\$\$ORIGIN/../lib'" \ 69 | python \ 70 | ; \ 71 | make install; \ 72 | \ 73 | # enable GDB to load debugging data: https://github.com/docker-library/python/pull/701 74 | bin="$(readlink -ve /usr/local/bin/python3)"; \ 75 | dir="$(dirname "$bin")"; \ 76 | mkdir -p "/usr/share/gdb/auto-load/$dir"; \ 77 | cp -vL Tools/gdb/libpython.py "/usr/share/gdb/auto-load/$bin-gdb.py"; \ 78 | \ 79 | cd /; \ 80 | rm -rf /usr/src/python; \ 81 | \ 82 | find /usr/local -depth \ 83 | \( \ 84 | \( -type d -a \( -name test -o -name tests -o -name idle_test \) \) \ 85 | -o \( -type f -a \( -name '*.pyc' -o -name '*.pyo' -o -name 'libpython*.a' \) \) \ 86 | \) -exec rm -rf '{}' + \ 87 | ; \ 88 | \ 89 | ldconfig; \ 90 | \ 91 | export PYTHONDONTWRITEBYTECODE=1; \ 92 | python3 --version; \ 93 | \ 94 | pip3 install \ 95 | --disable-pip-version-check \ 96 | --no-cache-dir \ 97 | --no-compile \ 98 | 'setuptools==79.0.1' \ 99 | # https://github.com/docker-library/python/issues/1023 100 | 'wheel<0.46' \ 101 | ; \ 102 | pip3 --version 103 | 104 | # make some useful symlinks that are expected to exist ("/usr/local/bin/python" and friends) 105 | RUN set -eux; \ 106 | for src in idle3 pip3 pydoc3 python3 python3-config; do \ 107 | dst="$(echo "$src" | tr -d 3)"; \ 108 | [ -s "/usr/local/bin/$src" ]; \ 109 | [ ! -e "/usr/local/bin/$dst" ]; \ 110 | ln -svT "$src" "/usr/local/bin/$dst"; \ 111 | done 112 | 113 | CMD ["python3"] 114 | -------------------------------------------------------------------------------- /3.13/trixie/Dockerfile: -------------------------------------------------------------------------------- 1 | # 2 | # NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh" 3 | # 4 | # PLEASE DO NOT EDIT IT DIRECTLY. 5 | # 6 | 7 | FROM buildpack-deps:trixie 8 | 9 | # ensure local python is preferred over distribution python 10 | ENV PATH /usr/local/bin:$PATH 11 | 12 | # runtime dependencies 13 | RUN set -eux; \ 14 | apt-get update; \ 15 | apt-get install -y --no-install-recommends \ 16 | libbluetooth-dev \ 17 | tk-dev \ 18 | uuid-dev \ 19 | ; \ 20 | apt-get dist-clean 21 | 22 | ENV GPG_KEY 7169605F62C751356D054A26A821E680E5FA6305 23 | ENV PYTHON_VERSION 3.13.11 24 | ENV PYTHON_SHA256 16ede7bb7cdbfa895d11b0642fa0e523f291e6487194d53cf6d3b338c3a17ea2 25 | 26 | RUN set -eux; \ 27 | \ 28 | wget -O python.tar.xz "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz"; \ 29 | echo "$PYTHON_SHA256 *python.tar.xz" | sha256sum -c -; \ 30 | wget -O python.tar.xz.asc "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz.asc"; \ 31 | GNUPGHOME="$(mktemp -d)"; export GNUPGHOME; \ 32 | gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$GPG_KEY"; \ 33 | gpg --batch --verify python.tar.xz.asc python.tar.xz; \ 34 | gpgconf --kill all; \ 35 | rm -rf "$GNUPGHOME" python.tar.xz.asc; \ 36 | mkdir -p /usr/src/python; \ 37 | tar --extract --directory /usr/src/python --strip-components=1 --file python.tar.xz; \ 38 | rm python.tar.xz; \ 39 | \ 40 | cd /usr/src/python; \ 41 | gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \ 42 | ./configure \ 43 | --build="$gnuArch" \ 44 | --enable-loadable-sqlite-extensions \ 45 | --enable-optimizations \ 46 | --enable-option-checking=fatal \ 47 | --enable-shared \ 48 | $(test "${gnuArch%%-*}" != 'riscv64' && echo '--with-lto') \ 49 | --with-ensurepip \ 50 | ; \ 51 | nproc="$(nproc)"; \ 52 | EXTRA_CFLAGS="$(dpkg-buildflags --get CFLAGS)"; \ 53 | LDFLAGS="$(dpkg-buildflags --get LDFLAGS)"; \ 54 | arch="$(dpkg --print-architecture)"; arch="${arch##*-}"; \ 55 | # https://docs.python.org/3.12/howto/perf_profiling.html 56 | # https://github.com/docker-library/python/pull/1000#issuecomment-2597021615 57 | case "$arch" in \ 58 | amd64|arm64) \ 59 | # only add "-mno-omit-leaf" on arches that support it 60 | # https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/x86-Options.html#index-momit-leaf-frame-pointer-2 61 | # https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/AArch64-Options.html#index-momit-leaf-frame-pointer 62 | EXTRA_CFLAGS="${EXTRA_CFLAGS:-} -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer"; \ 63 | ;; \ 64 | i386) \ 65 | # don't enable frame-pointers on 32bit x86 due to performance drop. 66 | ;; \ 67 | *) \ 68 | # other arches don't support "-mno-omit-leaf" 69 | EXTRA_CFLAGS="${EXTRA_CFLAGS:-} -fno-omit-frame-pointer"; \ 70 | ;; \ 71 | esac; \ 72 | make -j "$nproc" \ 73 | "EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \ 74 | "LDFLAGS=${LDFLAGS:-}" \ 75 | ; \ 76 | # https://github.com/docker-library/python/issues/784 77 | # prevent accidental usage of a system installed libpython of the same version 78 | rm python; \ 79 | make -j "$nproc" \ 80 | "EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \ 81 | "LDFLAGS=${LDFLAGS:--Wl},-rpath='\$\$ORIGIN/../lib'" \ 82 | python \ 83 | ; \ 84 | make install; \ 85 | \ 86 | # enable GDB to load debugging data: https://github.com/docker-library/python/pull/701 87 | bin="$(readlink -ve /usr/local/bin/python3)"; \ 88 | dir="$(dirname "$bin")"; \ 89 | mkdir -p "/usr/share/gdb/auto-load/$dir"; \ 90 | cp -vL Tools/gdb/libpython.py "/usr/share/gdb/auto-load/$bin-gdb.py"; \ 91 | \ 92 | cd /; \ 93 | rm -rf /usr/src/python; \ 94 | \ 95 | find /usr/local -depth \ 96 | \( \ 97 | \( -type d -a \( -name test -o -name tests -o -name idle_test \) \) \ 98 | -o \( -type f -a \( -name '*.pyc' -o -name '*.pyo' -o -name 'libpython*.a' \) \) \ 99 | \) -exec rm -rf '{}' + \ 100 | ; \ 101 | \ 102 | ldconfig; \ 103 | \ 104 | export PYTHONDONTWRITEBYTECODE=1; \ 105 | python3 --version; \ 106 | pip3 --version 107 | 108 | # make some useful symlinks that are expected to exist ("/usr/local/bin/python" and friends) 109 | RUN set -eux; \ 110 | for src in idle3 pip3 pydoc3 python3 python3-config; do \ 111 | dst="$(echo "$src" | tr -d 3)"; \ 112 | [ -s "/usr/local/bin/$src" ]; \ 113 | [ ! -e "/usr/local/bin/$dst" ]; \ 114 | ln -svT "$src" "/usr/local/bin/$dst"; \ 115 | done 116 | 117 | CMD ["python3"] 118 | -------------------------------------------------------------------------------- /3.13/bookworm/Dockerfile: -------------------------------------------------------------------------------- 1 | # 2 | # NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh" 3 | # 4 | # PLEASE DO NOT EDIT IT DIRECTLY. 5 | # 6 | 7 | FROM buildpack-deps:bookworm 8 | 9 | # ensure local python is preferred over distribution python 10 | ENV PATH /usr/local/bin:$PATH 11 | 12 | # runtime dependencies 13 | RUN set -eux; \ 14 | apt-get update; \ 15 | apt-get install -y --no-install-recommends \ 16 | libbluetooth-dev \ 17 | tk-dev \ 18 | uuid-dev \ 19 | ; \ 20 | rm -rf /var/lib/apt/lists/* 21 | 22 | ENV GPG_KEY 7169605F62C751356D054A26A821E680E5FA6305 23 | ENV PYTHON_VERSION 3.13.11 24 | ENV PYTHON_SHA256 16ede7bb7cdbfa895d11b0642fa0e523f291e6487194d53cf6d3b338c3a17ea2 25 | 26 | RUN set -eux; \ 27 | \ 28 | wget -O python.tar.xz "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz"; \ 29 | echo "$PYTHON_SHA256 *python.tar.xz" | sha256sum -c -; \ 30 | wget -O python.tar.xz.asc "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz.asc"; \ 31 | GNUPGHOME="$(mktemp -d)"; export GNUPGHOME; \ 32 | gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$GPG_KEY"; \ 33 | gpg --batch --verify python.tar.xz.asc python.tar.xz; \ 34 | gpgconf --kill all; \ 35 | rm -rf "$GNUPGHOME" python.tar.xz.asc; \ 36 | mkdir -p /usr/src/python; \ 37 | tar --extract --directory /usr/src/python --strip-components=1 --file python.tar.xz; \ 38 | rm python.tar.xz; \ 39 | \ 40 | cd /usr/src/python; \ 41 | gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \ 42 | ./configure \ 43 | --build="$gnuArch" \ 44 | --enable-loadable-sqlite-extensions \ 45 | --enable-optimizations \ 46 | --enable-option-checking=fatal \ 47 | --enable-shared \ 48 | $(test "${gnuArch%%-*}" != 'riscv64' && echo '--with-lto') \ 49 | --with-ensurepip \ 50 | ; \ 51 | nproc="$(nproc)"; \ 52 | EXTRA_CFLAGS="$(dpkg-buildflags --get CFLAGS)"; \ 53 | LDFLAGS="$(dpkg-buildflags --get LDFLAGS)"; \ 54 | arch="$(dpkg --print-architecture)"; arch="${arch##*-}"; \ 55 | # https://docs.python.org/3.12/howto/perf_profiling.html 56 | # https://github.com/docker-library/python/pull/1000#issuecomment-2597021615 57 | case "$arch" in \ 58 | amd64|arm64) \ 59 | # only add "-mno-omit-leaf" on arches that support it 60 | # https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/x86-Options.html#index-momit-leaf-frame-pointer-2 61 | # https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/AArch64-Options.html#index-momit-leaf-frame-pointer 62 | EXTRA_CFLAGS="${EXTRA_CFLAGS:-} -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer"; \ 63 | ;; \ 64 | i386) \ 65 | # don't enable frame-pointers on 32bit x86 due to performance drop. 66 | ;; \ 67 | *) \ 68 | # other arches don't support "-mno-omit-leaf" 69 | EXTRA_CFLAGS="${EXTRA_CFLAGS:-} -fno-omit-frame-pointer"; \ 70 | ;; \ 71 | esac; \ 72 | make -j "$nproc" \ 73 | "EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \ 74 | "LDFLAGS=${LDFLAGS:-}" \ 75 | ; \ 76 | # https://github.com/docker-library/python/issues/784 77 | # prevent accidental usage of a system installed libpython of the same version 78 | rm python; \ 79 | make -j "$nproc" \ 80 | "EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \ 81 | "LDFLAGS=${LDFLAGS:--Wl},-rpath='\$\$ORIGIN/../lib'" \ 82 | python \ 83 | ; \ 84 | make install; \ 85 | \ 86 | # enable GDB to load debugging data: https://github.com/docker-library/python/pull/701 87 | bin="$(readlink -ve /usr/local/bin/python3)"; \ 88 | dir="$(dirname "$bin")"; \ 89 | mkdir -p "/usr/share/gdb/auto-load/$dir"; \ 90 | cp -vL Tools/gdb/libpython.py "/usr/share/gdb/auto-load/$bin-gdb.py"; \ 91 | \ 92 | cd /; \ 93 | rm -rf /usr/src/python; \ 94 | \ 95 | find /usr/local -depth \ 96 | \( \ 97 | \( -type d -a \( -name test -o -name tests -o -name idle_test \) \) \ 98 | -o \( -type f -a \( -name '*.pyc' -o -name '*.pyo' -o -name 'libpython*.a' \) \) \ 99 | \) -exec rm -rf '{}' + \ 100 | ; \ 101 | \ 102 | ldconfig; \ 103 | \ 104 | export PYTHONDONTWRITEBYTECODE=1; \ 105 | python3 --version; \ 106 | pip3 --version 107 | 108 | # make some useful symlinks that are expected to exist ("/usr/local/bin/python" and friends) 109 | RUN set -eux; \ 110 | for src in idle3 pip3 pydoc3 python3 python3-config; do \ 111 | dst="$(echo "$src" | tr -d 3)"; \ 112 | [ -s "/usr/local/bin/$src" ]; \ 113 | [ ! -e "/usr/local/bin/$dst" ]; \ 114 | ln -svT "$src" "/usr/local/bin/$dst"; \ 115 | done 116 | 117 | CMD ["python3"] 118 | -------------------------------------------------------------------------------- /3.14/alpine3.22/Dockerfile: -------------------------------------------------------------------------------- 1 | # 2 | # NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh" 3 | # 4 | # PLEASE DO NOT EDIT IT DIRECTLY. 5 | # 6 | 7 | FROM alpine:3.22 8 | 9 | # ensure local python is preferred over distribution python 10 | ENV PATH /usr/local/bin:$PATH 11 | 12 | # runtime dependencies 13 | RUN set -eux; \ 14 | apk add --no-cache \ 15 | ca-certificates \ 16 | tzdata \ 17 | ; 18 | 19 | ENV PYTHON_VERSION 3.14.2 20 | ENV PYTHON_SHA256 ce543ab854bc256b61b71e9b27f831ffd1bfd60a479d639f8be7f9757cf573e9 21 | 22 | RUN set -eux; \ 23 | \ 24 | apk add --no-cache --virtual .build-deps \ 25 | bluez-dev \ 26 | bzip2-dev \ 27 | dpkg-dev dpkg \ 28 | findutils \ 29 | gcc \ 30 | gdbm-dev \ 31 | gnupg \ 32 | libc-dev \ 33 | libffi-dev \ 34 | libnsl-dev \ 35 | libtirpc-dev \ 36 | linux-headers \ 37 | make \ 38 | ncurses-dev \ 39 | openssl-dev \ 40 | pax-utils \ 41 | readline-dev \ 42 | sqlite-dev \ 43 | tar \ 44 | tcl-dev \ 45 | tk \ 46 | tk-dev \ 47 | util-linux-dev \ 48 | xz \ 49 | xz-dev \ 50 | zlib-dev \ 51 | zstd-dev \ 52 | ; \ 53 | \ 54 | wget -O python.tar.xz "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz"; \ 55 | echo "$PYTHON_SHA256 *python.tar.xz" | sha256sum -c -; \ 56 | mkdir -p /usr/src/python; \ 57 | tar --extract --directory /usr/src/python --strip-components=1 --file python.tar.xz; \ 58 | rm python.tar.xz; \ 59 | \ 60 | cd /usr/src/python; \ 61 | gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \ 62 | ./configure \ 63 | --build="$gnuArch" \ 64 | --enable-loadable-sqlite-extensions \ 65 | --enable-option-checking=fatal \ 66 | --enable-shared \ 67 | $(test "${gnuArch%%-*}" != 'riscv64' && echo '--with-lto') \ 68 | --with-ensurepip \ 69 | ; \ 70 | nproc="$(nproc)"; \ 71 | # set thread stack size to 1MB so we don't segfault before we hit sys.getrecursionlimit() 72 | # https://github.com/alpinelinux/aports/commit/2026e1259422d4e0cf92391ca2d3844356c649d0 73 | EXTRA_CFLAGS="-DTHREAD_STACK_SIZE=0x100000"; \ 74 | LDFLAGS="${LDFLAGS:--Wl},--strip-all"; \ 75 | arch="$(apk --print-arch)"; \ 76 | # https://docs.python.org/3.12/howto/perf_profiling.html 77 | # https://github.com/docker-library/python/pull/1000#issuecomment-2597021615 78 | case "$arch" in \ 79 | x86_64|aarch64) \ 80 | # only add "-mno-omit-leaf" on arches that support it 81 | # https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/x86-Options.html#index-momit-leaf-frame-pointer-2 82 | # https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/AArch64-Options.html#index-momit-leaf-frame-pointer 83 | EXTRA_CFLAGS="${EXTRA_CFLAGS:-} -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer"; \ 84 | ;; \ 85 | x86) \ 86 | # don't enable frame-pointers on 32bit x86 due to performance drop. 87 | ;; \ 88 | *) \ 89 | # other arches don't support "-mno-omit-leaf" 90 | EXTRA_CFLAGS="${EXTRA_CFLAGS:-} -fno-omit-frame-pointer"; \ 91 | ;; \ 92 | esac; \ 93 | make -j "$nproc" \ 94 | "EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \ 95 | "LDFLAGS=${LDFLAGS:-}" \ 96 | ; \ 97 | # https://github.com/docker-library/python/issues/784 98 | # prevent accidental usage of a system installed libpython of the same version 99 | rm python; \ 100 | make -j "$nproc" \ 101 | "EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \ 102 | "LDFLAGS=${LDFLAGS:--Wl},-rpath='\$\$ORIGIN/../lib'" \ 103 | python \ 104 | ; \ 105 | make install; \ 106 | \ 107 | cd /; \ 108 | rm -rf /usr/src/python; \ 109 | \ 110 | find /usr/local -depth \ 111 | \( \ 112 | \( -type d -a \( -name test -o -name tests -o -name idle_test \) \) \ 113 | -o \( -type f -a \( -name '*.pyc' -o -name '*.pyo' -o -name 'libpython*.a' \) \) \ 114 | \) -exec rm -rf '{}' + \ 115 | ; \ 116 | \ 117 | find /usr/local -type f -executable -not \( -name '*tkinter*' \) -exec scanelf --needed --nobanner --format '%n#p' '{}' ';' \ 118 | | tr ',' '\n' \ 119 | | sort -u \ 120 | | awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \ 121 | | xargs -rt apk add --no-network --virtual .python-rundeps \ 122 | ; \ 123 | apk del --no-network .build-deps; \ 124 | \ 125 | export PYTHONDONTWRITEBYTECODE=1; \ 126 | python3 --version; \ 127 | pip3 --version 128 | 129 | # make some useful symlinks that are expected to exist ("/usr/local/bin/python" and friends) 130 | RUN set -eux; \ 131 | for src in idle3 pip3 pydoc3 python3 python3-config; do \ 132 | dst="$(echo "$src" | tr -d 3)"; \ 133 | [ -s "/usr/local/bin/$src" ]; \ 134 | [ ! -e "/usr/local/bin/$dst" ]; \ 135 | ln -svT "$src" "/usr/local/bin/$dst"; \ 136 | done 137 | 138 | CMD ["python3"] 139 | -------------------------------------------------------------------------------- /3.14/alpine3.23/Dockerfile: -------------------------------------------------------------------------------- 1 | # 2 | # NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh" 3 | # 4 | # PLEASE DO NOT EDIT IT DIRECTLY. 5 | # 6 | 7 | FROM alpine:3.23 8 | 9 | # ensure local python is preferred over distribution python 10 | ENV PATH /usr/local/bin:$PATH 11 | 12 | # runtime dependencies 13 | RUN set -eux; \ 14 | apk add --no-cache \ 15 | ca-certificates \ 16 | tzdata \ 17 | ; 18 | 19 | ENV PYTHON_VERSION 3.14.2 20 | ENV PYTHON_SHA256 ce543ab854bc256b61b71e9b27f831ffd1bfd60a479d639f8be7f9757cf573e9 21 | 22 | RUN set -eux; \ 23 | \ 24 | apk add --no-cache --virtual .build-deps \ 25 | bluez-dev \ 26 | bzip2-dev \ 27 | dpkg-dev dpkg \ 28 | findutils \ 29 | gcc \ 30 | gdbm-dev \ 31 | gnupg \ 32 | libc-dev \ 33 | libffi-dev \ 34 | libnsl-dev \ 35 | libtirpc-dev \ 36 | linux-headers \ 37 | make \ 38 | ncurses-dev \ 39 | openssl-dev \ 40 | pax-utils \ 41 | readline-dev \ 42 | sqlite-dev \ 43 | tar \ 44 | tcl-dev \ 45 | tk \ 46 | tk-dev \ 47 | util-linux-dev \ 48 | xz \ 49 | xz-dev \ 50 | zlib-dev \ 51 | zstd-dev \ 52 | ; \ 53 | \ 54 | wget -O python.tar.xz "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz"; \ 55 | echo "$PYTHON_SHA256 *python.tar.xz" | sha256sum -c -; \ 56 | mkdir -p /usr/src/python; \ 57 | tar --extract --directory /usr/src/python --strip-components=1 --file python.tar.xz; \ 58 | rm python.tar.xz; \ 59 | \ 60 | cd /usr/src/python; \ 61 | gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \ 62 | ./configure \ 63 | --build="$gnuArch" \ 64 | --enable-loadable-sqlite-extensions \ 65 | --enable-option-checking=fatal \ 66 | --enable-shared \ 67 | $(test "${gnuArch%%-*}" != 'riscv64' && echo '--with-lto') \ 68 | --with-ensurepip \ 69 | ; \ 70 | nproc="$(nproc)"; \ 71 | # set thread stack size to 1MB so we don't segfault before we hit sys.getrecursionlimit() 72 | # https://github.com/alpinelinux/aports/commit/2026e1259422d4e0cf92391ca2d3844356c649d0 73 | EXTRA_CFLAGS="-DTHREAD_STACK_SIZE=0x100000"; \ 74 | LDFLAGS="${LDFLAGS:--Wl},--strip-all"; \ 75 | arch="$(apk --print-arch)"; \ 76 | # https://docs.python.org/3.12/howto/perf_profiling.html 77 | # https://github.com/docker-library/python/pull/1000#issuecomment-2597021615 78 | case "$arch" in \ 79 | x86_64|aarch64) \ 80 | # only add "-mno-omit-leaf" on arches that support it 81 | # https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/x86-Options.html#index-momit-leaf-frame-pointer-2 82 | # https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/AArch64-Options.html#index-momit-leaf-frame-pointer 83 | EXTRA_CFLAGS="${EXTRA_CFLAGS:-} -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer"; \ 84 | ;; \ 85 | x86) \ 86 | # don't enable frame-pointers on 32bit x86 due to performance drop. 87 | ;; \ 88 | *) \ 89 | # other arches don't support "-mno-omit-leaf" 90 | EXTRA_CFLAGS="${EXTRA_CFLAGS:-} -fno-omit-frame-pointer"; \ 91 | ;; \ 92 | esac; \ 93 | make -j "$nproc" \ 94 | "EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \ 95 | "LDFLAGS=${LDFLAGS:-}" \ 96 | ; \ 97 | # https://github.com/docker-library/python/issues/784 98 | # prevent accidental usage of a system installed libpython of the same version 99 | rm python; \ 100 | make -j "$nproc" \ 101 | "EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \ 102 | "LDFLAGS=${LDFLAGS:--Wl},-rpath='\$\$ORIGIN/../lib'" \ 103 | python \ 104 | ; \ 105 | make install; \ 106 | \ 107 | cd /; \ 108 | rm -rf /usr/src/python; \ 109 | \ 110 | find /usr/local -depth \ 111 | \( \ 112 | \( -type d -a \( -name test -o -name tests -o -name idle_test \) \) \ 113 | -o \( -type f -a \( -name '*.pyc' -o -name '*.pyo' -o -name 'libpython*.a' \) \) \ 114 | \) -exec rm -rf '{}' + \ 115 | ; \ 116 | \ 117 | find /usr/local -type f -executable -not \( -name '*tkinter*' \) -exec scanelf --needed --nobanner --format '%n#p' '{}' ';' \ 118 | | tr ',' '\n' \ 119 | | sort -u \ 120 | | awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \ 121 | | xargs -rt apk add --no-network --virtual .python-rundeps \ 122 | ; \ 123 | apk del --no-network .build-deps; \ 124 | \ 125 | export PYTHONDONTWRITEBYTECODE=1; \ 126 | python3 --version; \ 127 | pip3 --version 128 | 129 | # make some useful symlinks that are expected to exist ("/usr/local/bin/python" and friends) 130 | RUN set -eux; \ 131 | for src in idle3 pip3 pydoc3 python3 python3-config; do \ 132 | dst="$(echo "$src" | tr -d 3)"; \ 133 | [ -s "/usr/local/bin/$src" ]; \ 134 | [ ! -e "/usr/local/bin/$dst" ]; \ 135 | ln -svT "$src" "/usr/local/bin/$dst"; \ 136 | done 137 | 138 | CMD ["python3"] 139 | -------------------------------------------------------------------------------- /3.15-rc/alpine3.22/Dockerfile: -------------------------------------------------------------------------------- 1 | # 2 | # NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh" 3 | # 4 | # PLEASE DO NOT EDIT IT DIRECTLY. 5 | # 6 | 7 | FROM alpine:3.22 8 | 9 | # ensure local python is preferred over distribution python 10 | ENV PATH /usr/local/bin:$PATH 11 | 12 | # runtime dependencies 13 | RUN set -eux; \ 14 | apk add --no-cache \ 15 | ca-certificates \ 16 | tzdata \ 17 | ; 18 | 19 | ENV PYTHON_VERSION 3.15.0a3 20 | ENV PYTHON_SHA256 6ab02cdac24505779877bb1d9189432d67e90ddf2a9b8b7b373ead54ac07b607 21 | 22 | RUN set -eux; \ 23 | \ 24 | apk add --no-cache --virtual .build-deps \ 25 | bluez-dev \ 26 | bzip2-dev \ 27 | dpkg-dev dpkg \ 28 | findutils \ 29 | gcc \ 30 | gdbm-dev \ 31 | gnupg \ 32 | libc-dev \ 33 | libffi-dev \ 34 | libnsl-dev \ 35 | libtirpc-dev \ 36 | linux-headers \ 37 | make \ 38 | ncurses-dev \ 39 | openssl-dev \ 40 | pax-utils \ 41 | readline-dev \ 42 | sqlite-dev \ 43 | tar \ 44 | tcl-dev \ 45 | tk \ 46 | tk-dev \ 47 | util-linux-dev \ 48 | xz \ 49 | xz-dev \ 50 | zlib-dev \ 51 | zstd-dev \ 52 | ; \ 53 | \ 54 | wget -O python.tar.xz "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz"; \ 55 | echo "$PYTHON_SHA256 *python.tar.xz" | sha256sum -c -; \ 56 | mkdir -p /usr/src/python; \ 57 | tar --extract --directory /usr/src/python --strip-components=1 --file python.tar.xz; \ 58 | rm python.tar.xz; \ 59 | \ 60 | cd /usr/src/python; \ 61 | gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \ 62 | ./configure \ 63 | --build="$gnuArch" \ 64 | --enable-loadable-sqlite-extensions \ 65 | --enable-option-checking=fatal \ 66 | --enable-shared \ 67 | $(test "${gnuArch%%-*}" != 'riscv64' && echo '--with-lto') \ 68 | --with-ensurepip \ 69 | ; \ 70 | nproc="$(nproc)"; \ 71 | # set thread stack size to 1MB so we don't segfault before we hit sys.getrecursionlimit() 72 | # https://github.com/alpinelinux/aports/commit/2026e1259422d4e0cf92391ca2d3844356c649d0 73 | EXTRA_CFLAGS="-DTHREAD_STACK_SIZE=0x100000"; \ 74 | LDFLAGS="${LDFLAGS:--Wl},--strip-all"; \ 75 | arch="$(apk --print-arch)"; \ 76 | # https://docs.python.org/3.12/howto/perf_profiling.html 77 | # https://github.com/docker-library/python/pull/1000#issuecomment-2597021615 78 | case "$arch" in \ 79 | x86_64|aarch64) \ 80 | # only add "-mno-omit-leaf" on arches that support it 81 | # https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/x86-Options.html#index-momit-leaf-frame-pointer-2 82 | # https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/AArch64-Options.html#index-momit-leaf-frame-pointer 83 | EXTRA_CFLAGS="${EXTRA_CFLAGS:-} -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer"; \ 84 | ;; \ 85 | x86) \ 86 | # don't enable frame-pointers on 32bit x86 due to performance drop. 87 | ;; \ 88 | *) \ 89 | # other arches don't support "-mno-omit-leaf" 90 | EXTRA_CFLAGS="${EXTRA_CFLAGS:-} -fno-omit-frame-pointer"; \ 91 | ;; \ 92 | esac; \ 93 | make -j "$nproc" \ 94 | "EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \ 95 | "LDFLAGS=${LDFLAGS:-}" \ 96 | ; \ 97 | # https://github.com/docker-library/python/issues/784 98 | # prevent accidental usage of a system installed libpython of the same version 99 | rm python; \ 100 | make -j "$nproc" \ 101 | "EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \ 102 | "LDFLAGS=${LDFLAGS:--Wl},-rpath='\$\$ORIGIN/../lib'" \ 103 | python \ 104 | ; \ 105 | make install; \ 106 | \ 107 | cd /; \ 108 | rm -rf /usr/src/python; \ 109 | \ 110 | find /usr/local -depth \ 111 | \( \ 112 | \( -type d -a \( -name test -o -name tests -o -name idle_test \) \) \ 113 | -o \( -type f -a \( -name '*.pyc' -o -name '*.pyo' -o -name 'libpython*.a' \) \) \ 114 | \) -exec rm -rf '{}' + \ 115 | ; \ 116 | \ 117 | find /usr/local -type f -executable -not \( -name '*tkinter*' \) -exec scanelf --needed --nobanner --format '%n#p' '{}' ';' \ 118 | | tr ',' '\n' \ 119 | | sort -u \ 120 | | awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \ 121 | | xargs -rt apk add --no-network --virtual .python-rundeps \ 122 | ; \ 123 | apk del --no-network .build-deps; \ 124 | \ 125 | export PYTHONDONTWRITEBYTECODE=1; \ 126 | python3 --version; \ 127 | pip3 --version 128 | 129 | # make some useful symlinks that are expected to exist ("/usr/local/bin/python" and friends) 130 | RUN set -eux; \ 131 | for src in idle3 pip3 pydoc3 python3 python3-config; do \ 132 | dst="$(echo "$src" | tr -d 3)"; \ 133 | [ -s "/usr/local/bin/$src" ]; \ 134 | [ ! -e "/usr/local/bin/$dst" ]; \ 135 | ln -svT "$src" "/usr/local/bin/$dst"; \ 136 | done 137 | 138 | CMD ["python3"] 139 | -------------------------------------------------------------------------------- /3.15-rc/alpine3.23/Dockerfile: -------------------------------------------------------------------------------- 1 | # 2 | # NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh" 3 | # 4 | # PLEASE DO NOT EDIT IT DIRECTLY. 5 | # 6 | 7 | FROM alpine:3.23 8 | 9 | # ensure local python is preferred over distribution python 10 | ENV PATH /usr/local/bin:$PATH 11 | 12 | # runtime dependencies 13 | RUN set -eux; \ 14 | apk add --no-cache \ 15 | ca-certificates \ 16 | tzdata \ 17 | ; 18 | 19 | ENV PYTHON_VERSION 3.15.0a3 20 | ENV PYTHON_SHA256 6ab02cdac24505779877bb1d9189432d67e90ddf2a9b8b7b373ead54ac07b607 21 | 22 | RUN set -eux; \ 23 | \ 24 | apk add --no-cache --virtual .build-deps \ 25 | bluez-dev \ 26 | bzip2-dev \ 27 | dpkg-dev dpkg \ 28 | findutils \ 29 | gcc \ 30 | gdbm-dev \ 31 | gnupg \ 32 | libc-dev \ 33 | libffi-dev \ 34 | libnsl-dev \ 35 | libtirpc-dev \ 36 | linux-headers \ 37 | make \ 38 | ncurses-dev \ 39 | openssl-dev \ 40 | pax-utils \ 41 | readline-dev \ 42 | sqlite-dev \ 43 | tar \ 44 | tcl-dev \ 45 | tk \ 46 | tk-dev \ 47 | util-linux-dev \ 48 | xz \ 49 | xz-dev \ 50 | zlib-dev \ 51 | zstd-dev \ 52 | ; \ 53 | \ 54 | wget -O python.tar.xz "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz"; \ 55 | echo "$PYTHON_SHA256 *python.tar.xz" | sha256sum -c -; \ 56 | mkdir -p /usr/src/python; \ 57 | tar --extract --directory /usr/src/python --strip-components=1 --file python.tar.xz; \ 58 | rm python.tar.xz; \ 59 | \ 60 | cd /usr/src/python; \ 61 | gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \ 62 | ./configure \ 63 | --build="$gnuArch" \ 64 | --enable-loadable-sqlite-extensions \ 65 | --enable-option-checking=fatal \ 66 | --enable-shared \ 67 | $(test "${gnuArch%%-*}" != 'riscv64' && echo '--with-lto') \ 68 | --with-ensurepip \ 69 | ; \ 70 | nproc="$(nproc)"; \ 71 | # set thread stack size to 1MB so we don't segfault before we hit sys.getrecursionlimit() 72 | # https://github.com/alpinelinux/aports/commit/2026e1259422d4e0cf92391ca2d3844356c649d0 73 | EXTRA_CFLAGS="-DTHREAD_STACK_SIZE=0x100000"; \ 74 | LDFLAGS="${LDFLAGS:--Wl},--strip-all"; \ 75 | arch="$(apk --print-arch)"; \ 76 | # https://docs.python.org/3.12/howto/perf_profiling.html 77 | # https://github.com/docker-library/python/pull/1000#issuecomment-2597021615 78 | case "$arch" in \ 79 | x86_64|aarch64) \ 80 | # only add "-mno-omit-leaf" on arches that support it 81 | # https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/x86-Options.html#index-momit-leaf-frame-pointer-2 82 | # https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/AArch64-Options.html#index-momit-leaf-frame-pointer 83 | EXTRA_CFLAGS="${EXTRA_CFLAGS:-} -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer"; \ 84 | ;; \ 85 | x86) \ 86 | # don't enable frame-pointers on 32bit x86 due to performance drop. 87 | ;; \ 88 | *) \ 89 | # other arches don't support "-mno-omit-leaf" 90 | EXTRA_CFLAGS="${EXTRA_CFLAGS:-} -fno-omit-frame-pointer"; \ 91 | ;; \ 92 | esac; \ 93 | make -j "$nproc" \ 94 | "EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \ 95 | "LDFLAGS=${LDFLAGS:-}" \ 96 | ; \ 97 | # https://github.com/docker-library/python/issues/784 98 | # prevent accidental usage of a system installed libpython of the same version 99 | rm python; \ 100 | make -j "$nproc" \ 101 | "EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \ 102 | "LDFLAGS=${LDFLAGS:--Wl},-rpath='\$\$ORIGIN/../lib'" \ 103 | python \ 104 | ; \ 105 | make install; \ 106 | \ 107 | cd /; \ 108 | rm -rf /usr/src/python; \ 109 | \ 110 | find /usr/local -depth \ 111 | \( \ 112 | \( -type d -a \( -name test -o -name tests -o -name idle_test \) \) \ 113 | -o \( -type f -a \( -name '*.pyc' -o -name '*.pyo' -o -name 'libpython*.a' \) \) \ 114 | \) -exec rm -rf '{}' + \ 115 | ; \ 116 | \ 117 | find /usr/local -type f -executable -not \( -name '*tkinter*' \) -exec scanelf --needed --nobanner --format '%n#p' '{}' ';' \ 118 | | tr ',' '\n' \ 119 | | sort -u \ 120 | | awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \ 121 | | xargs -rt apk add --no-network --virtual .python-rundeps \ 122 | ; \ 123 | apk del --no-network .build-deps; \ 124 | \ 125 | export PYTHONDONTWRITEBYTECODE=1; \ 126 | python3 --version; \ 127 | pip3 --version 128 | 129 | # make some useful symlinks that are expected to exist ("/usr/local/bin/python" and friends) 130 | RUN set -eux; \ 131 | for src in idle3 pip3 pydoc3 python3 python3-config; do \ 132 | dst="$(echo "$src" | tr -d 3)"; \ 133 | [ -s "/usr/local/bin/$src" ]; \ 134 | [ ! -e "/usr/local/bin/$dst" ]; \ 135 | ln -svT "$src" "/usr/local/bin/$dst"; \ 136 | done 137 | 138 | CMD ["python3"] 139 | -------------------------------------------------------------------------------- /3.10/alpine3.22/Dockerfile: -------------------------------------------------------------------------------- 1 | # 2 | # NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh" 3 | # 4 | # PLEASE DO NOT EDIT IT DIRECTLY. 5 | # 6 | 7 | FROM alpine:3.22 8 | 9 | # ensure local python is preferred over distribution python 10 | ENV PATH /usr/local/bin:$PATH 11 | 12 | # cannot remove LANG even though https://bugs.python.org/issue19846 is fixed 13 | # last attempted removal of LANG broke many users: 14 | # https://github.com/docker-library/python/pull/570 15 | ENV LANG C.UTF-8 16 | 17 | # runtime dependencies 18 | RUN set -eux; \ 19 | apk add --no-cache \ 20 | ca-certificates \ 21 | tzdata \ 22 | ; 23 | 24 | ENV GPG_KEY A035C8C19219BA821ECEA86B64E628F8D684696D 25 | ENV PYTHON_VERSION 3.10.19 26 | ENV PYTHON_SHA256 c8f4a596572201d81dd7df91f70e177e19a70f1d489968b54b5fbbf29a97c076 27 | 28 | RUN set -eux; \ 29 | \ 30 | apk add --no-cache --virtual .build-deps \ 31 | bluez-dev \ 32 | bzip2-dev \ 33 | dpkg-dev dpkg \ 34 | findutils \ 35 | gcc \ 36 | gdbm-dev \ 37 | gnupg \ 38 | libc-dev \ 39 | libffi-dev \ 40 | libnsl-dev \ 41 | libtirpc-dev \ 42 | linux-headers \ 43 | make \ 44 | ncurses-dev \ 45 | openssl-dev \ 46 | pax-utils \ 47 | readline-dev \ 48 | sqlite-dev \ 49 | tar \ 50 | tcl-dev \ 51 | tk \ 52 | tk-dev \ 53 | util-linux-dev \ 54 | xz \ 55 | xz-dev \ 56 | zlib-dev \ 57 | ; \ 58 | \ 59 | wget -O python.tar.xz "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz"; \ 60 | echo "$PYTHON_SHA256 *python.tar.xz" | sha256sum -c -; \ 61 | wget -O python.tar.xz.asc "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz.asc"; \ 62 | GNUPGHOME="$(mktemp -d)"; export GNUPGHOME; \ 63 | gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$GPG_KEY"; \ 64 | gpg --batch --verify python.tar.xz.asc python.tar.xz; \ 65 | gpgconf --kill all; \ 66 | rm -rf "$GNUPGHOME" python.tar.xz.asc; \ 67 | mkdir -p /usr/src/python; \ 68 | tar --extract --directory /usr/src/python --strip-components=1 --file python.tar.xz; \ 69 | rm python.tar.xz; \ 70 | \ 71 | cd /usr/src/python; \ 72 | gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \ 73 | ./configure \ 74 | --build="$gnuArch" \ 75 | --enable-loadable-sqlite-extensions \ 76 | --enable-option-checking=fatal \ 77 | --enable-shared \ 78 | $(test "${gnuArch%%-*}" != 'riscv64' && echo '--with-lto') \ 79 | --with-ensurepip \ 80 | ; \ 81 | nproc="$(nproc)"; \ 82 | # set thread stack size to 1MB so we don't segfault before we hit sys.getrecursionlimit() 83 | # https://github.com/alpinelinux/aports/commit/2026e1259422d4e0cf92391ca2d3844356c649d0 84 | EXTRA_CFLAGS="-DTHREAD_STACK_SIZE=0x100000"; \ 85 | LDFLAGS="${LDFLAGS:--Wl},--strip-all"; \ 86 | make -j "$nproc" \ 87 | "EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \ 88 | "LDFLAGS=${LDFLAGS:-}" \ 89 | ; \ 90 | # https://github.com/docker-library/python/issues/784 91 | # prevent accidental usage of a system installed libpython of the same version 92 | rm python; \ 93 | make -j "$nproc" \ 94 | "EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \ 95 | "LDFLAGS=${LDFLAGS:--Wl},-rpath='\$\$ORIGIN/../lib'" \ 96 | python \ 97 | ; \ 98 | make install; \ 99 | \ 100 | cd /; \ 101 | rm -rf /usr/src/python; \ 102 | \ 103 | find /usr/local -depth \ 104 | \( \ 105 | \( -type d -a \( -name test -o -name tests -o -name idle_test \) \) \ 106 | -o \( -type f -a \( -name '*.pyc' -o -name '*.pyo' -o -name 'libpython*.a' \) \) \ 107 | \) -exec rm -rf '{}' + \ 108 | ; \ 109 | \ 110 | find /usr/local -type f -executable -not \( -name '*tkinter*' \) -exec scanelf --needed --nobanner --format '%n#p' '{}' ';' \ 111 | | tr ',' '\n' \ 112 | | sort -u \ 113 | | awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \ 114 | | xargs -rt apk add --no-network --virtual .python-rundeps \ 115 | ; \ 116 | apk del --no-network .build-deps; \ 117 | \ 118 | export PYTHONDONTWRITEBYTECODE=1; \ 119 | python3 --version; \ 120 | \ 121 | pip3 install \ 122 | --disable-pip-version-check \ 123 | --no-cache-dir \ 124 | --no-compile \ 125 | 'setuptools==79.0.1' \ 126 | # https://github.com/docker-library/python/issues/1023 127 | 'wheel<0.46' \ 128 | ; \ 129 | pip3 --version 130 | 131 | # make some useful symlinks that are expected to exist ("/usr/local/bin/python" and friends) 132 | RUN set -eux; \ 133 | for src in idle3 pip3 pydoc3 python3 python3-config; do \ 134 | dst="$(echo "$src" | tr -d 3)"; \ 135 | [ -s "/usr/local/bin/$src" ]; \ 136 | [ ! -e "/usr/local/bin/$dst" ]; \ 137 | ln -svT "$src" "/usr/local/bin/$dst"; \ 138 | done 139 | 140 | CMD ["python3"] 141 | -------------------------------------------------------------------------------- /3.10/alpine3.23/Dockerfile: -------------------------------------------------------------------------------- 1 | # 2 | # NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh" 3 | # 4 | # PLEASE DO NOT EDIT IT DIRECTLY. 5 | # 6 | 7 | FROM alpine:3.23 8 | 9 | # ensure local python is preferred over distribution python 10 | ENV PATH /usr/local/bin:$PATH 11 | 12 | # cannot remove LANG even though https://bugs.python.org/issue19846 is fixed 13 | # last attempted removal of LANG broke many users: 14 | # https://github.com/docker-library/python/pull/570 15 | ENV LANG C.UTF-8 16 | 17 | # runtime dependencies 18 | RUN set -eux; \ 19 | apk add --no-cache \ 20 | ca-certificates \ 21 | tzdata \ 22 | ; 23 | 24 | ENV GPG_KEY A035C8C19219BA821ECEA86B64E628F8D684696D 25 | ENV PYTHON_VERSION 3.10.19 26 | ENV PYTHON_SHA256 c8f4a596572201d81dd7df91f70e177e19a70f1d489968b54b5fbbf29a97c076 27 | 28 | RUN set -eux; \ 29 | \ 30 | apk add --no-cache --virtual .build-deps \ 31 | bluez-dev \ 32 | bzip2-dev \ 33 | dpkg-dev dpkg \ 34 | findutils \ 35 | gcc \ 36 | gdbm-dev \ 37 | gnupg \ 38 | libc-dev \ 39 | libffi-dev \ 40 | libnsl-dev \ 41 | libtirpc-dev \ 42 | linux-headers \ 43 | make \ 44 | ncurses-dev \ 45 | openssl-dev \ 46 | pax-utils \ 47 | readline-dev \ 48 | sqlite-dev \ 49 | tar \ 50 | tcl-dev \ 51 | tk \ 52 | tk-dev \ 53 | util-linux-dev \ 54 | xz \ 55 | xz-dev \ 56 | zlib-dev \ 57 | ; \ 58 | \ 59 | wget -O python.tar.xz "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz"; \ 60 | echo "$PYTHON_SHA256 *python.tar.xz" | sha256sum -c -; \ 61 | wget -O python.tar.xz.asc "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz.asc"; \ 62 | GNUPGHOME="$(mktemp -d)"; export GNUPGHOME; \ 63 | gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$GPG_KEY"; \ 64 | gpg --batch --verify python.tar.xz.asc python.tar.xz; \ 65 | gpgconf --kill all; \ 66 | rm -rf "$GNUPGHOME" python.tar.xz.asc; \ 67 | mkdir -p /usr/src/python; \ 68 | tar --extract --directory /usr/src/python --strip-components=1 --file python.tar.xz; \ 69 | rm python.tar.xz; \ 70 | \ 71 | cd /usr/src/python; \ 72 | gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \ 73 | ./configure \ 74 | --build="$gnuArch" \ 75 | --enable-loadable-sqlite-extensions \ 76 | --enable-option-checking=fatal \ 77 | --enable-shared \ 78 | $(test "${gnuArch%%-*}" != 'riscv64' && echo '--with-lto') \ 79 | --with-ensurepip \ 80 | ; \ 81 | nproc="$(nproc)"; \ 82 | # set thread stack size to 1MB so we don't segfault before we hit sys.getrecursionlimit() 83 | # https://github.com/alpinelinux/aports/commit/2026e1259422d4e0cf92391ca2d3844356c649d0 84 | EXTRA_CFLAGS="-DTHREAD_STACK_SIZE=0x100000"; \ 85 | LDFLAGS="${LDFLAGS:--Wl},--strip-all"; \ 86 | make -j "$nproc" \ 87 | "EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \ 88 | "LDFLAGS=${LDFLAGS:-}" \ 89 | ; \ 90 | # https://github.com/docker-library/python/issues/784 91 | # prevent accidental usage of a system installed libpython of the same version 92 | rm python; \ 93 | make -j "$nproc" \ 94 | "EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \ 95 | "LDFLAGS=${LDFLAGS:--Wl},-rpath='\$\$ORIGIN/../lib'" \ 96 | python \ 97 | ; \ 98 | make install; \ 99 | \ 100 | cd /; \ 101 | rm -rf /usr/src/python; \ 102 | \ 103 | find /usr/local -depth \ 104 | \( \ 105 | \( -type d -a \( -name test -o -name tests -o -name idle_test \) \) \ 106 | -o \( -type f -a \( -name '*.pyc' -o -name '*.pyo' -o -name 'libpython*.a' \) \) \ 107 | \) -exec rm -rf '{}' + \ 108 | ; \ 109 | \ 110 | find /usr/local -type f -executable -not \( -name '*tkinter*' \) -exec scanelf --needed --nobanner --format '%n#p' '{}' ';' \ 111 | | tr ',' '\n' \ 112 | | sort -u \ 113 | | awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \ 114 | | xargs -rt apk add --no-network --virtual .python-rundeps \ 115 | ; \ 116 | apk del --no-network .build-deps; \ 117 | \ 118 | export PYTHONDONTWRITEBYTECODE=1; \ 119 | python3 --version; \ 120 | \ 121 | pip3 install \ 122 | --disable-pip-version-check \ 123 | --no-cache-dir \ 124 | --no-compile \ 125 | 'setuptools==79.0.1' \ 126 | # https://github.com/docker-library/python/issues/1023 127 | 'wheel<0.46' \ 128 | ; \ 129 | pip3 --version 130 | 131 | # make some useful symlinks that are expected to exist ("/usr/local/bin/python" and friends) 132 | RUN set -eux; \ 133 | for src in idle3 pip3 pydoc3 python3 python3-config; do \ 134 | dst="$(echo "$src" | tr -d 3)"; \ 135 | [ -s "/usr/local/bin/$src" ]; \ 136 | [ ! -e "/usr/local/bin/$dst" ]; \ 137 | ln -svT "$src" "/usr/local/bin/$dst"; \ 138 | done 139 | 140 | CMD ["python3"] 141 | -------------------------------------------------------------------------------- /3.11/alpine3.22/Dockerfile: -------------------------------------------------------------------------------- 1 | # 2 | # NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh" 3 | # 4 | # PLEASE DO NOT EDIT IT DIRECTLY. 5 | # 6 | 7 | FROM alpine:3.22 8 | 9 | # ensure local python is preferred over distribution python 10 | ENV PATH /usr/local/bin:$PATH 11 | 12 | # cannot remove LANG even though https://bugs.python.org/issue19846 is fixed 13 | # last attempted removal of LANG broke many users: 14 | # https://github.com/docker-library/python/pull/570 15 | ENV LANG C.UTF-8 16 | 17 | # runtime dependencies 18 | RUN set -eux; \ 19 | apk add --no-cache \ 20 | ca-certificates \ 21 | tzdata \ 22 | ; 23 | 24 | ENV GPG_KEY A035C8C19219BA821ECEA86B64E628F8D684696D 25 | ENV PYTHON_VERSION 3.11.14 26 | ENV PYTHON_SHA256 8d3ed8ec5c88c1c95f5e558612a725450d2452813ddad5e58fdb1a53b1209b78 27 | 28 | RUN set -eux; \ 29 | \ 30 | apk add --no-cache --virtual .build-deps \ 31 | bluez-dev \ 32 | bzip2-dev \ 33 | dpkg-dev dpkg \ 34 | findutils \ 35 | gcc \ 36 | gdbm-dev \ 37 | gnupg \ 38 | libc-dev \ 39 | libffi-dev \ 40 | libnsl-dev \ 41 | libtirpc-dev \ 42 | linux-headers \ 43 | make \ 44 | ncurses-dev \ 45 | openssl-dev \ 46 | pax-utils \ 47 | readline-dev \ 48 | sqlite-dev \ 49 | tar \ 50 | tcl-dev \ 51 | tk \ 52 | tk-dev \ 53 | util-linux-dev \ 54 | xz \ 55 | xz-dev \ 56 | zlib-dev \ 57 | ; \ 58 | \ 59 | wget -O python.tar.xz "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz"; \ 60 | echo "$PYTHON_SHA256 *python.tar.xz" | sha256sum -c -; \ 61 | wget -O python.tar.xz.asc "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz.asc"; \ 62 | GNUPGHOME="$(mktemp -d)"; export GNUPGHOME; \ 63 | gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$GPG_KEY"; \ 64 | gpg --batch --verify python.tar.xz.asc python.tar.xz; \ 65 | gpgconf --kill all; \ 66 | rm -rf "$GNUPGHOME" python.tar.xz.asc; \ 67 | mkdir -p /usr/src/python; \ 68 | tar --extract --directory /usr/src/python --strip-components=1 --file python.tar.xz; \ 69 | rm python.tar.xz; \ 70 | \ 71 | cd /usr/src/python; \ 72 | gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \ 73 | ./configure \ 74 | --build="$gnuArch" \ 75 | --enable-loadable-sqlite-extensions \ 76 | --enable-option-checking=fatal \ 77 | --enable-shared \ 78 | $(test "${gnuArch%%-*}" != 'riscv64' && echo '--with-lto') \ 79 | --with-ensurepip \ 80 | ; \ 81 | nproc="$(nproc)"; \ 82 | # set thread stack size to 1MB so we don't segfault before we hit sys.getrecursionlimit() 83 | # https://github.com/alpinelinux/aports/commit/2026e1259422d4e0cf92391ca2d3844356c649d0 84 | EXTRA_CFLAGS="-DTHREAD_STACK_SIZE=0x100000"; \ 85 | LDFLAGS="${LDFLAGS:--Wl},--strip-all"; \ 86 | make -j "$nproc" \ 87 | "EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \ 88 | "LDFLAGS=${LDFLAGS:-}" \ 89 | ; \ 90 | # https://github.com/docker-library/python/issues/784 91 | # prevent accidental usage of a system installed libpython of the same version 92 | rm python; \ 93 | make -j "$nproc" \ 94 | "EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \ 95 | "LDFLAGS=${LDFLAGS:--Wl},-rpath='\$\$ORIGIN/../lib'" \ 96 | python \ 97 | ; \ 98 | make install; \ 99 | \ 100 | cd /; \ 101 | rm -rf /usr/src/python; \ 102 | \ 103 | find /usr/local -depth \ 104 | \( \ 105 | \( -type d -a \( -name test -o -name tests -o -name idle_test \) \) \ 106 | -o \( -type f -a \( -name '*.pyc' -o -name '*.pyo' -o -name 'libpython*.a' \) \) \ 107 | \) -exec rm -rf '{}' + \ 108 | ; \ 109 | \ 110 | find /usr/local -type f -executable -not \( -name '*tkinter*' \) -exec scanelf --needed --nobanner --format '%n#p' '{}' ';' \ 111 | | tr ',' '\n' \ 112 | | sort -u \ 113 | | awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \ 114 | | xargs -rt apk add --no-network --virtual .python-rundeps \ 115 | ; \ 116 | apk del --no-network .build-deps; \ 117 | \ 118 | export PYTHONDONTWRITEBYTECODE=1; \ 119 | python3 --version; \ 120 | \ 121 | pip3 install \ 122 | --disable-pip-version-check \ 123 | --no-cache-dir \ 124 | --no-compile \ 125 | 'setuptools==79.0.1' \ 126 | # https://github.com/docker-library/python/issues/1023 127 | 'wheel<0.46' \ 128 | ; \ 129 | pip3 --version 130 | 131 | # make some useful symlinks that are expected to exist ("/usr/local/bin/python" and friends) 132 | RUN set -eux; \ 133 | for src in idle3 pip3 pydoc3 python3 python3-config; do \ 134 | dst="$(echo "$src" | tr -d 3)"; \ 135 | [ -s "/usr/local/bin/$src" ]; \ 136 | [ ! -e "/usr/local/bin/$dst" ]; \ 137 | ln -svT "$src" "/usr/local/bin/$dst"; \ 138 | done 139 | 140 | CMD ["python3"] 141 | -------------------------------------------------------------------------------- /3.11/alpine3.23/Dockerfile: -------------------------------------------------------------------------------- 1 | # 2 | # NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh" 3 | # 4 | # PLEASE DO NOT EDIT IT DIRECTLY. 5 | # 6 | 7 | FROM alpine:3.23 8 | 9 | # ensure local python is preferred over distribution python 10 | ENV PATH /usr/local/bin:$PATH 11 | 12 | # cannot remove LANG even though https://bugs.python.org/issue19846 is fixed 13 | # last attempted removal of LANG broke many users: 14 | # https://github.com/docker-library/python/pull/570 15 | ENV LANG C.UTF-8 16 | 17 | # runtime dependencies 18 | RUN set -eux; \ 19 | apk add --no-cache \ 20 | ca-certificates \ 21 | tzdata \ 22 | ; 23 | 24 | ENV GPG_KEY A035C8C19219BA821ECEA86B64E628F8D684696D 25 | ENV PYTHON_VERSION 3.11.14 26 | ENV PYTHON_SHA256 8d3ed8ec5c88c1c95f5e558612a725450d2452813ddad5e58fdb1a53b1209b78 27 | 28 | RUN set -eux; \ 29 | \ 30 | apk add --no-cache --virtual .build-deps \ 31 | bluez-dev \ 32 | bzip2-dev \ 33 | dpkg-dev dpkg \ 34 | findutils \ 35 | gcc \ 36 | gdbm-dev \ 37 | gnupg \ 38 | libc-dev \ 39 | libffi-dev \ 40 | libnsl-dev \ 41 | libtirpc-dev \ 42 | linux-headers \ 43 | make \ 44 | ncurses-dev \ 45 | openssl-dev \ 46 | pax-utils \ 47 | readline-dev \ 48 | sqlite-dev \ 49 | tar \ 50 | tcl-dev \ 51 | tk \ 52 | tk-dev \ 53 | util-linux-dev \ 54 | xz \ 55 | xz-dev \ 56 | zlib-dev \ 57 | ; \ 58 | \ 59 | wget -O python.tar.xz "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz"; \ 60 | echo "$PYTHON_SHA256 *python.tar.xz" | sha256sum -c -; \ 61 | wget -O python.tar.xz.asc "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz.asc"; \ 62 | GNUPGHOME="$(mktemp -d)"; export GNUPGHOME; \ 63 | gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$GPG_KEY"; \ 64 | gpg --batch --verify python.tar.xz.asc python.tar.xz; \ 65 | gpgconf --kill all; \ 66 | rm -rf "$GNUPGHOME" python.tar.xz.asc; \ 67 | mkdir -p /usr/src/python; \ 68 | tar --extract --directory /usr/src/python --strip-components=1 --file python.tar.xz; \ 69 | rm python.tar.xz; \ 70 | \ 71 | cd /usr/src/python; \ 72 | gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \ 73 | ./configure \ 74 | --build="$gnuArch" \ 75 | --enable-loadable-sqlite-extensions \ 76 | --enable-option-checking=fatal \ 77 | --enable-shared \ 78 | $(test "${gnuArch%%-*}" != 'riscv64' && echo '--with-lto') \ 79 | --with-ensurepip \ 80 | ; \ 81 | nproc="$(nproc)"; \ 82 | # set thread stack size to 1MB so we don't segfault before we hit sys.getrecursionlimit() 83 | # https://github.com/alpinelinux/aports/commit/2026e1259422d4e0cf92391ca2d3844356c649d0 84 | EXTRA_CFLAGS="-DTHREAD_STACK_SIZE=0x100000"; \ 85 | LDFLAGS="${LDFLAGS:--Wl},--strip-all"; \ 86 | make -j "$nproc" \ 87 | "EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \ 88 | "LDFLAGS=${LDFLAGS:-}" \ 89 | ; \ 90 | # https://github.com/docker-library/python/issues/784 91 | # prevent accidental usage of a system installed libpython of the same version 92 | rm python; \ 93 | make -j "$nproc" \ 94 | "EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \ 95 | "LDFLAGS=${LDFLAGS:--Wl},-rpath='\$\$ORIGIN/../lib'" \ 96 | python \ 97 | ; \ 98 | make install; \ 99 | \ 100 | cd /; \ 101 | rm -rf /usr/src/python; \ 102 | \ 103 | find /usr/local -depth \ 104 | \( \ 105 | \( -type d -a \( -name test -o -name tests -o -name idle_test \) \) \ 106 | -o \( -type f -a \( -name '*.pyc' -o -name '*.pyo' -o -name 'libpython*.a' \) \) \ 107 | \) -exec rm -rf '{}' + \ 108 | ; \ 109 | \ 110 | find /usr/local -type f -executable -not \( -name '*tkinter*' \) -exec scanelf --needed --nobanner --format '%n#p' '{}' ';' \ 111 | | tr ',' '\n' \ 112 | | sort -u \ 113 | | awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \ 114 | | xargs -rt apk add --no-network --virtual .python-rundeps \ 115 | ; \ 116 | apk del --no-network .build-deps; \ 117 | \ 118 | export PYTHONDONTWRITEBYTECODE=1; \ 119 | python3 --version; \ 120 | \ 121 | pip3 install \ 122 | --disable-pip-version-check \ 123 | --no-cache-dir \ 124 | --no-compile \ 125 | 'setuptools==79.0.1' \ 126 | # https://github.com/docker-library/python/issues/1023 127 | 'wheel<0.46' \ 128 | ; \ 129 | pip3 --version 130 | 131 | # make some useful symlinks that are expected to exist ("/usr/local/bin/python" and friends) 132 | RUN set -eux; \ 133 | for src in idle3 pip3 pydoc3 python3 python3-config; do \ 134 | dst="$(echo "$src" | tr -d 3)"; \ 135 | [ -s "/usr/local/bin/$src" ]; \ 136 | [ ! -e "/usr/local/bin/$dst" ]; \ 137 | ln -svT "$src" "/usr/local/bin/$dst"; \ 138 | done 139 | 140 | CMD ["python3"] 141 | -------------------------------------------------------------------------------- /3.12/trixie/Dockerfile: -------------------------------------------------------------------------------- 1 | # 2 | # NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh" 3 | # 4 | # PLEASE DO NOT EDIT IT DIRECTLY. 5 | # 6 | 7 | FROM buildpack-deps:trixie 8 | 9 | # ensure local python is preferred over distribution python 10 | ENV PATH /usr/local/bin:$PATH 11 | 12 | # cannot remove LANG even though https://bugs.python.org/issue19846 is fixed 13 | # last attempted removal of LANG broke many users: 14 | # https://github.com/docker-library/python/pull/570 15 | ENV LANG C.UTF-8 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 | apt-get dist-clean 26 | 27 | ENV GPG_KEY 7169605F62C751356D054A26A821E680E5FA6305 28 | ENV PYTHON_VERSION 3.12.12 29 | ENV PYTHON_SHA256 fb85a13414b028c49ba18bbd523c2d055a30b56b18b92ce454ea2c51edc656c4 30 | 31 | RUN set -eux; \ 32 | \ 33 | wget -O python.tar.xz "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz"; \ 34 | echo "$PYTHON_SHA256 *python.tar.xz" | sha256sum -c -; \ 35 | wget -O python.tar.xz.asc "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz.asc"; \ 36 | GNUPGHOME="$(mktemp -d)"; export GNUPGHOME; \ 37 | gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$GPG_KEY"; \ 38 | gpg --batch --verify python.tar.xz.asc python.tar.xz; \ 39 | gpgconf --kill all; \ 40 | rm -rf "$GNUPGHOME" python.tar.xz.asc; \ 41 | mkdir -p /usr/src/python; \ 42 | tar --extract --directory /usr/src/python --strip-components=1 --file python.tar.xz; \ 43 | rm python.tar.xz; \ 44 | \ 45 | cd /usr/src/python; \ 46 | gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \ 47 | ./configure \ 48 | --build="$gnuArch" \ 49 | --enable-loadable-sqlite-extensions \ 50 | --enable-optimizations \ 51 | --enable-option-checking=fatal \ 52 | --enable-shared \ 53 | $(test "${gnuArch%%-*}" != 'riscv64' && echo '--with-lto') \ 54 | --with-ensurepip \ 55 | ; \ 56 | nproc="$(nproc)"; \ 57 | EXTRA_CFLAGS="$(dpkg-buildflags --get CFLAGS)"; \ 58 | LDFLAGS="$(dpkg-buildflags --get LDFLAGS)"; \ 59 | arch="$(dpkg --print-architecture)"; arch="${arch##*-}"; \ 60 | # https://docs.python.org/3.12/howto/perf_profiling.html 61 | # https://github.com/docker-library/python/pull/1000#issuecomment-2597021615 62 | case "$arch" in \ 63 | amd64|arm64) \ 64 | # only add "-mno-omit-leaf" on arches that support it 65 | # https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/x86-Options.html#index-momit-leaf-frame-pointer-2 66 | # https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/AArch64-Options.html#index-momit-leaf-frame-pointer 67 | EXTRA_CFLAGS="${EXTRA_CFLAGS:-} -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer"; \ 68 | ;; \ 69 | i386) \ 70 | # don't enable frame-pointers on 32bit x86 due to performance drop. 71 | ;; \ 72 | *) \ 73 | # other arches don't support "-mno-omit-leaf" 74 | EXTRA_CFLAGS="${EXTRA_CFLAGS:-} -fno-omit-frame-pointer"; \ 75 | ;; \ 76 | esac; \ 77 | make -j "$nproc" \ 78 | "EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \ 79 | "LDFLAGS=${LDFLAGS:-}" \ 80 | ; \ 81 | # https://github.com/docker-library/python/issues/784 82 | # prevent accidental usage of a system installed libpython of the same version 83 | rm python; \ 84 | make -j "$nproc" \ 85 | "EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \ 86 | "LDFLAGS=${LDFLAGS:--Wl},-rpath='\$\$ORIGIN/../lib'" \ 87 | python \ 88 | ; \ 89 | make install; \ 90 | \ 91 | # enable GDB to load debugging data: https://github.com/docker-library/python/pull/701 92 | bin="$(readlink -ve /usr/local/bin/python3)"; \ 93 | dir="$(dirname "$bin")"; \ 94 | mkdir -p "/usr/share/gdb/auto-load/$dir"; \ 95 | cp -vL Tools/gdb/libpython.py "/usr/share/gdb/auto-load/$bin-gdb.py"; \ 96 | \ 97 | cd /; \ 98 | rm -rf /usr/src/python; \ 99 | \ 100 | find /usr/local -depth \ 101 | \( \ 102 | \( -type d -a \( -name test -o -name tests -o -name idle_test \) \) \ 103 | -o \( -type f -a \( -name '*.pyc' -o -name '*.pyo' -o -name 'libpython*.a' \) \) \ 104 | \) -exec rm -rf '{}' + \ 105 | ; \ 106 | \ 107 | ldconfig; \ 108 | \ 109 | export PYTHONDONTWRITEBYTECODE=1; \ 110 | python3 --version; \ 111 | pip3 --version 112 | 113 | # make some useful symlinks that are expected to exist ("/usr/local/bin/python" and friends) 114 | RUN set -eux; \ 115 | for src in idle3 pip3 pydoc3 python3 python3-config; do \ 116 | dst="$(echo "$src" | tr -d 3)"; \ 117 | [ -s "/usr/local/bin/$src" ]; \ 118 | [ ! -e "/usr/local/bin/$dst" ]; \ 119 | ln -svT "$src" "/usr/local/bin/$dst"; \ 120 | done 121 | 122 | CMD ["python3"] 123 | -------------------------------------------------------------------------------- /3.12/bookworm/Dockerfile: -------------------------------------------------------------------------------- 1 | # 2 | # NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh" 3 | # 4 | # PLEASE DO NOT EDIT IT DIRECTLY. 5 | # 6 | 7 | FROM buildpack-deps:bookworm 8 | 9 | # ensure local python is preferred over distribution python 10 | ENV PATH /usr/local/bin:$PATH 11 | 12 | # cannot remove LANG even though https://bugs.python.org/issue19846 is fixed 13 | # last attempted removal of LANG broke many users: 14 | # https://github.com/docker-library/python/pull/570 15 | ENV LANG C.UTF-8 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 GPG_KEY 7169605F62C751356D054A26A821E680E5FA6305 28 | ENV PYTHON_VERSION 3.12.12 29 | ENV PYTHON_SHA256 fb85a13414b028c49ba18bbd523c2d055a30b56b18b92ce454ea2c51edc656c4 30 | 31 | RUN set -eux; \ 32 | \ 33 | wget -O python.tar.xz "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz"; \ 34 | echo "$PYTHON_SHA256 *python.tar.xz" | sha256sum -c -; \ 35 | wget -O python.tar.xz.asc "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz.asc"; \ 36 | GNUPGHOME="$(mktemp -d)"; export GNUPGHOME; \ 37 | gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$GPG_KEY"; \ 38 | gpg --batch --verify python.tar.xz.asc python.tar.xz; \ 39 | gpgconf --kill all; \ 40 | rm -rf "$GNUPGHOME" python.tar.xz.asc; \ 41 | mkdir -p /usr/src/python; \ 42 | tar --extract --directory /usr/src/python --strip-components=1 --file python.tar.xz; \ 43 | rm python.tar.xz; \ 44 | \ 45 | cd /usr/src/python; \ 46 | gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \ 47 | ./configure \ 48 | --build="$gnuArch" \ 49 | --enable-loadable-sqlite-extensions \ 50 | --enable-optimizations \ 51 | --enable-option-checking=fatal \ 52 | --enable-shared \ 53 | $(test "${gnuArch%%-*}" != 'riscv64' && echo '--with-lto') \ 54 | --with-ensurepip \ 55 | ; \ 56 | nproc="$(nproc)"; \ 57 | EXTRA_CFLAGS="$(dpkg-buildflags --get CFLAGS)"; \ 58 | LDFLAGS="$(dpkg-buildflags --get LDFLAGS)"; \ 59 | arch="$(dpkg --print-architecture)"; arch="${arch##*-}"; \ 60 | # https://docs.python.org/3.12/howto/perf_profiling.html 61 | # https://github.com/docker-library/python/pull/1000#issuecomment-2597021615 62 | case "$arch" in \ 63 | amd64|arm64) \ 64 | # only add "-mno-omit-leaf" on arches that support it 65 | # https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/x86-Options.html#index-momit-leaf-frame-pointer-2 66 | # https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/AArch64-Options.html#index-momit-leaf-frame-pointer 67 | EXTRA_CFLAGS="${EXTRA_CFLAGS:-} -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer"; \ 68 | ;; \ 69 | i386) \ 70 | # don't enable frame-pointers on 32bit x86 due to performance drop. 71 | ;; \ 72 | *) \ 73 | # other arches don't support "-mno-omit-leaf" 74 | EXTRA_CFLAGS="${EXTRA_CFLAGS:-} -fno-omit-frame-pointer"; \ 75 | ;; \ 76 | esac; \ 77 | make -j "$nproc" \ 78 | "EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \ 79 | "LDFLAGS=${LDFLAGS:-}" \ 80 | ; \ 81 | # https://github.com/docker-library/python/issues/784 82 | # prevent accidental usage of a system installed libpython of the same version 83 | rm python; \ 84 | make -j "$nproc" \ 85 | "EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \ 86 | "LDFLAGS=${LDFLAGS:--Wl},-rpath='\$\$ORIGIN/../lib'" \ 87 | python \ 88 | ; \ 89 | make install; \ 90 | \ 91 | # enable GDB to load debugging data: https://github.com/docker-library/python/pull/701 92 | bin="$(readlink -ve /usr/local/bin/python3)"; \ 93 | dir="$(dirname "$bin")"; \ 94 | mkdir -p "/usr/share/gdb/auto-load/$dir"; \ 95 | cp -vL Tools/gdb/libpython.py "/usr/share/gdb/auto-load/$bin-gdb.py"; \ 96 | \ 97 | cd /; \ 98 | rm -rf /usr/src/python; \ 99 | \ 100 | find /usr/local -depth \ 101 | \( \ 102 | \( -type d -a \( -name test -o -name tests -o -name idle_test \) \) \ 103 | -o \( -type f -a \( -name '*.pyc' -o -name '*.pyo' -o -name 'libpython*.a' \) \) \ 104 | \) -exec rm -rf '{}' + \ 105 | ; \ 106 | \ 107 | ldconfig; \ 108 | \ 109 | export PYTHONDONTWRITEBYTECODE=1; \ 110 | python3 --version; \ 111 | pip3 --version 112 | 113 | # make some useful symlinks that are expected to exist ("/usr/local/bin/python" and friends) 114 | RUN set -eux; \ 115 | for src in idle3 pip3 pydoc3 python3 python3-config; do \ 116 | dst="$(echo "$src" | tr -d 3)"; \ 117 | [ -s "/usr/local/bin/$src" ]; \ 118 | [ ! -e "/usr/local/bin/$dst" ]; \ 119 | ln -svT "$src" "/usr/local/bin/$dst"; \ 120 | done 121 | 122 | CMD ["python3"] 123 | -------------------------------------------------------------------------------- /3.14/trixie/Dockerfile: -------------------------------------------------------------------------------- 1 | # 2 | # NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh" 3 | # 4 | # PLEASE DO NOT EDIT IT DIRECTLY. 5 | # 6 | 7 | FROM buildpack-deps:trixie 8 | 9 | # ensure local python is preferred over distribution python 10 | ENV PATH /usr/local/bin:$PATH 11 | 12 | # runtime dependencies 13 | RUN set -eux; \ 14 | apt-get update; \ 15 | apt-get install -y --no-install-recommends \ 16 | libbluetooth-dev \ 17 | tk-dev \ 18 | uuid-dev \ 19 | ; \ 20 | apt-get dist-clean 21 | 22 | ENV PYTHON_VERSION 3.14.2 23 | ENV PYTHON_SHA256 ce543ab854bc256b61b71e9b27f831ffd1bfd60a479d639f8be7f9757cf573e9 24 | 25 | RUN set -eux; \ 26 | \ 27 | savedAptMark="$(apt-mark showmanual)"; \ 28 | apt-get update; \ 29 | apt-get install -y --no-install-recommends \ 30 | libzstd-dev \ 31 | ; \ 32 | \ 33 | wget -O python.tar.xz "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz"; \ 34 | echo "$PYTHON_SHA256 *python.tar.xz" | sha256sum -c -; \ 35 | mkdir -p /usr/src/python; \ 36 | tar --extract --directory /usr/src/python --strip-components=1 --file python.tar.xz; \ 37 | rm python.tar.xz; \ 38 | \ 39 | cd /usr/src/python; \ 40 | gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \ 41 | ./configure \ 42 | --build="$gnuArch" \ 43 | --enable-loadable-sqlite-extensions \ 44 | --enable-optimizations \ 45 | --enable-option-checking=fatal \ 46 | --enable-shared \ 47 | $(test "${gnuArch%%-*}" != 'riscv64' && echo '--with-lto') \ 48 | --with-ensurepip \ 49 | ; \ 50 | nproc="$(nproc)"; \ 51 | EXTRA_CFLAGS="$(dpkg-buildflags --get CFLAGS)"; \ 52 | LDFLAGS="$(dpkg-buildflags --get LDFLAGS)"; \ 53 | arch="$(dpkg --print-architecture)"; arch="${arch##*-}"; \ 54 | # https://docs.python.org/3.12/howto/perf_profiling.html 55 | # https://github.com/docker-library/python/pull/1000#issuecomment-2597021615 56 | case "$arch" in \ 57 | amd64|arm64) \ 58 | # only add "-mno-omit-leaf" on arches that support it 59 | # https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/x86-Options.html#index-momit-leaf-frame-pointer-2 60 | # https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/AArch64-Options.html#index-momit-leaf-frame-pointer 61 | EXTRA_CFLAGS="${EXTRA_CFLAGS:-} -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer"; \ 62 | ;; \ 63 | i386) \ 64 | # don't enable frame-pointers on 32bit x86 due to performance drop. 65 | ;; \ 66 | *) \ 67 | # other arches don't support "-mno-omit-leaf" 68 | EXTRA_CFLAGS="${EXTRA_CFLAGS:-} -fno-omit-frame-pointer"; \ 69 | ;; \ 70 | esac; \ 71 | make -j "$nproc" \ 72 | "EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \ 73 | "LDFLAGS=${LDFLAGS:-}" \ 74 | ; \ 75 | # https://github.com/docker-library/python/issues/784 76 | # prevent accidental usage of a system installed libpython of the same version 77 | rm python; \ 78 | make -j "$nproc" \ 79 | "EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \ 80 | "LDFLAGS=${LDFLAGS:--Wl},-rpath='\$\$ORIGIN/../lib'" \ 81 | python \ 82 | ; \ 83 | make install; \ 84 | \ 85 | # enable GDB to load debugging data: https://github.com/docker-library/python/pull/701 86 | bin="$(readlink -ve /usr/local/bin/python3)"; \ 87 | dir="$(dirname "$bin")"; \ 88 | mkdir -p "/usr/share/gdb/auto-load/$dir"; \ 89 | cp -vL Tools/gdb/libpython.py "/usr/share/gdb/auto-load/$bin-gdb.py"; \ 90 | \ 91 | cd /; \ 92 | rm -rf /usr/src/python; \ 93 | \ 94 | find /usr/local -depth \ 95 | \( \ 96 | \( -type d -a \( -name test -o -name tests -o -name idle_test \) \) \ 97 | -o \( -type f -a \( -name '*.pyc' -o -name '*.pyo' -o -name 'libpython*.a' \) \) \ 98 | \) -exec rm -rf '{}' + \ 99 | ; \ 100 | \ 101 | ldconfig; \ 102 | \ 103 | apt-mark auto '.*' > /dev/null; \ 104 | apt-mark manual $savedAptMark; \ 105 | find /usr/local -type f -executable -not \( -name '*tkinter*' \) -exec ldd '{}' ';' \ 106 | | awk '/=>/ { so = $(NF-1); if (index(so, "/usr/local/") == 1) { next }; gsub("^/(usr/)?", "", so); printf "*%s\n", so }' \ 107 | | sort -u \ 108 | | xargs -rt dpkg-query --search \ 109 | # https://manpages.debian.org/bookworm/dpkg/dpkg-query.1.en.html#S (we ignore diversions and it'll be really unusual for more than one package to provide any given .so file) 110 | | awk 'sub(":$", "", $1) { print $1 }' \ 111 | | sort -u \ 112 | | xargs -r apt-mark manual \ 113 | ; \ 114 | apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ 115 | apt-get dist-clean; \ 116 | \ 117 | export PYTHONDONTWRITEBYTECODE=1; \ 118 | python3 --version; \ 119 | pip3 --version 120 | 121 | # make some useful symlinks that are expected to exist ("/usr/local/bin/python" and friends) 122 | RUN set -eux; \ 123 | for src in idle3 pip3 pydoc3 python3 python3-config; do \ 124 | dst="$(echo "$src" | tr -d 3)"; \ 125 | [ -s "/usr/local/bin/$src" ]; \ 126 | [ ! -e "/usr/local/bin/$dst" ]; \ 127 | ln -svT "$src" "/usr/local/bin/$dst"; \ 128 | done 129 | 130 | CMD ["python3"] 131 | -------------------------------------------------------------------------------- /3.15-rc/trixie/Dockerfile: -------------------------------------------------------------------------------- 1 | # 2 | # NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh" 3 | # 4 | # PLEASE DO NOT EDIT IT DIRECTLY. 5 | # 6 | 7 | FROM buildpack-deps:trixie 8 | 9 | # ensure local python is preferred over distribution python 10 | ENV PATH /usr/local/bin:$PATH 11 | 12 | # runtime dependencies 13 | RUN set -eux; \ 14 | apt-get update; \ 15 | apt-get install -y --no-install-recommends \ 16 | libbluetooth-dev \ 17 | tk-dev \ 18 | uuid-dev \ 19 | ; \ 20 | apt-get dist-clean 21 | 22 | ENV PYTHON_VERSION 3.15.0a3 23 | ENV PYTHON_SHA256 6ab02cdac24505779877bb1d9189432d67e90ddf2a9b8b7b373ead54ac07b607 24 | 25 | RUN set -eux; \ 26 | \ 27 | savedAptMark="$(apt-mark showmanual)"; \ 28 | apt-get update; \ 29 | apt-get install -y --no-install-recommends \ 30 | libzstd-dev \ 31 | ; \ 32 | \ 33 | wget -O python.tar.xz "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz"; \ 34 | echo "$PYTHON_SHA256 *python.tar.xz" | sha256sum -c -; \ 35 | mkdir -p /usr/src/python; \ 36 | tar --extract --directory /usr/src/python --strip-components=1 --file python.tar.xz; \ 37 | rm python.tar.xz; \ 38 | \ 39 | cd /usr/src/python; \ 40 | gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \ 41 | ./configure \ 42 | --build="$gnuArch" \ 43 | --enable-loadable-sqlite-extensions \ 44 | --enable-optimizations \ 45 | --enable-option-checking=fatal \ 46 | --enable-shared \ 47 | $(test "${gnuArch%%-*}" != 'riscv64' && echo '--with-lto') \ 48 | --with-ensurepip \ 49 | ; \ 50 | nproc="$(nproc)"; \ 51 | EXTRA_CFLAGS="$(dpkg-buildflags --get CFLAGS)"; \ 52 | LDFLAGS="$(dpkg-buildflags --get LDFLAGS)"; \ 53 | arch="$(dpkg --print-architecture)"; arch="${arch##*-}"; \ 54 | # https://docs.python.org/3.12/howto/perf_profiling.html 55 | # https://github.com/docker-library/python/pull/1000#issuecomment-2597021615 56 | case "$arch" in \ 57 | amd64|arm64) \ 58 | # only add "-mno-omit-leaf" on arches that support it 59 | # https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/x86-Options.html#index-momit-leaf-frame-pointer-2 60 | # https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/AArch64-Options.html#index-momit-leaf-frame-pointer 61 | EXTRA_CFLAGS="${EXTRA_CFLAGS:-} -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer"; \ 62 | ;; \ 63 | i386) \ 64 | # don't enable frame-pointers on 32bit x86 due to performance drop. 65 | ;; \ 66 | *) \ 67 | # other arches don't support "-mno-omit-leaf" 68 | EXTRA_CFLAGS="${EXTRA_CFLAGS:-} -fno-omit-frame-pointer"; \ 69 | ;; \ 70 | esac; \ 71 | make -j "$nproc" \ 72 | "EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \ 73 | "LDFLAGS=${LDFLAGS:-}" \ 74 | ; \ 75 | # https://github.com/docker-library/python/issues/784 76 | # prevent accidental usage of a system installed libpython of the same version 77 | rm python; \ 78 | make -j "$nproc" \ 79 | "EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \ 80 | "LDFLAGS=${LDFLAGS:--Wl},-rpath='\$\$ORIGIN/../lib'" \ 81 | python \ 82 | ; \ 83 | make install; \ 84 | \ 85 | # enable GDB to load debugging data: https://github.com/docker-library/python/pull/701 86 | bin="$(readlink -ve /usr/local/bin/python3)"; \ 87 | dir="$(dirname "$bin")"; \ 88 | mkdir -p "/usr/share/gdb/auto-load/$dir"; \ 89 | cp -vL Tools/gdb/libpython.py "/usr/share/gdb/auto-load/$bin-gdb.py"; \ 90 | \ 91 | cd /; \ 92 | rm -rf /usr/src/python; \ 93 | \ 94 | find /usr/local -depth \ 95 | \( \ 96 | \( -type d -a \( -name test -o -name tests -o -name idle_test \) \) \ 97 | -o \( -type f -a \( -name '*.pyc' -o -name '*.pyo' -o -name 'libpython*.a' \) \) \ 98 | \) -exec rm -rf '{}' + \ 99 | ; \ 100 | \ 101 | ldconfig; \ 102 | \ 103 | apt-mark auto '.*' > /dev/null; \ 104 | apt-mark manual $savedAptMark; \ 105 | find /usr/local -type f -executable -not \( -name '*tkinter*' \) -exec ldd '{}' ';' \ 106 | | awk '/=>/ { so = $(NF-1); if (index(so, "/usr/local/") == 1) { next }; gsub("^/(usr/)?", "", so); printf "*%s\n", so }' \ 107 | | sort -u \ 108 | | xargs -rt dpkg-query --search \ 109 | # https://manpages.debian.org/bookworm/dpkg/dpkg-query.1.en.html#S (we ignore diversions and it'll be really unusual for more than one package to provide any given .so file) 110 | | awk 'sub(":$", "", $1) { print $1 }' \ 111 | | sort -u \ 112 | | xargs -r apt-mark manual \ 113 | ; \ 114 | apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ 115 | apt-get dist-clean; \ 116 | \ 117 | export PYTHONDONTWRITEBYTECODE=1; \ 118 | python3 --version; \ 119 | pip3 --version 120 | 121 | # make some useful symlinks that are expected to exist ("/usr/local/bin/python" and friends) 122 | RUN set -eux; \ 123 | for src in idle3 pip3 pydoc3 python3 python3-config; do \ 124 | dst="$(echo "$src" | tr -d 3)"; \ 125 | [ -s "/usr/local/bin/$src" ]; \ 126 | [ ! -e "/usr/local/bin/$dst" ]; \ 127 | ln -svT "$src" "/usr/local/bin/$dst"; \ 128 | done 129 | 130 | CMD ["python3"] 131 | -------------------------------------------------------------------------------- /3.14/bookworm/Dockerfile: -------------------------------------------------------------------------------- 1 | # 2 | # NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh" 3 | # 4 | # PLEASE DO NOT EDIT IT DIRECTLY. 5 | # 6 | 7 | FROM buildpack-deps:bookworm 8 | 9 | # ensure local python is preferred over distribution python 10 | ENV PATH /usr/local/bin:$PATH 11 | 12 | # runtime dependencies 13 | RUN set -eux; \ 14 | apt-get update; \ 15 | apt-get install -y --no-install-recommends \ 16 | libbluetooth-dev \ 17 | tk-dev \ 18 | uuid-dev \ 19 | ; \ 20 | rm -rf /var/lib/apt/lists/* 21 | 22 | ENV PYTHON_VERSION 3.14.2 23 | ENV PYTHON_SHA256 ce543ab854bc256b61b71e9b27f831ffd1bfd60a479d639f8be7f9757cf573e9 24 | 25 | RUN set -eux; \ 26 | \ 27 | savedAptMark="$(apt-mark showmanual)"; \ 28 | apt-get update; \ 29 | apt-get install -y --no-install-recommends \ 30 | libzstd-dev \ 31 | ; \ 32 | \ 33 | wget -O python.tar.xz "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz"; \ 34 | echo "$PYTHON_SHA256 *python.tar.xz" | sha256sum -c -; \ 35 | mkdir -p /usr/src/python; \ 36 | tar --extract --directory /usr/src/python --strip-components=1 --file python.tar.xz; \ 37 | rm python.tar.xz; \ 38 | \ 39 | cd /usr/src/python; \ 40 | gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \ 41 | ./configure \ 42 | --build="$gnuArch" \ 43 | --enable-loadable-sqlite-extensions \ 44 | --enable-optimizations \ 45 | --enable-option-checking=fatal \ 46 | --enable-shared \ 47 | $(test "${gnuArch%%-*}" != 'riscv64' && echo '--with-lto') \ 48 | --with-ensurepip \ 49 | ; \ 50 | nproc="$(nproc)"; \ 51 | EXTRA_CFLAGS="$(dpkg-buildflags --get CFLAGS)"; \ 52 | LDFLAGS="$(dpkg-buildflags --get LDFLAGS)"; \ 53 | arch="$(dpkg --print-architecture)"; arch="${arch##*-}"; \ 54 | # https://docs.python.org/3.12/howto/perf_profiling.html 55 | # https://github.com/docker-library/python/pull/1000#issuecomment-2597021615 56 | case "$arch" in \ 57 | amd64|arm64) \ 58 | # only add "-mno-omit-leaf" on arches that support it 59 | # https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/x86-Options.html#index-momit-leaf-frame-pointer-2 60 | # https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/AArch64-Options.html#index-momit-leaf-frame-pointer 61 | EXTRA_CFLAGS="${EXTRA_CFLAGS:-} -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer"; \ 62 | ;; \ 63 | i386) \ 64 | # don't enable frame-pointers on 32bit x86 due to performance drop. 65 | ;; \ 66 | *) \ 67 | # other arches don't support "-mno-omit-leaf" 68 | EXTRA_CFLAGS="${EXTRA_CFLAGS:-} -fno-omit-frame-pointer"; \ 69 | ;; \ 70 | esac; \ 71 | make -j "$nproc" \ 72 | "EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \ 73 | "LDFLAGS=${LDFLAGS:-}" \ 74 | ; \ 75 | # https://github.com/docker-library/python/issues/784 76 | # prevent accidental usage of a system installed libpython of the same version 77 | rm python; \ 78 | make -j "$nproc" \ 79 | "EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \ 80 | "LDFLAGS=${LDFLAGS:--Wl},-rpath='\$\$ORIGIN/../lib'" \ 81 | python \ 82 | ; \ 83 | make install; \ 84 | \ 85 | # enable GDB to load debugging data: https://github.com/docker-library/python/pull/701 86 | bin="$(readlink -ve /usr/local/bin/python3)"; \ 87 | dir="$(dirname "$bin")"; \ 88 | mkdir -p "/usr/share/gdb/auto-load/$dir"; \ 89 | cp -vL Tools/gdb/libpython.py "/usr/share/gdb/auto-load/$bin-gdb.py"; \ 90 | \ 91 | cd /; \ 92 | rm -rf /usr/src/python; \ 93 | \ 94 | find /usr/local -depth \ 95 | \( \ 96 | \( -type d -a \( -name test -o -name tests -o -name idle_test \) \) \ 97 | -o \( -type f -a \( -name '*.pyc' -o -name '*.pyo' -o -name 'libpython*.a' \) \) \ 98 | \) -exec rm -rf '{}' + \ 99 | ; \ 100 | \ 101 | ldconfig; \ 102 | \ 103 | apt-mark auto '.*' > /dev/null; \ 104 | apt-mark manual $savedAptMark; \ 105 | find /usr/local -type f -executable -not \( -name '*tkinter*' \) -exec ldd '{}' ';' \ 106 | | awk '/=>/ { so = $(NF-1); if (index(so, "/usr/local/") == 1) { next }; gsub("^/(usr/)?", "", so); printf "*%s\n", so }' \ 107 | | sort -u \ 108 | | xargs -rt dpkg-query --search \ 109 | # https://manpages.debian.org/bookworm/dpkg/dpkg-query.1.en.html#S (we ignore diversions and it'll be really unusual for more than one package to provide any given .so file) 110 | | awk 'sub(":$", "", $1) { print $1 }' \ 111 | | sort -u \ 112 | | xargs -r apt-mark manual \ 113 | ; \ 114 | apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ 115 | rm -rf /var/lib/apt/lists/*; \ 116 | \ 117 | export PYTHONDONTWRITEBYTECODE=1; \ 118 | python3 --version; \ 119 | pip3 --version 120 | 121 | # make some useful symlinks that are expected to exist ("/usr/local/bin/python" and friends) 122 | RUN set -eux; \ 123 | for src in idle3 pip3 pydoc3 python3 python3-config; do \ 124 | dst="$(echo "$src" | tr -d 3)"; \ 125 | [ -s "/usr/local/bin/$src" ]; \ 126 | [ ! -e "/usr/local/bin/$dst" ]; \ 127 | ln -svT "$src" "/usr/local/bin/$dst"; \ 128 | done 129 | 130 | CMD ["python3"] 131 | -------------------------------------------------------------------------------- /3.15-rc/bookworm/Dockerfile: -------------------------------------------------------------------------------- 1 | # 2 | # NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh" 3 | # 4 | # PLEASE DO NOT EDIT IT DIRECTLY. 5 | # 6 | 7 | FROM buildpack-deps:bookworm 8 | 9 | # ensure local python is preferred over distribution python 10 | ENV PATH /usr/local/bin:$PATH 11 | 12 | # runtime dependencies 13 | RUN set -eux; \ 14 | apt-get update; \ 15 | apt-get install -y --no-install-recommends \ 16 | libbluetooth-dev \ 17 | tk-dev \ 18 | uuid-dev \ 19 | ; \ 20 | rm -rf /var/lib/apt/lists/* 21 | 22 | ENV PYTHON_VERSION 3.15.0a3 23 | ENV PYTHON_SHA256 6ab02cdac24505779877bb1d9189432d67e90ddf2a9b8b7b373ead54ac07b607 24 | 25 | RUN set -eux; \ 26 | \ 27 | savedAptMark="$(apt-mark showmanual)"; \ 28 | apt-get update; \ 29 | apt-get install -y --no-install-recommends \ 30 | libzstd-dev \ 31 | ; \ 32 | \ 33 | wget -O python.tar.xz "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz"; \ 34 | echo "$PYTHON_SHA256 *python.tar.xz" | sha256sum -c -; \ 35 | mkdir -p /usr/src/python; \ 36 | tar --extract --directory /usr/src/python --strip-components=1 --file python.tar.xz; \ 37 | rm python.tar.xz; \ 38 | \ 39 | cd /usr/src/python; \ 40 | gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \ 41 | ./configure \ 42 | --build="$gnuArch" \ 43 | --enable-loadable-sqlite-extensions \ 44 | --enable-optimizations \ 45 | --enable-option-checking=fatal \ 46 | --enable-shared \ 47 | $(test "${gnuArch%%-*}" != 'riscv64' && echo '--with-lto') \ 48 | --with-ensurepip \ 49 | ; \ 50 | nproc="$(nproc)"; \ 51 | EXTRA_CFLAGS="$(dpkg-buildflags --get CFLAGS)"; \ 52 | LDFLAGS="$(dpkg-buildflags --get LDFLAGS)"; \ 53 | arch="$(dpkg --print-architecture)"; arch="${arch##*-}"; \ 54 | # https://docs.python.org/3.12/howto/perf_profiling.html 55 | # https://github.com/docker-library/python/pull/1000#issuecomment-2597021615 56 | case "$arch" in \ 57 | amd64|arm64) \ 58 | # only add "-mno-omit-leaf" on arches that support it 59 | # https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/x86-Options.html#index-momit-leaf-frame-pointer-2 60 | # https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/AArch64-Options.html#index-momit-leaf-frame-pointer 61 | EXTRA_CFLAGS="${EXTRA_CFLAGS:-} -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer"; \ 62 | ;; \ 63 | i386) \ 64 | # don't enable frame-pointers on 32bit x86 due to performance drop. 65 | ;; \ 66 | *) \ 67 | # other arches don't support "-mno-omit-leaf" 68 | EXTRA_CFLAGS="${EXTRA_CFLAGS:-} -fno-omit-frame-pointer"; \ 69 | ;; \ 70 | esac; \ 71 | make -j "$nproc" \ 72 | "EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \ 73 | "LDFLAGS=${LDFLAGS:-}" \ 74 | ; \ 75 | # https://github.com/docker-library/python/issues/784 76 | # prevent accidental usage of a system installed libpython of the same version 77 | rm python; \ 78 | make -j "$nproc" \ 79 | "EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \ 80 | "LDFLAGS=${LDFLAGS:--Wl},-rpath='\$\$ORIGIN/../lib'" \ 81 | python \ 82 | ; \ 83 | make install; \ 84 | \ 85 | # enable GDB to load debugging data: https://github.com/docker-library/python/pull/701 86 | bin="$(readlink -ve /usr/local/bin/python3)"; \ 87 | dir="$(dirname "$bin")"; \ 88 | mkdir -p "/usr/share/gdb/auto-load/$dir"; \ 89 | cp -vL Tools/gdb/libpython.py "/usr/share/gdb/auto-load/$bin-gdb.py"; \ 90 | \ 91 | cd /; \ 92 | rm -rf /usr/src/python; \ 93 | \ 94 | find /usr/local -depth \ 95 | \( \ 96 | \( -type d -a \( -name test -o -name tests -o -name idle_test \) \) \ 97 | -o \( -type f -a \( -name '*.pyc' -o -name '*.pyo' -o -name 'libpython*.a' \) \) \ 98 | \) -exec rm -rf '{}' + \ 99 | ; \ 100 | \ 101 | ldconfig; \ 102 | \ 103 | apt-mark auto '.*' > /dev/null; \ 104 | apt-mark manual $savedAptMark; \ 105 | find /usr/local -type f -executable -not \( -name '*tkinter*' \) -exec ldd '{}' ';' \ 106 | | awk '/=>/ { so = $(NF-1); if (index(so, "/usr/local/") == 1) { next }; gsub("^/(usr/)?", "", so); printf "*%s\n", so }' \ 107 | | sort -u \ 108 | | xargs -rt dpkg-query --search \ 109 | # https://manpages.debian.org/bookworm/dpkg/dpkg-query.1.en.html#S (we ignore diversions and it'll be really unusual for more than one package to provide any given .so file) 110 | | awk 'sub(":$", "", $1) { print $1 }' \ 111 | | sort -u \ 112 | | xargs -r apt-mark manual \ 113 | ; \ 114 | apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ 115 | rm -rf /var/lib/apt/lists/*; \ 116 | \ 117 | export PYTHONDONTWRITEBYTECODE=1; \ 118 | python3 --version; \ 119 | pip3 --version 120 | 121 | # make some useful symlinks that are expected to exist ("/usr/local/bin/python" and friends) 122 | RUN set -eux; \ 123 | for src in idle3 pip3 pydoc3 python3 python3-config; do \ 124 | dst="$(echo "$src" | tr -d 3)"; \ 125 | [ -s "/usr/local/bin/$src" ]; \ 126 | [ ! -e "/usr/local/bin/$dst" ]; \ 127 | ln -svT "$src" "/usr/local/bin/$dst"; \ 128 | done 129 | 130 | CMD ["python3"] 131 | -------------------------------------------------------------------------------- /3.10/slim-trixie/Dockerfile: -------------------------------------------------------------------------------- 1 | # 2 | # NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh" 3 | # 4 | # PLEASE DO NOT EDIT IT DIRECTLY. 5 | # 6 | 7 | FROM debian:trixie-slim 8 | 9 | # ensure local python is preferred over distribution python 10 | ENV PATH /usr/local/bin:$PATH 11 | 12 | # cannot remove LANG even though https://bugs.python.org/issue19846 is fixed 13 | # last attempted removal of LANG broke many users: 14 | # https://github.com/docker-library/python/pull/570 15 | ENV LANG C.UTF-8 16 | 17 | # runtime dependencies 18 | RUN set -eux; \ 19 | apt-get update; \ 20 | apt-get install -y --no-install-recommends \ 21 | ca-certificates \ 22 | netbase \ 23 | tzdata \ 24 | ; \ 25 | apt-get dist-clean 26 | 27 | ENV GPG_KEY A035C8C19219BA821ECEA86B64E628F8D684696D 28 | ENV PYTHON_VERSION 3.10.19 29 | ENV PYTHON_SHA256 c8f4a596572201d81dd7df91f70e177e19a70f1d489968b54b5fbbf29a97c076 30 | 31 | RUN set -eux; \ 32 | \ 33 | savedAptMark="$(apt-mark showmanual)"; \ 34 | apt-get update; \ 35 | apt-get install -y --no-install-recommends \ 36 | dpkg-dev \ 37 | gcc \ 38 | gnupg \ 39 | libbluetooth-dev \ 40 | libbz2-dev \ 41 | libc6-dev \ 42 | libdb-dev \ 43 | libffi-dev \ 44 | libgdbm-dev \ 45 | liblzma-dev \ 46 | libncursesw5-dev \ 47 | libreadline-dev \ 48 | libsqlite3-dev \ 49 | libssl-dev \ 50 | make \ 51 | tk-dev \ 52 | uuid-dev \ 53 | wget \ 54 | xz-utils \ 55 | zlib1g-dev \ 56 | ; \ 57 | \ 58 | wget -O python.tar.xz "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz"; \ 59 | echo "$PYTHON_SHA256 *python.tar.xz" | sha256sum -c -; \ 60 | wget -O python.tar.xz.asc "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz.asc"; \ 61 | GNUPGHOME="$(mktemp -d)"; export GNUPGHOME; \ 62 | gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$GPG_KEY"; \ 63 | gpg --batch --verify python.tar.xz.asc python.tar.xz; \ 64 | gpgconf --kill all; \ 65 | rm -rf "$GNUPGHOME" python.tar.xz.asc; \ 66 | mkdir -p /usr/src/python; \ 67 | tar --extract --directory /usr/src/python --strip-components=1 --file python.tar.xz; \ 68 | rm python.tar.xz; \ 69 | \ 70 | cd /usr/src/python; \ 71 | gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \ 72 | ./configure \ 73 | --build="$gnuArch" \ 74 | --enable-loadable-sqlite-extensions \ 75 | --enable-optimizations \ 76 | --enable-option-checking=fatal \ 77 | --enable-shared \ 78 | $(test "${gnuArch%%-*}" != 'riscv64' && echo '--with-lto') \ 79 | --with-ensurepip \ 80 | ; \ 81 | nproc="$(nproc)"; \ 82 | EXTRA_CFLAGS="$(dpkg-buildflags --get CFLAGS)"; \ 83 | LDFLAGS="$(dpkg-buildflags --get LDFLAGS)"; \ 84 | LDFLAGS="${LDFLAGS:--Wl},--strip-all"; \ 85 | make -j "$nproc" \ 86 | "EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \ 87 | "LDFLAGS=${LDFLAGS:-}" \ 88 | ; \ 89 | # https://github.com/docker-library/python/issues/784 90 | # prevent accidental usage of a system installed libpython of the same version 91 | rm python; \ 92 | make -j "$nproc" \ 93 | "EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \ 94 | "LDFLAGS=${LDFLAGS:--Wl},-rpath='\$\$ORIGIN/../lib'" \ 95 | python \ 96 | ; \ 97 | make install; \ 98 | \ 99 | cd /; \ 100 | rm -rf /usr/src/python; \ 101 | \ 102 | find /usr/local -depth \ 103 | \( \ 104 | \( -type d -a \( -name test -o -name tests -o -name idle_test \) \) \ 105 | -o \( -type f -a \( -name '*.pyc' -o -name '*.pyo' -o -name 'libpython*.a' \) \) \ 106 | \) -exec rm -rf '{}' + \ 107 | ; \ 108 | \ 109 | ldconfig; \ 110 | \ 111 | apt-mark auto '.*' > /dev/null; \ 112 | apt-mark manual $savedAptMark; \ 113 | find /usr/local -type f -executable -not \( -name '*tkinter*' \) -exec ldd '{}' ';' \ 114 | | awk '/=>/ { so = $(NF-1); if (index(so, "/usr/local/") == 1) { next }; gsub("^/(usr/)?", "", so); printf "*%s\n", so }' \ 115 | | sort -u \ 116 | | xargs -rt dpkg-query --search \ 117 | # https://manpages.debian.org/bookworm/dpkg/dpkg-query.1.en.html#S (we ignore diversions and it'll be really unusual for more than one package to provide any given .so file) 118 | | awk 'sub(":$", "", $1) { print $1 }' \ 119 | | sort -u \ 120 | | xargs -r apt-mark manual \ 121 | ; \ 122 | apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ 123 | apt-get dist-clean; \ 124 | \ 125 | export PYTHONDONTWRITEBYTECODE=1; \ 126 | python3 --version; \ 127 | \ 128 | pip3 install \ 129 | --disable-pip-version-check \ 130 | --no-cache-dir \ 131 | --no-compile \ 132 | 'setuptools==79.0.1' \ 133 | # https://github.com/docker-library/python/issues/1023 134 | 'wheel<0.46' \ 135 | ; \ 136 | pip3 --version 137 | 138 | # make some useful symlinks that are expected to exist ("/usr/local/bin/python" and friends) 139 | RUN set -eux; \ 140 | for src in idle3 pip3 pydoc3 python3 python3-config; do \ 141 | dst="$(echo "$src" | tr -d 3)"; \ 142 | [ -s "/usr/local/bin/$src" ]; \ 143 | [ ! -e "/usr/local/bin/$dst" ]; \ 144 | ln -svT "$src" "/usr/local/bin/$dst"; \ 145 | done 146 | 147 | CMD ["python3"] 148 | -------------------------------------------------------------------------------- /3.11/slim-trixie/Dockerfile: -------------------------------------------------------------------------------- 1 | # 2 | # NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh" 3 | # 4 | # PLEASE DO NOT EDIT IT DIRECTLY. 5 | # 6 | 7 | FROM debian:trixie-slim 8 | 9 | # ensure local python is preferred over distribution python 10 | ENV PATH /usr/local/bin:$PATH 11 | 12 | # cannot remove LANG even though https://bugs.python.org/issue19846 is fixed 13 | # last attempted removal of LANG broke many users: 14 | # https://github.com/docker-library/python/pull/570 15 | ENV LANG C.UTF-8 16 | 17 | # runtime dependencies 18 | RUN set -eux; \ 19 | apt-get update; \ 20 | apt-get install -y --no-install-recommends \ 21 | ca-certificates \ 22 | netbase \ 23 | tzdata \ 24 | ; \ 25 | apt-get dist-clean 26 | 27 | ENV GPG_KEY A035C8C19219BA821ECEA86B64E628F8D684696D 28 | ENV PYTHON_VERSION 3.11.14 29 | ENV PYTHON_SHA256 8d3ed8ec5c88c1c95f5e558612a725450d2452813ddad5e58fdb1a53b1209b78 30 | 31 | RUN set -eux; \ 32 | \ 33 | savedAptMark="$(apt-mark showmanual)"; \ 34 | apt-get update; \ 35 | apt-get install -y --no-install-recommends \ 36 | dpkg-dev \ 37 | gcc \ 38 | gnupg \ 39 | libbluetooth-dev \ 40 | libbz2-dev \ 41 | libc6-dev \ 42 | libdb-dev \ 43 | libffi-dev \ 44 | libgdbm-dev \ 45 | liblzma-dev \ 46 | libncursesw5-dev \ 47 | libreadline-dev \ 48 | libsqlite3-dev \ 49 | libssl-dev \ 50 | make \ 51 | tk-dev \ 52 | uuid-dev \ 53 | wget \ 54 | xz-utils \ 55 | zlib1g-dev \ 56 | ; \ 57 | \ 58 | wget -O python.tar.xz "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz"; \ 59 | echo "$PYTHON_SHA256 *python.tar.xz" | sha256sum -c -; \ 60 | wget -O python.tar.xz.asc "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz.asc"; \ 61 | GNUPGHOME="$(mktemp -d)"; export GNUPGHOME; \ 62 | gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$GPG_KEY"; \ 63 | gpg --batch --verify python.tar.xz.asc python.tar.xz; \ 64 | gpgconf --kill all; \ 65 | rm -rf "$GNUPGHOME" python.tar.xz.asc; \ 66 | mkdir -p /usr/src/python; \ 67 | tar --extract --directory /usr/src/python --strip-components=1 --file python.tar.xz; \ 68 | rm python.tar.xz; \ 69 | \ 70 | cd /usr/src/python; \ 71 | gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \ 72 | ./configure \ 73 | --build="$gnuArch" \ 74 | --enable-loadable-sqlite-extensions \ 75 | --enable-optimizations \ 76 | --enable-option-checking=fatal \ 77 | --enable-shared \ 78 | $(test "${gnuArch%%-*}" != 'riscv64' && echo '--with-lto') \ 79 | --with-ensurepip \ 80 | ; \ 81 | nproc="$(nproc)"; \ 82 | EXTRA_CFLAGS="$(dpkg-buildflags --get CFLAGS)"; \ 83 | LDFLAGS="$(dpkg-buildflags --get LDFLAGS)"; \ 84 | LDFLAGS="${LDFLAGS:--Wl},--strip-all"; \ 85 | make -j "$nproc" \ 86 | "EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \ 87 | "LDFLAGS=${LDFLAGS:-}" \ 88 | ; \ 89 | # https://github.com/docker-library/python/issues/784 90 | # prevent accidental usage of a system installed libpython of the same version 91 | rm python; \ 92 | make -j "$nproc" \ 93 | "EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \ 94 | "LDFLAGS=${LDFLAGS:--Wl},-rpath='\$\$ORIGIN/../lib'" \ 95 | python \ 96 | ; \ 97 | make install; \ 98 | \ 99 | cd /; \ 100 | rm -rf /usr/src/python; \ 101 | \ 102 | find /usr/local -depth \ 103 | \( \ 104 | \( -type d -a \( -name test -o -name tests -o -name idle_test \) \) \ 105 | -o \( -type f -a \( -name '*.pyc' -o -name '*.pyo' -o -name 'libpython*.a' \) \) \ 106 | \) -exec rm -rf '{}' + \ 107 | ; \ 108 | \ 109 | ldconfig; \ 110 | \ 111 | apt-mark auto '.*' > /dev/null; \ 112 | apt-mark manual $savedAptMark; \ 113 | find /usr/local -type f -executable -not \( -name '*tkinter*' \) -exec ldd '{}' ';' \ 114 | | awk '/=>/ { so = $(NF-1); if (index(so, "/usr/local/") == 1) { next }; gsub("^/(usr/)?", "", so); printf "*%s\n", so }' \ 115 | | sort -u \ 116 | | xargs -rt dpkg-query --search \ 117 | # https://manpages.debian.org/bookworm/dpkg/dpkg-query.1.en.html#S (we ignore diversions and it'll be really unusual for more than one package to provide any given .so file) 118 | | awk 'sub(":$", "", $1) { print $1 }' \ 119 | | sort -u \ 120 | | xargs -r apt-mark manual \ 121 | ; \ 122 | apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ 123 | apt-get dist-clean; \ 124 | \ 125 | export PYTHONDONTWRITEBYTECODE=1; \ 126 | python3 --version; \ 127 | \ 128 | pip3 install \ 129 | --disable-pip-version-check \ 130 | --no-cache-dir \ 131 | --no-compile \ 132 | 'setuptools==79.0.1' \ 133 | # https://github.com/docker-library/python/issues/1023 134 | 'wheel<0.46' \ 135 | ; \ 136 | pip3 --version 137 | 138 | # make some useful symlinks that are expected to exist ("/usr/local/bin/python" and friends) 139 | RUN set -eux; \ 140 | for src in idle3 pip3 pydoc3 python3 python3-config; do \ 141 | dst="$(echo "$src" | tr -d 3)"; \ 142 | [ -s "/usr/local/bin/$src" ]; \ 143 | [ ! -e "/usr/local/bin/$dst" ]; \ 144 | ln -svT "$src" "/usr/local/bin/$dst"; \ 145 | done 146 | 147 | CMD ["python3"] 148 | -------------------------------------------------------------------------------- /3.10/slim-bookworm/Dockerfile: -------------------------------------------------------------------------------- 1 | # 2 | # NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh" 3 | # 4 | # PLEASE DO NOT EDIT IT DIRECTLY. 5 | # 6 | 7 | FROM debian:bookworm-slim 8 | 9 | # ensure local python is preferred over distribution python 10 | ENV PATH /usr/local/bin:$PATH 11 | 12 | # cannot remove LANG even though https://bugs.python.org/issue19846 is fixed 13 | # last attempted removal of LANG broke many users: 14 | # https://github.com/docker-library/python/pull/570 15 | ENV LANG C.UTF-8 16 | 17 | # runtime dependencies 18 | RUN set -eux; \ 19 | apt-get update; \ 20 | apt-get install -y --no-install-recommends \ 21 | ca-certificates \ 22 | netbase \ 23 | tzdata \ 24 | ; \ 25 | rm -rf /var/lib/apt/lists/* 26 | 27 | ENV GPG_KEY A035C8C19219BA821ECEA86B64E628F8D684696D 28 | ENV PYTHON_VERSION 3.10.19 29 | ENV PYTHON_SHA256 c8f4a596572201d81dd7df91f70e177e19a70f1d489968b54b5fbbf29a97c076 30 | 31 | RUN set -eux; \ 32 | \ 33 | savedAptMark="$(apt-mark showmanual)"; \ 34 | apt-get update; \ 35 | apt-get install -y --no-install-recommends \ 36 | dpkg-dev \ 37 | gcc \ 38 | gnupg \ 39 | libbluetooth-dev \ 40 | libbz2-dev \ 41 | libc6-dev \ 42 | libdb-dev \ 43 | libffi-dev \ 44 | libgdbm-dev \ 45 | liblzma-dev \ 46 | libncursesw5-dev \ 47 | libreadline-dev \ 48 | libsqlite3-dev \ 49 | libssl-dev \ 50 | make \ 51 | tk-dev \ 52 | uuid-dev \ 53 | wget \ 54 | xz-utils \ 55 | zlib1g-dev \ 56 | ; \ 57 | \ 58 | wget -O python.tar.xz "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz"; \ 59 | echo "$PYTHON_SHA256 *python.tar.xz" | sha256sum -c -; \ 60 | wget -O python.tar.xz.asc "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz.asc"; \ 61 | GNUPGHOME="$(mktemp -d)"; export GNUPGHOME; \ 62 | gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$GPG_KEY"; \ 63 | gpg --batch --verify python.tar.xz.asc python.tar.xz; \ 64 | gpgconf --kill all; \ 65 | rm -rf "$GNUPGHOME" python.tar.xz.asc; \ 66 | mkdir -p /usr/src/python; \ 67 | tar --extract --directory /usr/src/python --strip-components=1 --file python.tar.xz; \ 68 | rm python.tar.xz; \ 69 | \ 70 | cd /usr/src/python; \ 71 | gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \ 72 | ./configure \ 73 | --build="$gnuArch" \ 74 | --enable-loadable-sqlite-extensions \ 75 | --enable-optimizations \ 76 | --enable-option-checking=fatal \ 77 | --enable-shared \ 78 | $(test "${gnuArch%%-*}" != 'riscv64' && echo '--with-lto') \ 79 | --with-ensurepip \ 80 | ; \ 81 | nproc="$(nproc)"; \ 82 | EXTRA_CFLAGS="$(dpkg-buildflags --get CFLAGS)"; \ 83 | LDFLAGS="$(dpkg-buildflags --get LDFLAGS)"; \ 84 | LDFLAGS="${LDFLAGS:--Wl},--strip-all"; \ 85 | make -j "$nproc" \ 86 | "EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \ 87 | "LDFLAGS=${LDFLAGS:-}" \ 88 | ; \ 89 | # https://github.com/docker-library/python/issues/784 90 | # prevent accidental usage of a system installed libpython of the same version 91 | rm python; \ 92 | make -j "$nproc" \ 93 | "EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \ 94 | "LDFLAGS=${LDFLAGS:--Wl},-rpath='\$\$ORIGIN/../lib'" \ 95 | python \ 96 | ; \ 97 | make install; \ 98 | \ 99 | cd /; \ 100 | rm -rf /usr/src/python; \ 101 | \ 102 | find /usr/local -depth \ 103 | \( \ 104 | \( -type d -a \( -name test -o -name tests -o -name idle_test \) \) \ 105 | -o \( -type f -a \( -name '*.pyc' -o -name '*.pyo' -o -name 'libpython*.a' \) \) \ 106 | \) -exec rm -rf '{}' + \ 107 | ; \ 108 | \ 109 | ldconfig; \ 110 | \ 111 | apt-mark auto '.*' > /dev/null; \ 112 | apt-mark manual $savedAptMark; \ 113 | find /usr/local -type f -executable -not \( -name '*tkinter*' \) -exec ldd '{}' ';' \ 114 | | awk '/=>/ { so = $(NF-1); if (index(so, "/usr/local/") == 1) { next }; gsub("^/(usr/)?", "", so); printf "*%s\n", so }' \ 115 | | sort -u \ 116 | | xargs -rt dpkg-query --search \ 117 | # https://manpages.debian.org/bookworm/dpkg/dpkg-query.1.en.html#S (we ignore diversions and it'll be really unusual for more than one package to provide any given .so file) 118 | | awk 'sub(":$", "", $1) { print $1 }' \ 119 | | sort -u \ 120 | | xargs -r apt-mark manual \ 121 | ; \ 122 | apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ 123 | rm -rf /var/lib/apt/lists/*; \ 124 | \ 125 | export PYTHONDONTWRITEBYTECODE=1; \ 126 | python3 --version; \ 127 | \ 128 | pip3 install \ 129 | --disable-pip-version-check \ 130 | --no-cache-dir \ 131 | --no-compile \ 132 | 'setuptools==79.0.1' \ 133 | # https://github.com/docker-library/python/issues/1023 134 | 'wheel<0.46' \ 135 | ; \ 136 | pip3 --version 137 | 138 | # make some useful symlinks that are expected to exist ("/usr/local/bin/python" and friends) 139 | RUN set -eux; \ 140 | for src in idle3 pip3 pydoc3 python3 python3-config; do \ 141 | dst="$(echo "$src" | tr -d 3)"; \ 142 | [ -s "/usr/local/bin/$src" ]; \ 143 | [ ! -e "/usr/local/bin/$dst" ]; \ 144 | ln -svT "$src" "/usr/local/bin/$dst"; \ 145 | done 146 | 147 | CMD ["python3"] 148 | -------------------------------------------------------------------------------- /3.11/slim-bookworm/Dockerfile: -------------------------------------------------------------------------------- 1 | # 2 | # NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh" 3 | # 4 | # PLEASE DO NOT EDIT IT DIRECTLY. 5 | # 6 | 7 | FROM debian:bookworm-slim 8 | 9 | # ensure local python is preferred over distribution python 10 | ENV PATH /usr/local/bin:$PATH 11 | 12 | # cannot remove LANG even though https://bugs.python.org/issue19846 is fixed 13 | # last attempted removal of LANG broke many users: 14 | # https://github.com/docker-library/python/pull/570 15 | ENV LANG C.UTF-8 16 | 17 | # runtime dependencies 18 | RUN set -eux; \ 19 | apt-get update; \ 20 | apt-get install -y --no-install-recommends \ 21 | ca-certificates \ 22 | netbase \ 23 | tzdata \ 24 | ; \ 25 | rm -rf /var/lib/apt/lists/* 26 | 27 | ENV GPG_KEY A035C8C19219BA821ECEA86B64E628F8D684696D 28 | ENV PYTHON_VERSION 3.11.14 29 | ENV PYTHON_SHA256 8d3ed8ec5c88c1c95f5e558612a725450d2452813ddad5e58fdb1a53b1209b78 30 | 31 | RUN set -eux; \ 32 | \ 33 | savedAptMark="$(apt-mark showmanual)"; \ 34 | apt-get update; \ 35 | apt-get install -y --no-install-recommends \ 36 | dpkg-dev \ 37 | gcc \ 38 | gnupg \ 39 | libbluetooth-dev \ 40 | libbz2-dev \ 41 | libc6-dev \ 42 | libdb-dev \ 43 | libffi-dev \ 44 | libgdbm-dev \ 45 | liblzma-dev \ 46 | libncursesw5-dev \ 47 | libreadline-dev \ 48 | libsqlite3-dev \ 49 | libssl-dev \ 50 | make \ 51 | tk-dev \ 52 | uuid-dev \ 53 | wget \ 54 | xz-utils \ 55 | zlib1g-dev \ 56 | ; \ 57 | \ 58 | wget -O python.tar.xz "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz"; \ 59 | echo "$PYTHON_SHA256 *python.tar.xz" | sha256sum -c -; \ 60 | wget -O python.tar.xz.asc "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz.asc"; \ 61 | GNUPGHOME="$(mktemp -d)"; export GNUPGHOME; \ 62 | gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$GPG_KEY"; \ 63 | gpg --batch --verify python.tar.xz.asc python.tar.xz; \ 64 | gpgconf --kill all; \ 65 | rm -rf "$GNUPGHOME" python.tar.xz.asc; \ 66 | mkdir -p /usr/src/python; \ 67 | tar --extract --directory /usr/src/python --strip-components=1 --file python.tar.xz; \ 68 | rm python.tar.xz; \ 69 | \ 70 | cd /usr/src/python; \ 71 | gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \ 72 | ./configure \ 73 | --build="$gnuArch" \ 74 | --enable-loadable-sqlite-extensions \ 75 | --enable-optimizations \ 76 | --enable-option-checking=fatal \ 77 | --enable-shared \ 78 | $(test "${gnuArch%%-*}" != 'riscv64' && echo '--with-lto') \ 79 | --with-ensurepip \ 80 | ; \ 81 | nproc="$(nproc)"; \ 82 | EXTRA_CFLAGS="$(dpkg-buildflags --get CFLAGS)"; \ 83 | LDFLAGS="$(dpkg-buildflags --get LDFLAGS)"; \ 84 | LDFLAGS="${LDFLAGS:--Wl},--strip-all"; \ 85 | make -j "$nproc" \ 86 | "EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \ 87 | "LDFLAGS=${LDFLAGS:-}" \ 88 | ; \ 89 | # https://github.com/docker-library/python/issues/784 90 | # prevent accidental usage of a system installed libpython of the same version 91 | rm python; \ 92 | make -j "$nproc" \ 93 | "EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \ 94 | "LDFLAGS=${LDFLAGS:--Wl},-rpath='\$\$ORIGIN/../lib'" \ 95 | python \ 96 | ; \ 97 | make install; \ 98 | \ 99 | cd /; \ 100 | rm -rf /usr/src/python; \ 101 | \ 102 | find /usr/local -depth \ 103 | \( \ 104 | \( -type d -a \( -name test -o -name tests -o -name idle_test \) \) \ 105 | -o \( -type f -a \( -name '*.pyc' -o -name '*.pyo' -o -name 'libpython*.a' \) \) \ 106 | \) -exec rm -rf '{}' + \ 107 | ; \ 108 | \ 109 | ldconfig; \ 110 | \ 111 | apt-mark auto '.*' > /dev/null; \ 112 | apt-mark manual $savedAptMark; \ 113 | find /usr/local -type f -executable -not \( -name '*tkinter*' \) -exec ldd '{}' ';' \ 114 | | awk '/=>/ { so = $(NF-1); if (index(so, "/usr/local/") == 1) { next }; gsub("^/(usr/)?", "", so); printf "*%s\n", so }' \ 115 | | sort -u \ 116 | | xargs -rt dpkg-query --search \ 117 | # https://manpages.debian.org/bookworm/dpkg/dpkg-query.1.en.html#S (we ignore diversions and it'll be really unusual for more than one package to provide any given .so file) 118 | | awk 'sub(":$", "", $1) { print $1 }' \ 119 | | sort -u \ 120 | | xargs -r apt-mark manual \ 121 | ; \ 122 | apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ 123 | rm -rf /var/lib/apt/lists/*; \ 124 | \ 125 | export PYTHONDONTWRITEBYTECODE=1; \ 126 | python3 --version; \ 127 | \ 128 | pip3 install \ 129 | --disable-pip-version-check \ 130 | --no-cache-dir \ 131 | --no-compile \ 132 | 'setuptools==79.0.1' \ 133 | # https://github.com/docker-library/python/issues/1023 134 | 'wheel<0.46' \ 135 | ; \ 136 | pip3 --version 137 | 138 | # make some useful symlinks that are expected to exist ("/usr/local/bin/python" and friends) 139 | RUN set -eux; \ 140 | for src in idle3 pip3 pydoc3 python3 python3-config; do \ 141 | dst="$(echo "$src" | tr -d 3)"; \ 142 | [ -s "/usr/local/bin/$src" ]; \ 143 | [ ! -e "/usr/local/bin/$dst" ]; \ 144 | ln -svT "$src" "/usr/local/bin/$dst"; \ 145 | done 146 | 147 | CMD ["python3"] 148 | -------------------------------------------------------------------------------- /3.14/slim-trixie/Dockerfile: -------------------------------------------------------------------------------- 1 | # 2 | # NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh" 3 | # 4 | # PLEASE DO NOT EDIT IT DIRECTLY. 5 | # 6 | 7 | FROM debian:trixie-slim 8 | 9 | # ensure local python is preferred over distribution python 10 | ENV PATH /usr/local/bin:$PATH 11 | 12 | # runtime dependencies 13 | RUN set -eux; \ 14 | apt-get update; \ 15 | apt-get install -y --no-install-recommends \ 16 | ca-certificates \ 17 | netbase \ 18 | tzdata \ 19 | ; \ 20 | apt-get dist-clean 21 | 22 | ENV PYTHON_VERSION 3.14.2 23 | ENV PYTHON_SHA256 ce543ab854bc256b61b71e9b27f831ffd1bfd60a479d639f8be7f9757cf573e9 24 | 25 | RUN set -eux; \ 26 | \ 27 | savedAptMark="$(apt-mark showmanual)"; \ 28 | apt-get update; \ 29 | apt-get install -y --no-install-recommends \ 30 | dpkg-dev \ 31 | gcc \ 32 | gnupg \ 33 | libbluetooth-dev \ 34 | libbz2-dev \ 35 | libc6-dev \ 36 | libdb-dev \ 37 | libffi-dev \ 38 | libgdbm-dev \ 39 | liblzma-dev \ 40 | libncursesw5-dev \ 41 | libreadline-dev \ 42 | libsqlite3-dev \ 43 | libssl-dev \ 44 | libzstd-dev \ 45 | make \ 46 | tk-dev \ 47 | uuid-dev \ 48 | wget \ 49 | xz-utils \ 50 | zlib1g-dev \ 51 | ; \ 52 | \ 53 | wget -O python.tar.xz "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz"; \ 54 | echo "$PYTHON_SHA256 *python.tar.xz" | sha256sum -c -; \ 55 | mkdir -p /usr/src/python; \ 56 | tar --extract --directory /usr/src/python --strip-components=1 --file python.tar.xz; \ 57 | rm python.tar.xz; \ 58 | \ 59 | cd /usr/src/python; \ 60 | gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \ 61 | ./configure \ 62 | --build="$gnuArch" \ 63 | --enable-loadable-sqlite-extensions \ 64 | --enable-optimizations \ 65 | --enable-option-checking=fatal \ 66 | --enable-shared \ 67 | $(test "${gnuArch%%-*}" != 'riscv64' && echo '--with-lto') \ 68 | --with-ensurepip \ 69 | ; \ 70 | nproc="$(nproc)"; \ 71 | EXTRA_CFLAGS="$(dpkg-buildflags --get CFLAGS)"; \ 72 | LDFLAGS="$(dpkg-buildflags --get LDFLAGS)"; \ 73 | LDFLAGS="${LDFLAGS:--Wl},--strip-all"; \ 74 | arch="$(dpkg --print-architecture)"; arch="${arch##*-}"; \ 75 | # https://docs.python.org/3.12/howto/perf_profiling.html 76 | # https://github.com/docker-library/python/pull/1000#issuecomment-2597021615 77 | case "$arch" in \ 78 | amd64|arm64) \ 79 | # only add "-mno-omit-leaf" on arches that support it 80 | # https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/x86-Options.html#index-momit-leaf-frame-pointer-2 81 | # https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/AArch64-Options.html#index-momit-leaf-frame-pointer 82 | EXTRA_CFLAGS="${EXTRA_CFLAGS:-} -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer"; \ 83 | ;; \ 84 | i386) \ 85 | # don't enable frame-pointers on 32bit x86 due to performance drop. 86 | ;; \ 87 | *) \ 88 | # other arches don't support "-mno-omit-leaf" 89 | EXTRA_CFLAGS="${EXTRA_CFLAGS:-} -fno-omit-frame-pointer"; \ 90 | ;; \ 91 | esac; \ 92 | make -j "$nproc" \ 93 | "EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \ 94 | "LDFLAGS=${LDFLAGS:-}" \ 95 | ; \ 96 | # https://github.com/docker-library/python/issues/784 97 | # prevent accidental usage of a system installed libpython of the same version 98 | rm python; \ 99 | make -j "$nproc" \ 100 | "EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \ 101 | "LDFLAGS=${LDFLAGS:--Wl},-rpath='\$\$ORIGIN/../lib'" \ 102 | python \ 103 | ; \ 104 | make install; \ 105 | \ 106 | cd /; \ 107 | rm -rf /usr/src/python; \ 108 | \ 109 | find /usr/local -depth \ 110 | \( \ 111 | \( -type d -a \( -name test -o -name tests -o -name idle_test \) \) \ 112 | -o \( -type f -a \( -name '*.pyc' -o -name '*.pyo' -o -name 'libpython*.a' \) \) \ 113 | \) -exec rm -rf '{}' + \ 114 | ; \ 115 | \ 116 | ldconfig; \ 117 | \ 118 | apt-mark auto '.*' > /dev/null; \ 119 | apt-mark manual $savedAptMark; \ 120 | find /usr/local -type f -executable -not \( -name '*tkinter*' \) -exec ldd '{}' ';' \ 121 | | awk '/=>/ { so = $(NF-1); if (index(so, "/usr/local/") == 1) { next }; gsub("^/(usr/)?", "", so); printf "*%s\n", so }' \ 122 | | sort -u \ 123 | | xargs -rt dpkg-query --search \ 124 | # https://manpages.debian.org/bookworm/dpkg/dpkg-query.1.en.html#S (we ignore diversions and it'll be really unusual for more than one package to provide any given .so file) 125 | | awk 'sub(":$", "", $1) { print $1 }' \ 126 | | sort -u \ 127 | | xargs -r apt-mark manual \ 128 | ; \ 129 | apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ 130 | apt-get dist-clean; \ 131 | \ 132 | export PYTHONDONTWRITEBYTECODE=1; \ 133 | python3 --version; \ 134 | pip3 --version 135 | 136 | # make some useful symlinks that are expected to exist ("/usr/local/bin/python" and friends) 137 | RUN set -eux; \ 138 | for src in idle3 pip3 pydoc3 python3 python3-config; do \ 139 | dst="$(echo "$src" | tr -d 3)"; \ 140 | [ -s "/usr/local/bin/$src" ]; \ 141 | [ ! -e "/usr/local/bin/$dst" ]; \ 142 | ln -svT "$src" "/usr/local/bin/$dst"; \ 143 | done 144 | 145 | CMD ["python3"] 146 | -------------------------------------------------------------------------------- /3.15-rc/slim-trixie/Dockerfile: -------------------------------------------------------------------------------- 1 | # 2 | # NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh" 3 | # 4 | # PLEASE DO NOT EDIT IT DIRECTLY. 5 | # 6 | 7 | FROM debian:trixie-slim 8 | 9 | # ensure local python is preferred over distribution python 10 | ENV PATH /usr/local/bin:$PATH 11 | 12 | # runtime dependencies 13 | RUN set -eux; \ 14 | apt-get update; \ 15 | apt-get install -y --no-install-recommends \ 16 | ca-certificates \ 17 | netbase \ 18 | tzdata \ 19 | ; \ 20 | apt-get dist-clean 21 | 22 | ENV PYTHON_VERSION 3.15.0a3 23 | ENV PYTHON_SHA256 6ab02cdac24505779877bb1d9189432d67e90ddf2a9b8b7b373ead54ac07b607 24 | 25 | RUN set -eux; \ 26 | \ 27 | savedAptMark="$(apt-mark showmanual)"; \ 28 | apt-get update; \ 29 | apt-get install -y --no-install-recommends \ 30 | dpkg-dev \ 31 | gcc \ 32 | gnupg \ 33 | libbluetooth-dev \ 34 | libbz2-dev \ 35 | libc6-dev \ 36 | libdb-dev \ 37 | libffi-dev \ 38 | libgdbm-dev \ 39 | liblzma-dev \ 40 | libncursesw5-dev \ 41 | libreadline-dev \ 42 | libsqlite3-dev \ 43 | libssl-dev \ 44 | libzstd-dev \ 45 | make \ 46 | tk-dev \ 47 | uuid-dev \ 48 | wget \ 49 | xz-utils \ 50 | zlib1g-dev \ 51 | ; \ 52 | \ 53 | wget -O python.tar.xz "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz"; \ 54 | echo "$PYTHON_SHA256 *python.tar.xz" | sha256sum -c -; \ 55 | mkdir -p /usr/src/python; \ 56 | tar --extract --directory /usr/src/python --strip-components=1 --file python.tar.xz; \ 57 | rm python.tar.xz; \ 58 | \ 59 | cd /usr/src/python; \ 60 | gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \ 61 | ./configure \ 62 | --build="$gnuArch" \ 63 | --enable-loadable-sqlite-extensions \ 64 | --enable-optimizations \ 65 | --enable-option-checking=fatal \ 66 | --enable-shared \ 67 | $(test "${gnuArch%%-*}" != 'riscv64' && echo '--with-lto') \ 68 | --with-ensurepip \ 69 | ; \ 70 | nproc="$(nproc)"; \ 71 | EXTRA_CFLAGS="$(dpkg-buildflags --get CFLAGS)"; \ 72 | LDFLAGS="$(dpkg-buildflags --get LDFLAGS)"; \ 73 | LDFLAGS="${LDFLAGS:--Wl},--strip-all"; \ 74 | arch="$(dpkg --print-architecture)"; arch="${arch##*-}"; \ 75 | # https://docs.python.org/3.12/howto/perf_profiling.html 76 | # https://github.com/docker-library/python/pull/1000#issuecomment-2597021615 77 | case "$arch" in \ 78 | amd64|arm64) \ 79 | # only add "-mno-omit-leaf" on arches that support it 80 | # https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/x86-Options.html#index-momit-leaf-frame-pointer-2 81 | # https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/AArch64-Options.html#index-momit-leaf-frame-pointer 82 | EXTRA_CFLAGS="${EXTRA_CFLAGS:-} -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer"; \ 83 | ;; \ 84 | i386) \ 85 | # don't enable frame-pointers on 32bit x86 due to performance drop. 86 | ;; \ 87 | *) \ 88 | # other arches don't support "-mno-omit-leaf" 89 | EXTRA_CFLAGS="${EXTRA_CFLAGS:-} -fno-omit-frame-pointer"; \ 90 | ;; \ 91 | esac; \ 92 | make -j "$nproc" \ 93 | "EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \ 94 | "LDFLAGS=${LDFLAGS:-}" \ 95 | ; \ 96 | # https://github.com/docker-library/python/issues/784 97 | # prevent accidental usage of a system installed libpython of the same version 98 | rm python; \ 99 | make -j "$nproc" \ 100 | "EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \ 101 | "LDFLAGS=${LDFLAGS:--Wl},-rpath='\$\$ORIGIN/../lib'" \ 102 | python \ 103 | ; \ 104 | make install; \ 105 | \ 106 | cd /; \ 107 | rm -rf /usr/src/python; \ 108 | \ 109 | find /usr/local -depth \ 110 | \( \ 111 | \( -type d -a \( -name test -o -name tests -o -name idle_test \) \) \ 112 | -o \( -type f -a \( -name '*.pyc' -o -name '*.pyo' -o -name 'libpython*.a' \) \) \ 113 | \) -exec rm -rf '{}' + \ 114 | ; \ 115 | \ 116 | ldconfig; \ 117 | \ 118 | apt-mark auto '.*' > /dev/null; \ 119 | apt-mark manual $savedAptMark; \ 120 | find /usr/local -type f -executable -not \( -name '*tkinter*' \) -exec ldd '{}' ';' \ 121 | | awk '/=>/ { so = $(NF-1); if (index(so, "/usr/local/") == 1) { next }; gsub("^/(usr/)?", "", so); printf "*%s\n", so }' \ 122 | | sort -u \ 123 | | xargs -rt dpkg-query --search \ 124 | # https://manpages.debian.org/bookworm/dpkg/dpkg-query.1.en.html#S (we ignore diversions and it'll be really unusual for more than one package to provide any given .so file) 125 | | awk 'sub(":$", "", $1) { print $1 }' \ 126 | | sort -u \ 127 | | xargs -r apt-mark manual \ 128 | ; \ 129 | apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ 130 | apt-get dist-clean; \ 131 | \ 132 | export PYTHONDONTWRITEBYTECODE=1; \ 133 | python3 --version; \ 134 | pip3 --version 135 | 136 | # make some useful symlinks that are expected to exist ("/usr/local/bin/python" and friends) 137 | RUN set -eux; \ 138 | for src in idle3 pip3 pydoc3 python3 python3-config; do \ 139 | dst="$(echo "$src" | tr -d 3)"; \ 140 | [ -s "/usr/local/bin/$src" ]; \ 141 | [ ! -e "/usr/local/bin/$dst" ]; \ 142 | ln -svT "$src" "/usr/local/bin/$dst"; \ 143 | done 144 | 145 | CMD ["python3"] 146 | -------------------------------------------------------------------------------- /3.13/alpine3.22/Dockerfile: -------------------------------------------------------------------------------- 1 | # 2 | # NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh" 3 | # 4 | # PLEASE DO NOT EDIT IT DIRECTLY. 5 | # 6 | 7 | FROM alpine:3.22 8 | 9 | # ensure local python is preferred over distribution python 10 | ENV PATH /usr/local/bin:$PATH 11 | 12 | # runtime dependencies 13 | RUN set -eux; \ 14 | apk add --no-cache \ 15 | ca-certificates \ 16 | tzdata \ 17 | ; 18 | 19 | ENV GPG_KEY 7169605F62C751356D054A26A821E680E5FA6305 20 | ENV PYTHON_VERSION 3.13.11 21 | ENV PYTHON_SHA256 16ede7bb7cdbfa895d11b0642fa0e523f291e6487194d53cf6d3b338c3a17ea2 22 | 23 | RUN set -eux; \ 24 | \ 25 | apk add --no-cache --virtual .build-deps \ 26 | bluez-dev \ 27 | bzip2-dev \ 28 | dpkg-dev dpkg \ 29 | findutils \ 30 | gcc \ 31 | gdbm-dev \ 32 | gnupg \ 33 | libc-dev \ 34 | libffi-dev \ 35 | libnsl-dev \ 36 | libtirpc-dev \ 37 | linux-headers \ 38 | make \ 39 | ncurses-dev \ 40 | openssl-dev \ 41 | pax-utils \ 42 | readline-dev \ 43 | sqlite-dev \ 44 | tar \ 45 | tcl-dev \ 46 | tk \ 47 | tk-dev \ 48 | util-linux-dev \ 49 | xz \ 50 | xz-dev \ 51 | zlib-dev \ 52 | ; \ 53 | \ 54 | wget -O python.tar.xz "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz"; \ 55 | echo "$PYTHON_SHA256 *python.tar.xz" | sha256sum -c -; \ 56 | wget -O python.tar.xz.asc "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz.asc"; \ 57 | GNUPGHOME="$(mktemp -d)"; export GNUPGHOME; \ 58 | gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$GPG_KEY"; \ 59 | gpg --batch --verify python.tar.xz.asc python.tar.xz; \ 60 | gpgconf --kill all; \ 61 | rm -rf "$GNUPGHOME" python.tar.xz.asc; \ 62 | mkdir -p /usr/src/python; \ 63 | tar --extract --directory /usr/src/python --strip-components=1 --file python.tar.xz; \ 64 | rm python.tar.xz; \ 65 | \ 66 | cd /usr/src/python; \ 67 | gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \ 68 | ./configure \ 69 | --build="$gnuArch" \ 70 | --enable-loadable-sqlite-extensions \ 71 | --enable-option-checking=fatal \ 72 | --enable-shared \ 73 | $(test "${gnuArch%%-*}" != 'riscv64' && echo '--with-lto') \ 74 | --with-ensurepip \ 75 | ; \ 76 | nproc="$(nproc)"; \ 77 | # set thread stack size to 1MB so we don't segfault before we hit sys.getrecursionlimit() 78 | # https://github.com/alpinelinux/aports/commit/2026e1259422d4e0cf92391ca2d3844356c649d0 79 | EXTRA_CFLAGS="-DTHREAD_STACK_SIZE=0x100000"; \ 80 | LDFLAGS="${LDFLAGS:--Wl},--strip-all"; \ 81 | arch="$(apk --print-arch)"; \ 82 | # https://docs.python.org/3.12/howto/perf_profiling.html 83 | # https://github.com/docker-library/python/pull/1000#issuecomment-2597021615 84 | case "$arch" in \ 85 | x86_64|aarch64) \ 86 | # only add "-mno-omit-leaf" on arches that support it 87 | # https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/x86-Options.html#index-momit-leaf-frame-pointer-2 88 | # https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/AArch64-Options.html#index-momit-leaf-frame-pointer 89 | EXTRA_CFLAGS="${EXTRA_CFLAGS:-} -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer"; \ 90 | ;; \ 91 | x86) \ 92 | # don't enable frame-pointers on 32bit x86 due to performance drop. 93 | ;; \ 94 | *) \ 95 | # other arches don't support "-mno-omit-leaf" 96 | EXTRA_CFLAGS="${EXTRA_CFLAGS:-} -fno-omit-frame-pointer"; \ 97 | ;; \ 98 | esac; \ 99 | make -j "$nproc" \ 100 | "EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \ 101 | "LDFLAGS=${LDFLAGS:-}" \ 102 | ; \ 103 | # https://github.com/docker-library/python/issues/784 104 | # prevent accidental usage of a system installed libpython of the same version 105 | rm python; \ 106 | make -j "$nproc" \ 107 | "EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \ 108 | "LDFLAGS=${LDFLAGS:--Wl},-rpath='\$\$ORIGIN/../lib'" \ 109 | python \ 110 | ; \ 111 | make install; \ 112 | \ 113 | cd /; \ 114 | rm -rf /usr/src/python; \ 115 | \ 116 | find /usr/local -depth \ 117 | \( \ 118 | \( -type d -a \( -name test -o -name tests -o -name idle_test \) \) \ 119 | -o \( -type f -a \( -name '*.pyc' -o -name '*.pyo' -o -name 'libpython*.a' \) \) \ 120 | \) -exec rm -rf '{}' + \ 121 | ; \ 122 | \ 123 | find /usr/local -type f -executable -not \( -name '*tkinter*' \) -exec scanelf --needed --nobanner --format '%n#p' '{}' ';' \ 124 | | tr ',' '\n' \ 125 | | sort -u \ 126 | | awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \ 127 | | xargs -rt apk add --no-network --virtual .python-rundeps \ 128 | ; \ 129 | apk del --no-network .build-deps; \ 130 | \ 131 | export PYTHONDONTWRITEBYTECODE=1; \ 132 | python3 --version; \ 133 | pip3 --version 134 | 135 | # make some useful symlinks that are expected to exist ("/usr/local/bin/python" and friends) 136 | RUN set -eux; \ 137 | for src in idle3 pip3 pydoc3 python3 python3-config; do \ 138 | dst="$(echo "$src" | tr -d 3)"; \ 139 | [ -s "/usr/local/bin/$src" ]; \ 140 | [ ! -e "/usr/local/bin/$dst" ]; \ 141 | ln -svT "$src" "/usr/local/bin/$dst"; \ 142 | done 143 | 144 | CMD ["python3"] 145 | -------------------------------------------------------------------------------- /3.13/alpine3.23/Dockerfile: -------------------------------------------------------------------------------- 1 | # 2 | # NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh" 3 | # 4 | # PLEASE DO NOT EDIT IT DIRECTLY. 5 | # 6 | 7 | FROM alpine:3.23 8 | 9 | # ensure local python is preferred over distribution python 10 | ENV PATH /usr/local/bin:$PATH 11 | 12 | # runtime dependencies 13 | RUN set -eux; \ 14 | apk add --no-cache \ 15 | ca-certificates \ 16 | tzdata \ 17 | ; 18 | 19 | ENV GPG_KEY 7169605F62C751356D054A26A821E680E5FA6305 20 | ENV PYTHON_VERSION 3.13.11 21 | ENV PYTHON_SHA256 16ede7bb7cdbfa895d11b0642fa0e523f291e6487194d53cf6d3b338c3a17ea2 22 | 23 | RUN set -eux; \ 24 | \ 25 | apk add --no-cache --virtual .build-deps \ 26 | bluez-dev \ 27 | bzip2-dev \ 28 | dpkg-dev dpkg \ 29 | findutils \ 30 | gcc \ 31 | gdbm-dev \ 32 | gnupg \ 33 | libc-dev \ 34 | libffi-dev \ 35 | libnsl-dev \ 36 | libtirpc-dev \ 37 | linux-headers \ 38 | make \ 39 | ncurses-dev \ 40 | openssl-dev \ 41 | pax-utils \ 42 | readline-dev \ 43 | sqlite-dev \ 44 | tar \ 45 | tcl-dev \ 46 | tk \ 47 | tk-dev \ 48 | util-linux-dev \ 49 | xz \ 50 | xz-dev \ 51 | zlib-dev \ 52 | ; \ 53 | \ 54 | wget -O python.tar.xz "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz"; \ 55 | echo "$PYTHON_SHA256 *python.tar.xz" | sha256sum -c -; \ 56 | wget -O python.tar.xz.asc "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz.asc"; \ 57 | GNUPGHOME="$(mktemp -d)"; export GNUPGHOME; \ 58 | gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$GPG_KEY"; \ 59 | gpg --batch --verify python.tar.xz.asc python.tar.xz; \ 60 | gpgconf --kill all; \ 61 | rm -rf "$GNUPGHOME" python.tar.xz.asc; \ 62 | mkdir -p /usr/src/python; \ 63 | tar --extract --directory /usr/src/python --strip-components=1 --file python.tar.xz; \ 64 | rm python.tar.xz; \ 65 | \ 66 | cd /usr/src/python; \ 67 | gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \ 68 | ./configure \ 69 | --build="$gnuArch" \ 70 | --enable-loadable-sqlite-extensions \ 71 | --enable-option-checking=fatal \ 72 | --enable-shared \ 73 | $(test "${gnuArch%%-*}" != 'riscv64' && echo '--with-lto') \ 74 | --with-ensurepip \ 75 | ; \ 76 | nproc="$(nproc)"; \ 77 | # set thread stack size to 1MB so we don't segfault before we hit sys.getrecursionlimit() 78 | # https://github.com/alpinelinux/aports/commit/2026e1259422d4e0cf92391ca2d3844356c649d0 79 | EXTRA_CFLAGS="-DTHREAD_STACK_SIZE=0x100000"; \ 80 | LDFLAGS="${LDFLAGS:--Wl},--strip-all"; \ 81 | arch="$(apk --print-arch)"; \ 82 | # https://docs.python.org/3.12/howto/perf_profiling.html 83 | # https://github.com/docker-library/python/pull/1000#issuecomment-2597021615 84 | case "$arch" in \ 85 | x86_64|aarch64) \ 86 | # only add "-mno-omit-leaf" on arches that support it 87 | # https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/x86-Options.html#index-momit-leaf-frame-pointer-2 88 | # https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/AArch64-Options.html#index-momit-leaf-frame-pointer 89 | EXTRA_CFLAGS="${EXTRA_CFLAGS:-} -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer"; \ 90 | ;; \ 91 | x86) \ 92 | # don't enable frame-pointers on 32bit x86 due to performance drop. 93 | ;; \ 94 | *) \ 95 | # other arches don't support "-mno-omit-leaf" 96 | EXTRA_CFLAGS="${EXTRA_CFLAGS:-} -fno-omit-frame-pointer"; \ 97 | ;; \ 98 | esac; \ 99 | make -j "$nproc" \ 100 | "EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \ 101 | "LDFLAGS=${LDFLAGS:-}" \ 102 | ; \ 103 | # https://github.com/docker-library/python/issues/784 104 | # prevent accidental usage of a system installed libpython of the same version 105 | rm python; \ 106 | make -j "$nproc" \ 107 | "EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \ 108 | "LDFLAGS=${LDFLAGS:--Wl},-rpath='\$\$ORIGIN/../lib'" \ 109 | python \ 110 | ; \ 111 | make install; \ 112 | \ 113 | cd /; \ 114 | rm -rf /usr/src/python; \ 115 | \ 116 | find /usr/local -depth \ 117 | \( \ 118 | \( -type d -a \( -name test -o -name tests -o -name idle_test \) \) \ 119 | -o \( -type f -a \( -name '*.pyc' -o -name '*.pyo' -o -name 'libpython*.a' \) \) \ 120 | \) -exec rm -rf '{}' + \ 121 | ; \ 122 | \ 123 | find /usr/local -type f -executable -not \( -name '*tkinter*' \) -exec scanelf --needed --nobanner --format '%n#p' '{}' ';' \ 124 | | tr ',' '\n' \ 125 | | sort -u \ 126 | | awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \ 127 | | xargs -rt apk add --no-network --virtual .python-rundeps \ 128 | ; \ 129 | apk del --no-network .build-deps; \ 130 | \ 131 | export PYTHONDONTWRITEBYTECODE=1; \ 132 | python3 --version; \ 133 | pip3 --version 134 | 135 | # make some useful symlinks that are expected to exist ("/usr/local/bin/python" and friends) 136 | RUN set -eux; \ 137 | for src in idle3 pip3 pydoc3 python3 python3-config; do \ 138 | dst="$(echo "$src" | tr -d 3)"; \ 139 | [ -s "/usr/local/bin/$src" ]; \ 140 | [ ! -e "/usr/local/bin/$dst" ]; \ 141 | ln -svT "$src" "/usr/local/bin/$dst"; \ 142 | done 143 | 144 | CMD ["python3"] 145 | -------------------------------------------------------------------------------- /3.14/slim-bookworm/Dockerfile: -------------------------------------------------------------------------------- 1 | # 2 | # NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh" 3 | # 4 | # PLEASE DO NOT EDIT IT DIRECTLY. 5 | # 6 | 7 | FROM debian:bookworm-slim 8 | 9 | # ensure local python is preferred over distribution python 10 | ENV PATH /usr/local/bin:$PATH 11 | 12 | # runtime dependencies 13 | RUN set -eux; \ 14 | apt-get update; \ 15 | apt-get install -y --no-install-recommends \ 16 | ca-certificates \ 17 | netbase \ 18 | tzdata \ 19 | ; \ 20 | rm -rf /var/lib/apt/lists/* 21 | 22 | ENV PYTHON_VERSION 3.14.2 23 | ENV PYTHON_SHA256 ce543ab854bc256b61b71e9b27f831ffd1bfd60a479d639f8be7f9757cf573e9 24 | 25 | RUN set -eux; \ 26 | \ 27 | savedAptMark="$(apt-mark showmanual)"; \ 28 | apt-get update; \ 29 | apt-get install -y --no-install-recommends \ 30 | dpkg-dev \ 31 | gcc \ 32 | gnupg \ 33 | libbluetooth-dev \ 34 | libbz2-dev \ 35 | libc6-dev \ 36 | libdb-dev \ 37 | libffi-dev \ 38 | libgdbm-dev \ 39 | liblzma-dev \ 40 | libncursesw5-dev \ 41 | libreadline-dev \ 42 | libsqlite3-dev \ 43 | libssl-dev \ 44 | libzstd-dev \ 45 | make \ 46 | tk-dev \ 47 | uuid-dev \ 48 | wget \ 49 | xz-utils \ 50 | zlib1g-dev \ 51 | ; \ 52 | \ 53 | wget -O python.tar.xz "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz"; \ 54 | echo "$PYTHON_SHA256 *python.tar.xz" | sha256sum -c -; \ 55 | mkdir -p /usr/src/python; \ 56 | tar --extract --directory /usr/src/python --strip-components=1 --file python.tar.xz; \ 57 | rm python.tar.xz; \ 58 | \ 59 | cd /usr/src/python; \ 60 | gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \ 61 | ./configure \ 62 | --build="$gnuArch" \ 63 | --enable-loadable-sqlite-extensions \ 64 | --enable-optimizations \ 65 | --enable-option-checking=fatal \ 66 | --enable-shared \ 67 | $(test "${gnuArch%%-*}" != 'riscv64' && echo '--with-lto') \ 68 | --with-ensurepip \ 69 | ; \ 70 | nproc="$(nproc)"; \ 71 | EXTRA_CFLAGS="$(dpkg-buildflags --get CFLAGS)"; \ 72 | LDFLAGS="$(dpkg-buildflags --get LDFLAGS)"; \ 73 | LDFLAGS="${LDFLAGS:--Wl},--strip-all"; \ 74 | arch="$(dpkg --print-architecture)"; arch="${arch##*-}"; \ 75 | # https://docs.python.org/3.12/howto/perf_profiling.html 76 | # https://github.com/docker-library/python/pull/1000#issuecomment-2597021615 77 | case "$arch" in \ 78 | amd64|arm64) \ 79 | # only add "-mno-omit-leaf" on arches that support it 80 | # https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/x86-Options.html#index-momit-leaf-frame-pointer-2 81 | # https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/AArch64-Options.html#index-momit-leaf-frame-pointer 82 | EXTRA_CFLAGS="${EXTRA_CFLAGS:-} -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer"; \ 83 | ;; \ 84 | i386) \ 85 | # don't enable frame-pointers on 32bit x86 due to performance drop. 86 | ;; \ 87 | *) \ 88 | # other arches don't support "-mno-omit-leaf" 89 | EXTRA_CFLAGS="${EXTRA_CFLAGS:-} -fno-omit-frame-pointer"; \ 90 | ;; \ 91 | esac; \ 92 | make -j "$nproc" \ 93 | "EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \ 94 | "LDFLAGS=${LDFLAGS:-}" \ 95 | ; \ 96 | # https://github.com/docker-library/python/issues/784 97 | # prevent accidental usage of a system installed libpython of the same version 98 | rm python; \ 99 | make -j "$nproc" \ 100 | "EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \ 101 | "LDFLAGS=${LDFLAGS:--Wl},-rpath='\$\$ORIGIN/../lib'" \ 102 | python \ 103 | ; \ 104 | make install; \ 105 | \ 106 | cd /; \ 107 | rm -rf /usr/src/python; \ 108 | \ 109 | find /usr/local -depth \ 110 | \( \ 111 | \( -type d -a \( -name test -o -name tests -o -name idle_test \) \) \ 112 | -o \( -type f -a \( -name '*.pyc' -o -name '*.pyo' -o -name 'libpython*.a' \) \) \ 113 | \) -exec rm -rf '{}' + \ 114 | ; \ 115 | \ 116 | ldconfig; \ 117 | \ 118 | apt-mark auto '.*' > /dev/null; \ 119 | apt-mark manual $savedAptMark; \ 120 | find /usr/local -type f -executable -not \( -name '*tkinter*' \) -exec ldd '{}' ';' \ 121 | | awk '/=>/ { so = $(NF-1); if (index(so, "/usr/local/") == 1) { next }; gsub("^/(usr/)?", "", so); printf "*%s\n", so }' \ 122 | | sort -u \ 123 | | xargs -rt dpkg-query --search \ 124 | # https://manpages.debian.org/bookworm/dpkg/dpkg-query.1.en.html#S (we ignore diversions and it'll be really unusual for more than one package to provide any given .so file) 125 | | awk 'sub(":$", "", $1) { print $1 }' \ 126 | | sort -u \ 127 | | xargs -r apt-mark manual \ 128 | ; \ 129 | apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ 130 | rm -rf /var/lib/apt/lists/*; \ 131 | \ 132 | export PYTHONDONTWRITEBYTECODE=1; \ 133 | python3 --version; \ 134 | pip3 --version 135 | 136 | # make some useful symlinks that are expected to exist ("/usr/local/bin/python" and friends) 137 | RUN set -eux; \ 138 | for src in idle3 pip3 pydoc3 python3 python3-config; do \ 139 | dst="$(echo "$src" | tr -d 3)"; \ 140 | [ -s "/usr/local/bin/$src" ]; \ 141 | [ ! -e "/usr/local/bin/$dst" ]; \ 142 | ln -svT "$src" "/usr/local/bin/$dst"; \ 143 | done 144 | 145 | CMD ["python3"] 146 | -------------------------------------------------------------------------------- /3.15-rc/slim-bookworm/Dockerfile: -------------------------------------------------------------------------------- 1 | # 2 | # NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh" 3 | # 4 | # PLEASE DO NOT EDIT IT DIRECTLY. 5 | # 6 | 7 | FROM debian:bookworm-slim 8 | 9 | # ensure local python is preferred over distribution python 10 | ENV PATH /usr/local/bin:$PATH 11 | 12 | # runtime dependencies 13 | RUN set -eux; \ 14 | apt-get update; \ 15 | apt-get install -y --no-install-recommends \ 16 | ca-certificates \ 17 | netbase \ 18 | tzdata \ 19 | ; \ 20 | rm -rf /var/lib/apt/lists/* 21 | 22 | ENV PYTHON_VERSION 3.15.0a3 23 | ENV PYTHON_SHA256 6ab02cdac24505779877bb1d9189432d67e90ddf2a9b8b7b373ead54ac07b607 24 | 25 | RUN set -eux; \ 26 | \ 27 | savedAptMark="$(apt-mark showmanual)"; \ 28 | apt-get update; \ 29 | apt-get install -y --no-install-recommends \ 30 | dpkg-dev \ 31 | gcc \ 32 | gnupg \ 33 | libbluetooth-dev \ 34 | libbz2-dev \ 35 | libc6-dev \ 36 | libdb-dev \ 37 | libffi-dev \ 38 | libgdbm-dev \ 39 | liblzma-dev \ 40 | libncursesw5-dev \ 41 | libreadline-dev \ 42 | libsqlite3-dev \ 43 | libssl-dev \ 44 | libzstd-dev \ 45 | make \ 46 | tk-dev \ 47 | uuid-dev \ 48 | wget \ 49 | xz-utils \ 50 | zlib1g-dev \ 51 | ; \ 52 | \ 53 | wget -O python.tar.xz "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz"; \ 54 | echo "$PYTHON_SHA256 *python.tar.xz" | sha256sum -c -; \ 55 | mkdir -p /usr/src/python; \ 56 | tar --extract --directory /usr/src/python --strip-components=1 --file python.tar.xz; \ 57 | rm python.tar.xz; \ 58 | \ 59 | cd /usr/src/python; \ 60 | gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \ 61 | ./configure \ 62 | --build="$gnuArch" \ 63 | --enable-loadable-sqlite-extensions \ 64 | --enable-optimizations \ 65 | --enable-option-checking=fatal \ 66 | --enable-shared \ 67 | $(test "${gnuArch%%-*}" != 'riscv64' && echo '--with-lto') \ 68 | --with-ensurepip \ 69 | ; \ 70 | nproc="$(nproc)"; \ 71 | EXTRA_CFLAGS="$(dpkg-buildflags --get CFLAGS)"; \ 72 | LDFLAGS="$(dpkg-buildflags --get LDFLAGS)"; \ 73 | LDFLAGS="${LDFLAGS:--Wl},--strip-all"; \ 74 | arch="$(dpkg --print-architecture)"; arch="${arch##*-}"; \ 75 | # https://docs.python.org/3.12/howto/perf_profiling.html 76 | # https://github.com/docker-library/python/pull/1000#issuecomment-2597021615 77 | case "$arch" in \ 78 | amd64|arm64) \ 79 | # only add "-mno-omit-leaf" on arches that support it 80 | # https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/x86-Options.html#index-momit-leaf-frame-pointer-2 81 | # https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/AArch64-Options.html#index-momit-leaf-frame-pointer 82 | EXTRA_CFLAGS="${EXTRA_CFLAGS:-} -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer"; \ 83 | ;; \ 84 | i386) \ 85 | # don't enable frame-pointers on 32bit x86 due to performance drop. 86 | ;; \ 87 | *) \ 88 | # other arches don't support "-mno-omit-leaf" 89 | EXTRA_CFLAGS="${EXTRA_CFLAGS:-} -fno-omit-frame-pointer"; \ 90 | ;; \ 91 | esac; \ 92 | make -j "$nproc" \ 93 | "EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \ 94 | "LDFLAGS=${LDFLAGS:-}" \ 95 | ; \ 96 | # https://github.com/docker-library/python/issues/784 97 | # prevent accidental usage of a system installed libpython of the same version 98 | rm python; \ 99 | make -j "$nproc" \ 100 | "EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \ 101 | "LDFLAGS=${LDFLAGS:--Wl},-rpath='\$\$ORIGIN/../lib'" \ 102 | python \ 103 | ; \ 104 | make install; \ 105 | \ 106 | cd /; \ 107 | rm -rf /usr/src/python; \ 108 | \ 109 | find /usr/local -depth \ 110 | \( \ 111 | \( -type d -a \( -name test -o -name tests -o -name idle_test \) \) \ 112 | -o \( -type f -a \( -name '*.pyc' -o -name '*.pyo' -o -name 'libpython*.a' \) \) \ 113 | \) -exec rm -rf '{}' + \ 114 | ; \ 115 | \ 116 | ldconfig; \ 117 | \ 118 | apt-mark auto '.*' > /dev/null; \ 119 | apt-mark manual $savedAptMark; \ 120 | find /usr/local -type f -executable -not \( -name '*tkinter*' \) -exec ldd '{}' ';' \ 121 | | awk '/=>/ { so = $(NF-1); if (index(so, "/usr/local/") == 1) { next }; gsub("^/(usr/)?", "", so); printf "*%s\n", so }' \ 122 | | sort -u \ 123 | | xargs -rt dpkg-query --search \ 124 | # https://manpages.debian.org/bookworm/dpkg/dpkg-query.1.en.html#S (we ignore diversions and it'll be really unusual for more than one package to provide any given .so file) 125 | | awk 'sub(":$", "", $1) { print $1 }' \ 126 | | sort -u \ 127 | | xargs -r apt-mark manual \ 128 | ; \ 129 | apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ 130 | rm -rf /var/lib/apt/lists/*; \ 131 | \ 132 | export PYTHONDONTWRITEBYTECODE=1; \ 133 | python3 --version; \ 134 | pip3 --version 135 | 136 | # make some useful symlinks that are expected to exist ("/usr/local/bin/python" and friends) 137 | RUN set -eux; \ 138 | for src in idle3 pip3 pydoc3 python3 python3-config; do \ 139 | dst="$(echo "$src" | tr -d 3)"; \ 140 | [ -s "/usr/local/bin/$src" ]; \ 141 | [ ! -e "/usr/local/bin/$dst" ]; \ 142 | ln -svT "$src" "/usr/local/bin/$dst"; \ 143 | done 144 | 145 | CMD ["python3"] 146 | -------------------------------------------------------------------------------- /generate-stackbrew-library.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -Eeuo pipefail 3 | 4 | declare -A aliases=( 5 | [3.14]='3 latest' 6 | ) 7 | 8 | self="$(basename "$BASH_SOURCE")" 9 | cd "$(dirname "$(readlink -f "$BASH_SOURCE")")" 10 | 11 | if [ "$#" -eq 0 ]; then 12 | versions="$(jq -r 'keys | map(@sh) | join(" ")' versions.json)" 13 | eval "set -- $versions" 14 | fi 15 | 16 | # sort version numbers with highest first 17 | IFS=$'\n'; set -- $(sort -rV <<<"$*"); unset IFS 18 | 19 | # get the most recent commit which modified any of "$@" 20 | fileCommit() { 21 | git log -1 --format='format:%H' HEAD -- "$@" 22 | } 23 | 24 | # get the most recent commit which modified "$1/Dockerfile" or any file COPY'd from "$1/Dockerfile" 25 | dirCommit() { 26 | local dir="$1"; shift 27 | ( 28 | cd "$dir" 29 | files="$( 30 | git show HEAD:./Dockerfile | awk ' 31 | toupper($1) == "COPY" { 32 | for (i = 2; i < NF; i++) { 33 | if ($i ~ /^--from=/) { 34 | next 35 | } 36 | print $i 37 | } 38 | } 39 | ' 40 | )" 41 | fileCommit Dockerfile $files 42 | ) 43 | } 44 | 45 | getArches() { 46 | local repo="$1"; shift 47 | local officialImagesBase="${BASHBREW_LIBRARY:-https://github.com/docker-library/official-images/raw/HEAD/library}/" 48 | 49 | local parentRepoToArchesStr 50 | parentRepoToArchesStr="$( 51 | find -name 'Dockerfile' -exec awk -v officialImagesBase="$officialImagesBase" ' 52 | toupper($1) == "FROM" && $2 !~ /^('"$repo"'|scratch|.*\/.*)(:|$)/ { 53 | printf "%s%s\n", officialImagesBase, $2 54 | } 55 | ' '{}' + \ 56 | | sort -u \ 57 | | xargs -r bashbrew cat --format '["{{ .RepoName }}:{{ .TagName }}"]="{{ join " " .TagEntry.Architectures }}"' 58 | )" 59 | eval "declare -g -A parentRepoToArches=( $parentRepoToArchesStr )" 60 | } 61 | getArches 'python' 62 | 63 | cat <<-EOH 64 | # this file is generated via https://github.com/docker-library/python/blob/$(fileCommit "$self")/$self 65 | 66 | Maintainers: Tianon Gravi (@tianon), 67 | Joseph Ferguson (@yosifkit) 68 | GitRepo: https://github.com/docker-library/python.git 69 | Builder: buildkit 70 | EOH 71 | 72 | # prints "$2$1$3$1...$N" 73 | join() { 74 | local sep="$1"; shift 75 | local out; printf -v out "${sep//%/%%}%s" "$@" 76 | echo "${out#$sep}" 77 | } 78 | 79 | for version; do 80 | export version 81 | variants="$(jq -r '.[env.version].variants | map(@sh) | join(" ")' versions.json)" 82 | eval "variants=( $variants )" 83 | 84 | fullVersion="$(jq -r '.[env.version].version' versions.json)" 85 | 86 | versionAliases=( 87 | $fullVersion 88 | $version 89 | ${aliases[$version]:-} 90 | ) 91 | 92 | defaultDebianVariant="$(jq -r ' 93 | .[env.version].variants 94 | | map(select( 95 | startswith("alpine") 96 | or startswith("slim-") 97 | or startswith("windows/") 98 | | not 99 | )) 100 | | .[0] 101 | ' versions.json)" 102 | defaultAlpineVariant="$(jq -r ' 103 | .[env.version].variants 104 | | map(select( 105 | startswith("alpine") 106 | )) 107 | | .[0] 108 | ' versions.json)" 109 | 110 | for v in "${variants[@]}"; do 111 | dir="$version/$v" 112 | [ -f "$dir/Dockerfile" ] || continue 113 | variant="$(basename "$v")" 114 | 115 | commit="$(dirCommit "$dir")" 116 | 117 | variantAliases=( "${versionAliases[@]/%/-$variant}" ) 118 | case "$variant" in 119 | *-"$defaultDebianVariant") # slim-xxx -> slim 120 | variantAliases+=( "${versionAliases[@]/%/-${variant%-$defaultDebianVariant}}" ) 121 | ;; 122 | "$defaultAlpineVariant") 123 | variantAliases+=( "${versionAliases[@]/%/-alpine}" ) 124 | ;; 125 | esac 126 | variantAliases=( "${variantAliases[@]//latest-/}" ) 127 | 128 | case "$v" in 129 | windows/*) 130 | variantArches='windows-amd64' 131 | ;; 132 | 133 | *) 134 | variantParent="$(awk 'toupper($1) == "FROM" { print $2 }' "$dir/Dockerfile")" 135 | variantArches="${parentRepoToArches[$variantParent]}" 136 | ;; 137 | esac 138 | 139 | # https://github.com/python/cpython/issues/93619 (Linking error when building 3.11 beta on mips64le) + https://peps.python.org/pep-0011/ (mips is not even tier 3) 140 | variantArches="$(sed <<<" $variantArches " -e 's/ mips64le / /g')" 141 | 142 | sharedTags=() 143 | for windowsShared in windowsservercore nanoserver; do 144 | if [[ "$variant" == "$windowsShared"* ]]; then 145 | sharedTags=( "${versionAliases[@]/%/-$windowsShared}" ) 146 | sharedTags=( "${sharedTags[@]//latest-/}" ) 147 | break 148 | fi 149 | done 150 | if [ "$variant" = "$defaultDebianVariant" ] || [[ "$variant" == 'windowsservercore'* ]]; then 151 | sharedTags+=( "${versionAliases[@]}" ) 152 | fi 153 | 154 | echo 155 | echo "Tags: $(join ', ' "${variantAliases[@]}")" 156 | if [ "${#sharedTags[@]}" -gt 0 ]; then 157 | echo "SharedTags: $(join ', ' "${sharedTags[@]}")" 158 | fi 159 | cat <<-EOE 160 | Architectures: $(join ', ' $variantArches) 161 | GitCommit: $commit 162 | Directory: $dir 163 | EOE 164 | if [[ "$v" == windows/* ]]; then 165 | echo "Constraints: $variant" 166 | echo 'Builder: classic' 167 | fi 168 | done 169 | done 170 | -------------------------------------------------------------------------------- /3.12/alpine3.22/Dockerfile: -------------------------------------------------------------------------------- 1 | # 2 | # NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh" 3 | # 4 | # PLEASE DO NOT EDIT IT DIRECTLY. 5 | # 6 | 7 | FROM alpine:3.22 8 | 9 | # ensure local python is preferred over distribution python 10 | ENV PATH /usr/local/bin:$PATH 11 | 12 | # cannot remove LANG even though https://bugs.python.org/issue19846 is fixed 13 | # last attempted removal of LANG broke many users: 14 | # https://github.com/docker-library/python/pull/570 15 | ENV LANG C.UTF-8 16 | 17 | # runtime dependencies 18 | RUN set -eux; \ 19 | apk add --no-cache \ 20 | ca-certificates \ 21 | tzdata \ 22 | ; 23 | 24 | ENV GPG_KEY 7169605F62C751356D054A26A821E680E5FA6305 25 | ENV PYTHON_VERSION 3.12.12 26 | ENV PYTHON_SHA256 fb85a13414b028c49ba18bbd523c2d055a30b56b18b92ce454ea2c51edc656c4 27 | 28 | RUN set -eux; \ 29 | \ 30 | apk add --no-cache --virtual .build-deps \ 31 | bluez-dev \ 32 | bzip2-dev \ 33 | dpkg-dev dpkg \ 34 | findutils \ 35 | gcc \ 36 | gdbm-dev \ 37 | gnupg \ 38 | libc-dev \ 39 | libffi-dev \ 40 | libnsl-dev \ 41 | libtirpc-dev \ 42 | linux-headers \ 43 | make \ 44 | ncurses-dev \ 45 | openssl-dev \ 46 | pax-utils \ 47 | readline-dev \ 48 | sqlite-dev \ 49 | tar \ 50 | tcl-dev \ 51 | tk \ 52 | tk-dev \ 53 | util-linux-dev \ 54 | xz \ 55 | xz-dev \ 56 | zlib-dev \ 57 | ; \ 58 | \ 59 | wget -O python.tar.xz "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz"; \ 60 | echo "$PYTHON_SHA256 *python.tar.xz" | sha256sum -c -; \ 61 | wget -O python.tar.xz.asc "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz.asc"; \ 62 | GNUPGHOME="$(mktemp -d)"; export GNUPGHOME; \ 63 | gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$GPG_KEY"; \ 64 | gpg --batch --verify python.tar.xz.asc python.tar.xz; \ 65 | gpgconf --kill all; \ 66 | rm -rf "$GNUPGHOME" python.tar.xz.asc; \ 67 | mkdir -p /usr/src/python; \ 68 | tar --extract --directory /usr/src/python --strip-components=1 --file python.tar.xz; \ 69 | rm python.tar.xz; \ 70 | \ 71 | cd /usr/src/python; \ 72 | gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \ 73 | ./configure \ 74 | --build="$gnuArch" \ 75 | --enable-loadable-sqlite-extensions \ 76 | --enable-option-checking=fatal \ 77 | --enable-shared \ 78 | $(test "${gnuArch%%-*}" != 'riscv64' && echo '--with-lto') \ 79 | --with-ensurepip \ 80 | ; \ 81 | nproc="$(nproc)"; \ 82 | # set thread stack size to 1MB so we don't segfault before we hit sys.getrecursionlimit() 83 | # https://github.com/alpinelinux/aports/commit/2026e1259422d4e0cf92391ca2d3844356c649d0 84 | EXTRA_CFLAGS="-DTHREAD_STACK_SIZE=0x100000"; \ 85 | LDFLAGS="${LDFLAGS:--Wl},--strip-all"; \ 86 | arch="$(apk --print-arch)"; \ 87 | # https://docs.python.org/3.12/howto/perf_profiling.html 88 | # https://github.com/docker-library/python/pull/1000#issuecomment-2597021615 89 | case "$arch" in \ 90 | x86_64|aarch64) \ 91 | # only add "-mno-omit-leaf" on arches that support it 92 | # https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/x86-Options.html#index-momit-leaf-frame-pointer-2 93 | # https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/AArch64-Options.html#index-momit-leaf-frame-pointer 94 | EXTRA_CFLAGS="${EXTRA_CFLAGS:-} -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer"; \ 95 | ;; \ 96 | x86) \ 97 | # don't enable frame-pointers on 32bit x86 due to performance drop. 98 | ;; \ 99 | *) \ 100 | # other arches don't support "-mno-omit-leaf" 101 | EXTRA_CFLAGS="${EXTRA_CFLAGS:-} -fno-omit-frame-pointer"; \ 102 | ;; \ 103 | esac; \ 104 | make -j "$nproc" \ 105 | "EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \ 106 | "LDFLAGS=${LDFLAGS:-}" \ 107 | ; \ 108 | # https://github.com/docker-library/python/issues/784 109 | # prevent accidental usage of a system installed libpython of the same version 110 | rm python; \ 111 | make -j "$nproc" \ 112 | "EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \ 113 | "LDFLAGS=${LDFLAGS:--Wl},-rpath='\$\$ORIGIN/../lib'" \ 114 | python \ 115 | ; \ 116 | make install; \ 117 | \ 118 | cd /; \ 119 | rm -rf /usr/src/python; \ 120 | \ 121 | find /usr/local -depth \ 122 | \( \ 123 | \( -type d -a \( -name test -o -name tests -o -name idle_test \) \) \ 124 | -o \( -type f -a \( -name '*.pyc' -o -name '*.pyo' -o -name 'libpython*.a' \) \) \ 125 | \) -exec rm -rf '{}' + \ 126 | ; \ 127 | \ 128 | find /usr/local -type f -executable -not \( -name '*tkinter*' \) -exec scanelf --needed --nobanner --format '%n#p' '{}' ';' \ 129 | | tr ',' '\n' \ 130 | | sort -u \ 131 | | awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \ 132 | | xargs -rt apk add --no-network --virtual .python-rundeps \ 133 | ; \ 134 | apk del --no-network .build-deps; \ 135 | \ 136 | export PYTHONDONTWRITEBYTECODE=1; \ 137 | python3 --version; \ 138 | pip3 --version 139 | 140 | # make some useful symlinks that are expected to exist ("/usr/local/bin/python" and friends) 141 | RUN set -eux; \ 142 | for src in idle3 pip3 pydoc3 python3 python3-config; do \ 143 | dst="$(echo "$src" | tr -d 3)"; \ 144 | [ -s "/usr/local/bin/$src" ]; \ 145 | [ ! -e "/usr/local/bin/$dst" ]; \ 146 | ln -svT "$src" "/usr/local/bin/$dst"; \ 147 | done 148 | 149 | CMD ["python3"] 150 | -------------------------------------------------------------------------------- /3.12/alpine3.23/Dockerfile: -------------------------------------------------------------------------------- 1 | # 2 | # NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh" 3 | # 4 | # PLEASE DO NOT EDIT IT DIRECTLY. 5 | # 6 | 7 | FROM alpine:3.23 8 | 9 | # ensure local python is preferred over distribution python 10 | ENV PATH /usr/local/bin:$PATH 11 | 12 | # cannot remove LANG even though https://bugs.python.org/issue19846 is fixed 13 | # last attempted removal of LANG broke many users: 14 | # https://github.com/docker-library/python/pull/570 15 | ENV LANG C.UTF-8 16 | 17 | # runtime dependencies 18 | RUN set -eux; \ 19 | apk add --no-cache \ 20 | ca-certificates \ 21 | tzdata \ 22 | ; 23 | 24 | ENV GPG_KEY 7169605F62C751356D054A26A821E680E5FA6305 25 | ENV PYTHON_VERSION 3.12.12 26 | ENV PYTHON_SHA256 fb85a13414b028c49ba18bbd523c2d055a30b56b18b92ce454ea2c51edc656c4 27 | 28 | RUN set -eux; \ 29 | \ 30 | apk add --no-cache --virtual .build-deps \ 31 | bluez-dev \ 32 | bzip2-dev \ 33 | dpkg-dev dpkg \ 34 | findutils \ 35 | gcc \ 36 | gdbm-dev \ 37 | gnupg \ 38 | libc-dev \ 39 | libffi-dev \ 40 | libnsl-dev \ 41 | libtirpc-dev \ 42 | linux-headers \ 43 | make \ 44 | ncurses-dev \ 45 | openssl-dev \ 46 | pax-utils \ 47 | readline-dev \ 48 | sqlite-dev \ 49 | tar \ 50 | tcl-dev \ 51 | tk \ 52 | tk-dev \ 53 | util-linux-dev \ 54 | xz \ 55 | xz-dev \ 56 | zlib-dev \ 57 | ; \ 58 | \ 59 | wget -O python.tar.xz "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz"; \ 60 | echo "$PYTHON_SHA256 *python.tar.xz" | sha256sum -c -; \ 61 | wget -O python.tar.xz.asc "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz.asc"; \ 62 | GNUPGHOME="$(mktemp -d)"; export GNUPGHOME; \ 63 | gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$GPG_KEY"; \ 64 | gpg --batch --verify python.tar.xz.asc python.tar.xz; \ 65 | gpgconf --kill all; \ 66 | rm -rf "$GNUPGHOME" python.tar.xz.asc; \ 67 | mkdir -p /usr/src/python; \ 68 | tar --extract --directory /usr/src/python --strip-components=1 --file python.tar.xz; \ 69 | rm python.tar.xz; \ 70 | \ 71 | cd /usr/src/python; \ 72 | gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \ 73 | ./configure \ 74 | --build="$gnuArch" \ 75 | --enable-loadable-sqlite-extensions \ 76 | --enable-option-checking=fatal \ 77 | --enable-shared \ 78 | $(test "${gnuArch%%-*}" != 'riscv64' && echo '--with-lto') \ 79 | --with-ensurepip \ 80 | ; \ 81 | nproc="$(nproc)"; \ 82 | # set thread stack size to 1MB so we don't segfault before we hit sys.getrecursionlimit() 83 | # https://github.com/alpinelinux/aports/commit/2026e1259422d4e0cf92391ca2d3844356c649d0 84 | EXTRA_CFLAGS="-DTHREAD_STACK_SIZE=0x100000"; \ 85 | LDFLAGS="${LDFLAGS:--Wl},--strip-all"; \ 86 | arch="$(apk --print-arch)"; \ 87 | # https://docs.python.org/3.12/howto/perf_profiling.html 88 | # https://github.com/docker-library/python/pull/1000#issuecomment-2597021615 89 | case "$arch" in \ 90 | x86_64|aarch64) \ 91 | # only add "-mno-omit-leaf" on arches that support it 92 | # https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/x86-Options.html#index-momit-leaf-frame-pointer-2 93 | # https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/AArch64-Options.html#index-momit-leaf-frame-pointer 94 | EXTRA_CFLAGS="${EXTRA_CFLAGS:-} -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer"; \ 95 | ;; \ 96 | x86) \ 97 | # don't enable frame-pointers on 32bit x86 due to performance drop. 98 | ;; \ 99 | *) \ 100 | # other arches don't support "-mno-omit-leaf" 101 | EXTRA_CFLAGS="${EXTRA_CFLAGS:-} -fno-omit-frame-pointer"; \ 102 | ;; \ 103 | esac; \ 104 | make -j "$nproc" \ 105 | "EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \ 106 | "LDFLAGS=${LDFLAGS:-}" \ 107 | ; \ 108 | # https://github.com/docker-library/python/issues/784 109 | # prevent accidental usage of a system installed libpython of the same version 110 | rm python; \ 111 | make -j "$nproc" \ 112 | "EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \ 113 | "LDFLAGS=${LDFLAGS:--Wl},-rpath='\$\$ORIGIN/../lib'" \ 114 | python \ 115 | ; \ 116 | make install; \ 117 | \ 118 | cd /; \ 119 | rm -rf /usr/src/python; \ 120 | \ 121 | find /usr/local -depth \ 122 | \( \ 123 | \( -type d -a \( -name test -o -name tests -o -name idle_test \) \) \ 124 | -o \( -type f -a \( -name '*.pyc' -o -name '*.pyo' -o -name 'libpython*.a' \) \) \ 125 | \) -exec rm -rf '{}' + \ 126 | ; \ 127 | \ 128 | find /usr/local -type f -executable -not \( -name '*tkinter*' \) -exec scanelf --needed --nobanner --format '%n#p' '{}' ';' \ 129 | | tr ',' '\n' \ 130 | | sort -u \ 131 | | awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \ 132 | | xargs -rt apk add --no-network --virtual .python-rundeps \ 133 | ; \ 134 | apk del --no-network .build-deps; \ 135 | \ 136 | export PYTHONDONTWRITEBYTECODE=1; \ 137 | python3 --version; \ 138 | pip3 --version 139 | 140 | # make some useful symlinks that are expected to exist ("/usr/local/bin/python" and friends) 141 | RUN set -eux; \ 142 | for src in idle3 pip3 pydoc3 python3 python3-config; do \ 143 | dst="$(echo "$src" | tr -d 3)"; \ 144 | [ -s "/usr/local/bin/$src" ]; \ 145 | [ ! -e "/usr/local/bin/$dst" ]; \ 146 | ln -svT "$src" "/usr/local/bin/$dst"; \ 147 | done 148 | 149 | CMD ["python3"] 150 | -------------------------------------------------------------------------------- /3.13/slim-trixie/Dockerfile: -------------------------------------------------------------------------------- 1 | # 2 | # NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh" 3 | # 4 | # PLEASE DO NOT EDIT IT DIRECTLY. 5 | # 6 | 7 | FROM debian:trixie-slim 8 | 9 | # ensure local python is preferred over distribution python 10 | ENV PATH /usr/local/bin:$PATH 11 | 12 | # runtime dependencies 13 | RUN set -eux; \ 14 | apt-get update; \ 15 | apt-get install -y --no-install-recommends \ 16 | ca-certificates \ 17 | netbase \ 18 | tzdata \ 19 | ; \ 20 | apt-get dist-clean 21 | 22 | ENV GPG_KEY 7169605F62C751356D054A26A821E680E5FA6305 23 | ENV PYTHON_VERSION 3.13.11 24 | ENV PYTHON_SHA256 16ede7bb7cdbfa895d11b0642fa0e523f291e6487194d53cf6d3b338c3a17ea2 25 | 26 | RUN set -eux; \ 27 | \ 28 | savedAptMark="$(apt-mark showmanual)"; \ 29 | apt-get update; \ 30 | apt-get install -y --no-install-recommends \ 31 | dpkg-dev \ 32 | gcc \ 33 | gnupg \ 34 | libbluetooth-dev \ 35 | libbz2-dev \ 36 | libc6-dev \ 37 | libdb-dev \ 38 | libffi-dev \ 39 | libgdbm-dev \ 40 | liblzma-dev \ 41 | libncursesw5-dev \ 42 | libreadline-dev \ 43 | libsqlite3-dev \ 44 | libssl-dev \ 45 | make \ 46 | tk-dev \ 47 | uuid-dev \ 48 | wget \ 49 | xz-utils \ 50 | zlib1g-dev \ 51 | ; \ 52 | \ 53 | wget -O python.tar.xz "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz"; \ 54 | echo "$PYTHON_SHA256 *python.tar.xz" | sha256sum -c -; \ 55 | wget -O python.tar.xz.asc "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz.asc"; \ 56 | GNUPGHOME="$(mktemp -d)"; export GNUPGHOME; \ 57 | gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$GPG_KEY"; \ 58 | gpg --batch --verify python.tar.xz.asc python.tar.xz; \ 59 | gpgconf --kill all; \ 60 | rm -rf "$GNUPGHOME" python.tar.xz.asc; \ 61 | mkdir -p /usr/src/python; \ 62 | tar --extract --directory /usr/src/python --strip-components=1 --file python.tar.xz; \ 63 | rm python.tar.xz; \ 64 | \ 65 | cd /usr/src/python; \ 66 | gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \ 67 | ./configure \ 68 | --build="$gnuArch" \ 69 | --enable-loadable-sqlite-extensions \ 70 | --enable-optimizations \ 71 | --enable-option-checking=fatal \ 72 | --enable-shared \ 73 | $(test "${gnuArch%%-*}" != 'riscv64' && echo '--with-lto') \ 74 | --with-ensurepip \ 75 | ; \ 76 | nproc="$(nproc)"; \ 77 | EXTRA_CFLAGS="$(dpkg-buildflags --get CFLAGS)"; \ 78 | LDFLAGS="$(dpkg-buildflags --get LDFLAGS)"; \ 79 | LDFLAGS="${LDFLAGS:--Wl},--strip-all"; \ 80 | arch="$(dpkg --print-architecture)"; arch="${arch##*-}"; \ 81 | # https://docs.python.org/3.12/howto/perf_profiling.html 82 | # https://github.com/docker-library/python/pull/1000#issuecomment-2597021615 83 | case "$arch" in \ 84 | amd64|arm64) \ 85 | # only add "-mno-omit-leaf" on arches that support it 86 | # https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/x86-Options.html#index-momit-leaf-frame-pointer-2 87 | # https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/AArch64-Options.html#index-momit-leaf-frame-pointer 88 | EXTRA_CFLAGS="${EXTRA_CFLAGS:-} -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer"; \ 89 | ;; \ 90 | i386) \ 91 | # don't enable frame-pointers on 32bit x86 due to performance drop. 92 | ;; \ 93 | *) \ 94 | # other arches don't support "-mno-omit-leaf" 95 | EXTRA_CFLAGS="${EXTRA_CFLAGS:-} -fno-omit-frame-pointer"; \ 96 | ;; \ 97 | esac; \ 98 | make -j "$nproc" \ 99 | "EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \ 100 | "LDFLAGS=${LDFLAGS:-}" \ 101 | ; \ 102 | # https://github.com/docker-library/python/issues/784 103 | # prevent accidental usage of a system installed libpython of the same version 104 | rm python; \ 105 | make -j "$nproc" \ 106 | "EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \ 107 | "LDFLAGS=${LDFLAGS:--Wl},-rpath='\$\$ORIGIN/../lib'" \ 108 | python \ 109 | ; \ 110 | make install; \ 111 | \ 112 | cd /; \ 113 | rm -rf /usr/src/python; \ 114 | \ 115 | find /usr/local -depth \ 116 | \( \ 117 | \( -type d -a \( -name test -o -name tests -o -name idle_test \) \) \ 118 | -o \( -type f -a \( -name '*.pyc' -o -name '*.pyo' -o -name 'libpython*.a' \) \) \ 119 | \) -exec rm -rf '{}' + \ 120 | ; \ 121 | \ 122 | ldconfig; \ 123 | \ 124 | apt-mark auto '.*' > /dev/null; \ 125 | apt-mark manual $savedAptMark; \ 126 | find /usr/local -type f -executable -not \( -name '*tkinter*' \) -exec ldd '{}' ';' \ 127 | | awk '/=>/ { so = $(NF-1); if (index(so, "/usr/local/") == 1) { next }; gsub("^/(usr/)?", "", so); printf "*%s\n", so }' \ 128 | | sort -u \ 129 | | xargs -rt dpkg-query --search \ 130 | # https://manpages.debian.org/bookworm/dpkg/dpkg-query.1.en.html#S (we ignore diversions and it'll be really unusual for more than one package to provide any given .so file) 131 | | awk 'sub(":$", "", $1) { print $1 }' \ 132 | | sort -u \ 133 | | xargs -r apt-mark manual \ 134 | ; \ 135 | apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ 136 | apt-get dist-clean; \ 137 | \ 138 | export PYTHONDONTWRITEBYTECODE=1; \ 139 | python3 --version; \ 140 | pip3 --version 141 | 142 | # make some useful symlinks that are expected to exist ("/usr/local/bin/python" and friends) 143 | RUN set -eux; \ 144 | for src in idle3 pip3 pydoc3 python3 python3-config; do \ 145 | dst="$(echo "$src" | tr -d 3)"; \ 146 | [ -s "/usr/local/bin/$src" ]; \ 147 | [ ! -e "/usr/local/bin/$dst" ]; \ 148 | ln -svT "$src" "/usr/local/bin/$dst"; \ 149 | done 150 | 151 | CMD ["python3"] 152 | -------------------------------------------------------------------------------- /3.13/slim-bookworm/Dockerfile: -------------------------------------------------------------------------------- 1 | # 2 | # NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh" 3 | # 4 | # PLEASE DO NOT EDIT IT DIRECTLY. 5 | # 6 | 7 | FROM debian:bookworm-slim 8 | 9 | # ensure local python is preferred over distribution python 10 | ENV PATH /usr/local/bin:$PATH 11 | 12 | # runtime dependencies 13 | RUN set -eux; \ 14 | apt-get update; \ 15 | apt-get install -y --no-install-recommends \ 16 | ca-certificates \ 17 | netbase \ 18 | tzdata \ 19 | ; \ 20 | rm -rf /var/lib/apt/lists/* 21 | 22 | ENV GPG_KEY 7169605F62C751356D054A26A821E680E5FA6305 23 | ENV PYTHON_VERSION 3.13.11 24 | ENV PYTHON_SHA256 16ede7bb7cdbfa895d11b0642fa0e523f291e6487194d53cf6d3b338c3a17ea2 25 | 26 | RUN set -eux; \ 27 | \ 28 | savedAptMark="$(apt-mark showmanual)"; \ 29 | apt-get update; \ 30 | apt-get install -y --no-install-recommends \ 31 | dpkg-dev \ 32 | gcc \ 33 | gnupg \ 34 | libbluetooth-dev \ 35 | libbz2-dev \ 36 | libc6-dev \ 37 | libdb-dev \ 38 | libffi-dev \ 39 | libgdbm-dev \ 40 | liblzma-dev \ 41 | libncursesw5-dev \ 42 | libreadline-dev \ 43 | libsqlite3-dev \ 44 | libssl-dev \ 45 | make \ 46 | tk-dev \ 47 | uuid-dev \ 48 | wget \ 49 | xz-utils \ 50 | zlib1g-dev \ 51 | ; \ 52 | \ 53 | wget -O python.tar.xz "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz"; \ 54 | echo "$PYTHON_SHA256 *python.tar.xz" | sha256sum -c -; \ 55 | wget -O python.tar.xz.asc "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz.asc"; \ 56 | GNUPGHOME="$(mktemp -d)"; export GNUPGHOME; \ 57 | gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$GPG_KEY"; \ 58 | gpg --batch --verify python.tar.xz.asc python.tar.xz; \ 59 | gpgconf --kill all; \ 60 | rm -rf "$GNUPGHOME" python.tar.xz.asc; \ 61 | mkdir -p /usr/src/python; \ 62 | tar --extract --directory /usr/src/python --strip-components=1 --file python.tar.xz; \ 63 | rm python.tar.xz; \ 64 | \ 65 | cd /usr/src/python; \ 66 | gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \ 67 | ./configure \ 68 | --build="$gnuArch" \ 69 | --enable-loadable-sqlite-extensions \ 70 | --enable-optimizations \ 71 | --enable-option-checking=fatal \ 72 | --enable-shared \ 73 | $(test "${gnuArch%%-*}" != 'riscv64' && echo '--with-lto') \ 74 | --with-ensurepip \ 75 | ; \ 76 | nproc="$(nproc)"; \ 77 | EXTRA_CFLAGS="$(dpkg-buildflags --get CFLAGS)"; \ 78 | LDFLAGS="$(dpkg-buildflags --get LDFLAGS)"; \ 79 | LDFLAGS="${LDFLAGS:--Wl},--strip-all"; \ 80 | arch="$(dpkg --print-architecture)"; arch="${arch##*-}"; \ 81 | # https://docs.python.org/3.12/howto/perf_profiling.html 82 | # https://github.com/docker-library/python/pull/1000#issuecomment-2597021615 83 | case "$arch" in \ 84 | amd64|arm64) \ 85 | # only add "-mno-omit-leaf" on arches that support it 86 | # https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/x86-Options.html#index-momit-leaf-frame-pointer-2 87 | # https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/AArch64-Options.html#index-momit-leaf-frame-pointer 88 | EXTRA_CFLAGS="${EXTRA_CFLAGS:-} -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer"; \ 89 | ;; \ 90 | i386) \ 91 | # don't enable frame-pointers on 32bit x86 due to performance drop. 92 | ;; \ 93 | *) \ 94 | # other arches don't support "-mno-omit-leaf" 95 | EXTRA_CFLAGS="${EXTRA_CFLAGS:-} -fno-omit-frame-pointer"; \ 96 | ;; \ 97 | esac; \ 98 | make -j "$nproc" \ 99 | "EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \ 100 | "LDFLAGS=${LDFLAGS:-}" \ 101 | ; \ 102 | # https://github.com/docker-library/python/issues/784 103 | # prevent accidental usage of a system installed libpython of the same version 104 | rm python; \ 105 | make -j "$nproc" \ 106 | "EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \ 107 | "LDFLAGS=${LDFLAGS:--Wl},-rpath='\$\$ORIGIN/../lib'" \ 108 | python \ 109 | ; \ 110 | make install; \ 111 | \ 112 | cd /; \ 113 | rm -rf /usr/src/python; \ 114 | \ 115 | find /usr/local -depth \ 116 | \( \ 117 | \( -type d -a \( -name test -o -name tests -o -name idle_test \) \) \ 118 | -o \( -type f -a \( -name '*.pyc' -o -name '*.pyo' -o -name 'libpython*.a' \) \) \ 119 | \) -exec rm -rf '{}' + \ 120 | ; \ 121 | \ 122 | ldconfig; \ 123 | \ 124 | apt-mark auto '.*' > /dev/null; \ 125 | apt-mark manual $savedAptMark; \ 126 | find /usr/local -type f -executable -not \( -name '*tkinter*' \) -exec ldd '{}' ';' \ 127 | | awk '/=>/ { so = $(NF-1); if (index(so, "/usr/local/") == 1) { next }; gsub("^/(usr/)?", "", so); printf "*%s\n", so }' \ 128 | | sort -u \ 129 | | xargs -rt dpkg-query --search \ 130 | # https://manpages.debian.org/bookworm/dpkg/dpkg-query.1.en.html#S (we ignore diversions and it'll be really unusual for more than one package to provide any given .so file) 131 | | awk 'sub(":$", "", $1) { print $1 }' \ 132 | | sort -u \ 133 | | xargs -r apt-mark manual \ 134 | ; \ 135 | apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ 136 | rm -rf /var/lib/apt/lists/*; \ 137 | \ 138 | export PYTHONDONTWRITEBYTECODE=1; \ 139 | python3 --version; \ 140 | pip3 --version 141 | 142 | # make some useful symlinks that are expected to exist ("/usr/local/bin/python" and friends) 143 | RUN set -eux; \ 144 | for src in idle3 pip3 pydoc3 python3 python3-config; do \ 145 | dst="$(echo "$src" | tr -d 3)"; \ 146 | [ -s "/usr/local/bin/$src" ]; \ 147 | [ ! -e "/usr/local/bin/$dst" ]; \ 148 | ln -svT "$src" "/usr/local/bin/$dst"; \ 149 | done 150 | 151 | CMD ["python3"] 152 | -------------------------------------------------------------------------------- /3.12/slim-trixie/Dockerfile: -------------------------------------------------------------------------------- 1 | # 2 | # NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh" 3 | # 4 | # PLEASE DO NOT EDIT IT DIRECTLY. 5 | # 6 | 7 | FROM debian:trixie-slim 8 | 9 | # ensure local python is preferred over distribution python 10 | ENV PATH /usr/local/bin:$PATH 11 | 12 | # cannot remove LANG even though https://bugs.python.org/issue19846 is fixed 13 | # last attempted removal of LANG broke many users: 14 | # https://github.com/docker-library/python/pull/570 15 | ENV LANG C.UTF-8 16 | 17 | # runtime dependencies 18 | RUN set -eux; \ 19 | apt-get update; \ 20 | apt-get install -y --no-install-recommends \ 21 | ca-certificates \ 22 | netbase \ 23 | tzdata \ 24 | ; \ 25 | apt-get dist-clean 26 | 27 | ENV GPG_KEY 7169605F62C751356D054A26A821E680E5FA6305 28 | ENV PYTHON_VERSION 3.12.12 29 | ENV PYTHON_SHA256 fb85a13414b028c49ba18bbd523c2d055a30b56b18b92ce454ea2c51edc656c4 30 | 31 | RUN set -eux; \ 32 | \ 33 | savedAptMark="$(apt-mark showmanual)"; \ 34 | apt-get update; \ 35 | apt-get install -y --no-install-recommends \ 36 | dpkg-dev \ 37 | gcc \ 38 | gnupg \ 39 | libbluetooth-dev \ 40 | libbz2-dev \ 41 | libc6-dev \ 42 | libdb-dev \ 43 | libffi-dev \ 44 | libgdbm-dev \ 45 | liblzma-dev \ 46 | libncursesw5-dev \ 47 | libreadline-dev \ 48 | libsqlite3-dev \ 49 | libssl-dev \ 50 | make \ 51 | tk-dev \ 52 | uuid-dev \ 53 | wget \ 54 | xz-utils \ 55 | zlib1g-dev \ 56 | ; \ 57 | \ 58 | wget -O python.tar.xz "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz"; \ 59 | echo "$PYTHON_SHA256 *python.tar.xz" | sha256sum -c -; \ 60 | wget -O python.tar.xz.asc "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz.asc"; \ 61 | GNUPGHOME="$(mktemp -d)"; export GNUPGHOME; \ 62 | gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$GPG_KEY"; \ 63 | gpg --batch --verify python.tar.xz.asc python.tar.xz; \ 64 | gpgconf --kill all; \ 65 | rm -rf "$GNUPGHOME" python.tar.xz.asc; \ 66 | mkdir -p /usr/src/python; \ 67 | tar --extract --directory /usr/src/python --strip-components=1 --file python.tar.xz; \ 68 | rm python.tar.xz; \ 69 | \ 70 | cd /usr/src/python; \ 71 | gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \ 72 | ./configure \ 73 | --build="$gnuArch" \ 74 | --enable-loadable-sqlite-extensions \ 75 | --enable-optimizations \ 76 | --enable-option-checking=fatal \ 77 | --enable-shared \ 78 | $(test "${gnuArch%%-*}" != 'riscv64' && echo '--with-lto') \ 79 | --with-ensurepip \ 80 | ; \ 81 | nproc="$(nproc)"; \ 82 | EXTRA_CFLAGS="$(dpkg-buildflags --get CFLAGS)"; \ 83 | LDFLAGS="$(dpkg-buildflags --get LDFLAGS)"; \ 84 | LDFLAGS="${LDFLAGS:--Wl},--strip-all"; \ 85 | arch="$(dpkg --print-architecture)"; arch="${arch##*-}"; \ 86 | # https://docs.python.org/3.12/howto/perf_profiling.html 87 | # https://github.com/docker-library/python/pull/1000#issuecomment-2597021615 88 | case "$arch" in \ 89 | amd64|arm64) \ 90 | # only add "-mno-omit-leaf" on arches that support it 91 | # https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/x86-Options.html#index-momit-leaf-frame-pointer-2 92 | # https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/AArch64-Options.html#index-momit-leaf-frame-pointer 93 | EXTRA_CFLAGS="${EXTRA_CFLAGS:-} -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer"; \ 94 | ;; \ 95 | i386) \ 96 | # don't enable frame-pointers on 32bit x86 due to performance drop. 97 | ;; \ 98 | *) \ 99 | # other arches don't support "-mno-omit-leaf" 100 | EXTRA_CFLAGS="${EXTRA_CFLAGS:-} -fno-omit-frame-pointer"; \ 101 | ;; \ 102 | esac; \ 103 | make -j "$nproc" \ 104 | "EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \ 105 | "LDFLAGS=${LDFLAGS:-}" \ 106 | ; \ 107 | # https://github.com/docker-library/python/issues/784 108 | # prevent accidental usage of a system installed libpython of the same version 109 | rm python; \ 110 | make -j "$nproc" \ 111 | "EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \ 112 | "LDFLAGS=${LDFLAGS:--Wl},-rpath='\$\$ORIGIN/../lib'" \ 113 | python \ 114 | ; \ 115 | make install; \ 116 | \ 117 | cd /; \ 118 | rm -rf /usr/src/python; \ 119 | \ 120 | find /usr/local -depth \ 121 | \( \ 122 | \( -type d -a \( -name test -o -name tests -o -name idle_test \) \) \ 123 | -o \( -type f -a \( -name '*.pyc' -o -name '*.pyo' -o -name 'libpython*.a' \) \) \ 124 | \) -exec rm -rf '{}' + \ 125 | ; \ 126 | \ 127 | ldconfig; \ 128 | \ 129 | apt-mark auto '.*' > /dev/null; \ 130 | apt-mark manual $savedAptMark; \ 131 | find /usr/local -type f -executable -not \( -name '*tkinter*' \) -exec ldd '{}' ';' \ 132 | | awk '/=>/ { so = $(NF-1); if (index(so, "/usr/local/") == 1) { next }; gsub("^/(usr/)?", "", so); printf "*%s\n", so }' \ 133 | | sort -u \ 134 | | xargs -rt dpkg-query --search \ 135 | # https://manpages.debian.org/bookworm/dpkg/dpkg-query.1.en.html#S (we ignore diversions and it'll be really unusual for more than one package to provide any given .so file) 136 | | awk 'sub(":$", "", $1) { print $1 }' \ 137 | | sort -u \ 138 | | xargs -r apt-mark manual \ 139 | ; \ 140 | apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ 141 | apt-get dist-clean; \ 142 | \ 143 | export PYTHONDONTWRITEBYTECODE=1; \ 144 | python3 --version; \ 145 | pip3 --version 146 | 147 | # make some useful symlinks that are expected to exist ("/usr/local/bin/python" and friends) 148 | RUN set -eux; \ 149 | for src in idle3 pip3 pydoc3 python3 python3-config; do \ 150 | dst="$(echo "$src" | tr -d 3)"; \ 151 | [ -s "/usr/local/bin/$src" ]; \ 152 | [ ! -e "/usr/local/bin/$dst" ]; \ 153 | ln -svT "$src" "/usr/local/bin/$dst"; \ 154 | done 155 | 156 | CMD ["python3"] 157 | -------------------------------------------------------------------------------- /3.12/slim-bookworm/Dockerfile: -------------------------------------------------------------------------------- 1 | # 2 | # NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh" 3 | # 4 | # PLEASE DO NOT EDIT IT DIRECTLY. 5 | # 6 | 7 | FROM debian:bookworm-slim 8 | 9 | # ensure local python is preferred over distribution python 10 | ENV PATH /usr/local/bin:$PATH 11 | 12 | # cannot remove LANG even though https://bugs.python.org/issue19846 is fixed 13 | # last attempted removal of LANG broke many users: 14 | # https://github.com/docker-library/python/pull/570 15 | ENV LANG C.UTF-8 16 | 17 | # runtime dependencies 18 | RUN set -eux; \ 19 | apt-get update; \ 20 | apt-get install -y --no-install-recommends \ 21 | ca-certificates \ 22 | netbase \ 23 | tzdata \ 24 | ; \ 25 | rm -rf /var/lib/apt/lists/* 26 | 27 | ENV GPG_KEY 7169605F62C751356D054A26A821E680E5FA6305 28 | ENV PYTHON_VERSION 3.12.12 29 | ENV PYTHON_SHA256 fb85a13414b028c49ba18bbd523c2d055a30b56b18b92ce454ea2c51edc656c4 30 | 31 | RUN set -eux; \ 32 | \ 33 | savedAptMark="$(apt-mark showmanual)"; \ 34 | apt-get update; \ 35 | apt-get install -y --no-install-recommends \ 36 | dpkg-dev \ 37 | gcc \ 38 | gnupg \ 39 | libbluetooth-dev \ 40 | libbz2-dev \ 41 | libc6-dev \ 42 | libdb-dev \ 43 | libffi-dev \ 44 | libgdbm-dev \ 45 | liblzma-dev \ 46 | libncursesw5-dev \ 47 | libreadline-dev \ 48 | libsqlite3-dev \ 49 | libssl-dev \ 50 | make \ 51 | tk-dev \ 52 | uuid-dev \ 53 | wget \ 54 | xz-utils \ 55 | zlib1g-dev \ 56 | ; \ 57 | \ 58 | wget -O python.tar.xz "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz"; \ 59 | echo "$PYTHON_SHA256 *python.tar.xz" | sha256sum -c -; \ 60 | wget -O python.tar.xz.asc "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz.asc"; \ 61 | GNUPGHOME="$(mktemp -d)"; export GNUPGHOME; \ 62 | gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$GPG_KEY"; \ 63 | gpg --batch --verify python.tar.xz.asc python.tar.xz; \ 64 | gpgconf --kill all; \ 65 | rm -rf "$GNUPGHOME" python.tar.xz.asc; \ 66 | mkdir -p /usr/src/python; \ 67 | tar --extract --directory /usr/src/python --strip-components=1 --file python.tar.xz; \ 68 | rm python.tar.xz; \ 69 | \ 70 | cd /usr/src/python; \ 71 | gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \ 72 | ./configure \ 73 | --build="$gnuArch" \ 74 | --enable-loadable-sqlite-extensions \ 75 | --enable-optimizations \ 76 | --enable-option-checking=fatal \ 77 | --enable-shared \ 78 | $(test "${gnuArch%%-*}" != 'riscv64' && echo '--with-lto') \ 79 | --with-ensurepip \ 80 | ; \ 81 | nproc="$(nproc)"; \ 82 | EXTRA_CFLAGS="$(dpkg-buildflags --get CFLAGS)"; \ 83 | LDFLAGS="$(dpkg-buildflags --get LDFLAGS)"; \ 84 | LDFLAGS="${LDFLAGS:--Wl},--strip-all"; \ 85 | arch="$(dpkg --print-architecture)"; arch="${arch##*-}"; \ 86 | # https://docs.python.org/3.12/howto/perf_profiling.html 87 | # https://github.com/docker-library/python/pull/1000#issuecomment-2597021615 88 | case "$arch" in \ 89 | amd64|arm64) \ 90 | # only add "-mno-omit-leaf" on arches that support it 91 | # https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/x86-Options.html#index-momit-leaf-frame-pointer-2 92 | # https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/AArch64-Options.html#index-momit-leaf-frame-pointer 93 | EXTRA_CFLAGS="${EXTRA_CFLAGS:-} -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer"; \ 94 | ;; \ 95 | i386) \ 96 | # don't enable frame-pointers on 32bit x86 due to performance drop. 97 | ;; \ 98 | *) \ 99 | # other arches don't support "-mno-omit-leaf" 100 | EXTRA_CFLAGS="${EXTRA_CFLAGS:-} -fno-omit-frame-pointer"; \ 101 | ;; \ 102 | esac; \ 103 | make -j "$nproc" \ 104 | "EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \ 105 | "LDFLAGS=${LDFLAGS:-}" \ 106 | ; \ 107 | # https://github.com/docker-library/python/issues/784 108 | # prevent accidental usage of a system installed libpython of the same version 109 | rm python; \ 110 | make -j "$nproc" \ 111 | "EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \ 112 | "LDFLAGS=${LDFLAGS:--Wl},-rpath='\$\$ORIGIN/../lib'" \ 113 | python \ 114 | ; \ 115 | make install; \ 116 | \ 117 | cd /; \ 118 | rm -rf /usr/src/python; \ 119 | \ 120 | find /usr/local -depth \ 121 | \( \ 122 | \( -type d -a \( -name test -o -name tests -o -name idle_test \) \) \ 123 | -o \( -type f -a \( -name '*.pyc' -o -name '*.pyo' -o -name 'libpython*.a' \) \) \ 124 | \) -exec rm -rf '{}' + \ 125 | ; \ 126 | \ 127 | ldconfig; \ 128 | \ 129 | apt-mark auto '.*' > /dev/null; \ 130 | apt-mark manual $savedAptMark; \ 131 | find /usr/local -type f -executable -not \( -name '*tkinter*' \) -exec ldd '{}' ';' \ 132 | | awk '/=>/ { so = $(NF-1); if (index(so, "/usr/local/") == 1) { next }; gsub("^/(usr/)?", "", so); printf "*%s\n", so }' \ 133 | | sort -u \ 134 | | xargs -rt dpkg-query --search \ 135 | # https://manpages.debian.org/bookworm/dpkg/dpkg-query.1.en.html#S (we ignore diversions and it'll be really unusual for more than one package to provide any given .so file) 136 | | awk 'sub(":$", "", $1) { print $1 }' \ 137 | | sort -u \ 138 | | xargs -r apt-mark manual \ 139 | ; \ 140 | apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ 141 | rm -rf /var/lib/apt/lists/*; \ 142 | \ 143 | export PYTHONDONTWRITEBYTECODE=1; \ 144 | python3 --version; \ 145 | pip3 --version 146 | 147 | # make some useful symlinks that are expected to exist ("/usr/local/bin/python" and friends) 148 | RUN set -eux; \ 149 | for src in idle3 pip3 pydoc3 python3 python3-config; do \ 150 | dst="$(echo "$src" | tr -d 3)"; \ 151 | [ -s "/usr/local/bin/$src" ]; \ 152 | [ ! -e "/usr/local/bin/$dst" ]; \ 153 | ln -svT "$src" "/usr/local/bin/$dst"; \ 154 | done 155 | 156 | CMD ["python3"] 157 | -------------------------------------------------------------------------------- /versions.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -Eeuo pipefail 3 | shopt -s nullglob 4 | 5 | cd "$(dirname "$(readlink -f "$BASH_SOURCE")")" 6 | 7 | versions=( "$@" ) 8 | if [ ${#versions[@]} -eq 0 ]; then 9 | versions=( */ ) 10 | json='{}' 11 | else 12 | json="$(< versions.json)" 13 | fi 14 | versions=( "${versions[@]%/}" ) 15 | 16 | declare -A checksums=() 17 | check_file() { 18 | local dirVersion="$1"; shift 19 | local fullVersion="$1"; shift 20 | local type="${1:-source}" # "source" or "windows" 21 | 22 | local filename="Python-$fullVersion.tar.xz" 23 | if [ "$type" = 'windows' ]; then 24 | filename="python-$fullVersion-amd64.exe" 25 | fi 26 | local url="https://www.python.org/ftp/python/$dirVersion/$filename" 27 | 28 | local sigstore 29 | if sigstore="$( 30 | wget -qO- -o/dev/null "$url.sigstore" \ 31 | | jq -r ' 32 | .messageSignature.messageDigest 33 | | if .algorithm != "SHA2_256" then 34 | error("sigstore bundle not using SHA2_256") 35 | else .digest end 36 | ' 37 | )" && [ -n "$sigstore" ]; then 38 | sigstore="$(base64 -d <<<"$sigstore" | hexdump -ve '/1 "%02x"')" 39 | checksums["$fullVersion"]="$(jq <<<"${checksums["$fullVersion"]:-null}" --arg type "$type" --arg sha256 "$sigstore" '.[$type].sha256 = $sha256')" 40 | return 0 41 | fi 42 | 43 | # TODO is this even necessary/useful? the sigstore-based version above is *much* faster, supports all current versions (not just 3.12+ like this), *and* should be more reliable 🤔 44 | local sbom 45 | if sbom="$( 46 | wget -qO- -o/dev/null "$url.spdx.json" \ 47 | | jq --arg filename "$filename" ' 48 | first( 49 | .packages[] 50 | | select( 51 | .name == "CPython" 52 | and .packageFileName == $filename 53 | ) 54 | ) 55 | | .checksums 56 | | map({ 57 | key: (.algorithm // empty | ascii_downcase), 58 | value: (.checksumValue // empty), 59 | }) 60 | | if length < 1 then 61 | error("no checksums found for \($filename)") 62 | else . end 63 | | from_entries 64 | | if has("sha256") then . else 65 | error("missing sha256 for \($filename); have \(.)") 66 | end 67 | ' 68 | )" && [ -n "sbom" ]; then 69 | checksums["$fullVersion"]="$(jq <<<"${checksums["$fullVersion"]:-null}" --arg type "$type" --argjson sums "$sbom" '.[$type] += $sums')" 70 | return 0 71 | fi 72 | 73 | if ! wget -q -O /dev/null -o /dev/null --spider "$url"; then 74 | return 1 75 | fi 76 | 77 | return 0 78 | } 79 | 80 | for version in "${versions[@]}"; do 81 | rcVersion="${version%-rc}" 82 | export version rcVersion 83 | 84 | rcGrepV='-v' 85 | if [ "$rcVersion" != "$version" ]; then 86 | rcGrepV= 87 | fi 88 | 89 | possibles=( $( 90 | { 91 | git ls-remote --tags https://github.com/python/cpython.git "refs/tags/v${rcVersion}.*" \ 92 | | sed -r 's!^.*refs/tags/v([0-9a-z.]+).*$!\1!' \ 93 | | grep $rcGrepV -E -- '[a-zA-Z]+' \ 94 | || : 95 | 96 | # this page has a very aggressive varnish cache in front of it, which is why we also scrape tags from GitHub 97 | wget -qO- 'https://www.python.org/ftp/python/' \ 98 | | grep '&2 150 | exit 1 151 | fi 152 | 153 | ensurepipVersions="$( 154 | wget -qO- "https://github.com/python/cpython/raw/v$fullVersion/Lib/ensurepip/__init__.py" \ 155 | | grep -E '^[^[:space:]]+_VERSION[[:space:]]*=' 156 | )" 157 | 158 | # Note: We don't extract the pip version here, since our policy is now to use the pip version 159 | # that is installed during the Python build (which is the version bundled in ensurepip), and 160 | # to not support overriding it. 161 | 162 | # TODO remove setuptools version handling entirely once Python 3.11 is EOL 163 | setuptoolsVersion="$(sed -nre 's/^_SETUPTOOLS_VERSION[[:space:]]*=[[:space:]]*"(.*?)".*/\1/p' <<<"$ensurepipVersions")" 164 | case "$rcVersion" in 165 | 3.10 | 3.11) 166 | if [ -z "$setuptoolsVersion" ]; then 167 | echo >&2 "error: $version: missing setuptools version" 168 | exit 1 169 | fi 170 | if ! wget -q -O /dev/null -o /dev/null --spider "https://pypi.org/pypi/setuptools/$setuptoolsVersion/json"; then 171 | echo >&2 "error: $version: setuptools version ($setuptoolsVersion) seems to be invalid?" 172 | exit 1 173 | fi 174 | ;; 175 | 176 | *) 177 | # https://github.com/python/cpython/issues/95299 -> https://github.com/python/cpython/commit/ece20dba120a1a4745721c49f8d7389d4b1ee2a7 178 | if [ -n "$setuptoolsVersion" ]; then 179 | echo >&2 "error: $version: unexpected setuptools: $setuptoolsVersion" 180 | exit 1 181 | fi 182 | ;; 183 | esac 184 | 185 | echo "$version: $fullVersion" 186 | 187 | export fullVersion pipVersion setuptoolsVersion hasWindows 188 | doc="$(jq -nc ' 189 | { 190 | version: env.fullVersion, 191 | variants: [ 192 | ( 193 | "trixie", 194 | "bookworm", 195 | empty 196 | | ., "slim-" + .), # https://github.com/docker-library/ruby/pull/142#issuecomment-320012893 197 | ( 198 | "3.23", 199 | "3.22", 200 | empty 201 | | "alpine" + .), 202 | if env.hasWindows != "" then 203 | ( 204 | "ltsc2025", 205 | "ltsc2022", 206 | empty 207 | | "windows/windowsservercore-" + .) 208 | else empty end 209 | ], 210 | } + if env.setuptoolsVersion != "" then { 211 | setuptools: { 212 | version: env.setuptoolsVersion, 213 | }, 214 | } else {} end 215 | ')" 216 | 217 | if [ -n "${checksums["$fullVersion"]:-}" ]; then 218 | doc="$(jq <<<"$doc" -c --argjson checksums "${checksums["$fullVersion"]}" '.checksums = $checksums')" 219 | fi 220 | 221 | json="$(jq <<<"$json" -c --argjson doc "$doc" '.[env.version] = $doc')" 222 | done 223 | 224 | jq <<<"$json" -S . > versions.json 225 | -------------------------------------------------------------------------------- /Dockerfile-linux.template: -------------------------------------------------------------------------------- 1 | {{ 2 | def is_alpine: 3 | env.variant | startswith("alpine") 4 | ; 5 | def is_slim: 6 | env.variant | startswith("slim-") 7 | ; 8 | def rcVersion: 9 | env.version | rtrimstr("-rc") 10 | ; 11 | def clean_apt: 12 | # TODO once bookworm is EOL, remove this and just hard-code "apt-get dist-clean" instead 13 | if env.variant | contains("bookworm") then 14 | "rm -rf /var/lib/apt/lists/*" 15 | else "apt-get dist-clean" end 16 | -}} 17 | {{ if is_alpine then ( -}} 18 | FROM alpine:{{ env.variant | ltrimstr("alpine") }} 19 | {{ ) elif is_slim then ( -}} 20 | FROM debian:{{ env.variant | ltrimstr("slim-") }}-slim 21 | {{ ) else ( -}} 22 | FROM buildpack-deps:{{ env.variant }} 23 | {{ ) end -}} 24 | 25 | # ensure local python is preferred over distribution python 26 | ENV PATH /usr/local/bin:$PATH 27 | 28 | {{ if rcVersion | IN("3.10", "3.11", "3.12") then ( -}} 29 | {{ # only set LANG on versions less than 3.13 -}} 30 | # cannot remove LANG even though https://bugs.python.org/issue19846 is fixed 31 | # last attempted removal of LANG broke many users: 32 | # https://github.com/docker-library/python/pull/570 33 | ENV LANG C.UTF-8 34 | 35 | {{ ) else "" end -}} 36 | # runtime dependencies 37 | {{ if is_alpine then ( -}} 38 | RUN set -eux; \ 39 | apk add --no-cache \ 40 | ca-certificates \ 41 | tzdata \ 42 | ; 43 | {{ ) else ( -}} 44 | RUN set -eux; \ 45 | apt-get update; \ 46 | apt-get install -y --no-install-recommends \ 47 | {{ if is_slim then ( -}} 48 | ca-certificates \ 49 | netbase \ 50 | tzdata \ 51 | {{ ) else ( -}} 52 | libbluetooth-dev \ 53 | tk-dev \ 54 | uuid-dev \ 55 | {{ ) end -}} 56 | ; \ 57 | {{ clean_apt }} 58 | {{ ) end -}} 59 | 60 | {{ 61 | def should_pgp: 62 | # https://github.com/docker-library/python/issues/977 63 | # https://peps.python.org/pep-0761/ 64 | # https://discuss.python.org/t/pep-761-deprecating-pgp-signatures-for-cpython-artifacts/67180 65 | rcVersion | IN("3.10", "3.11", "3.12", "3.13") 66 | -}} 67 | {{ if should_pgp then ( -}} 68 | ENV GPG_KEY {{ 69 | { 70 | # gpg: key 64E628F8D684696D: public key "Pablo Galindo Salgado " imported 71 | "3.10": "A035C8C19219BA821ECEA86B64E628F8D684696D", 72 | # https://peps.python.org/pep-0619/#release-manager-and-crew 73 | 74 | # gpg: key 64E628F8D684696D: public key "Pablo Galindo Salgado " imported 75 | "3.11": "A035C8C19219BA821ECEA86B64E628F8D684696D", 76 | # https://peps.python.org/pep-0664/#release-manager-and-crew 77 | 78 | # gpg: key A821E680E5FA6305: public key "Thomas Wouters " imported 79 | "3.12": "7169605F62C751356D054A26A821E680E5FA6305", 80 | # https://peps.python.org/pep-0693/#release-manager-and-crew 81 | 82 | # gpg: key A821E680E5FA6305: public key "Thomas Wouters " imported 83 | "3.13": "7169605F62C751356D054A26A821E680E5FA6305", 84 | # https://peps.python.org/pep-0719/#release-manager-and-crew 85 | }[rcVersion] 86 | }} 87 | {{ ) else "" end -}} 88 | ENV PYTHON_VERSION {{ .version }} 89 | {{ if .checksums.source.sha256 then ( -}} 90 | ENV PYTHON_SHA256 {{ .checksums.source.sha256 }} 91 | {{ ) else "" end -}} 92 | 93 | RUN set -eux; \ 94 | \ 95 | {{ def build_deps: [ 96 | if is_alpine then 97 | "bluez-dev", 98 | "bzip2-dev", 99 | "dpkg-dev dpkg", 100 | "findutils", 101 | "gcc", 102 | "gdbm-dev", 103 | "gnupg", 104 | "libc-dev", 105 | "libffi-dev", 106 | "libnsl-dev", 107 | "libtirpc-dev", 108 | "linux-headers", 109 | "make", 110 | "ncurses-dev", 111 | "openssl-dev", 112 | "pax-utils", 113 | "readline-dev", 114 | "sqlite-dev", 115 | "tar", 116 | "tcl-dev", 117 | "tk", 118 | "tk-dev", 119 | "util-linux-dev", 120 | "xz", 121 | "xz-dev", 122 | "zlib-dev", 123 | if IN(env.version; "3.10", "3.11", "3.12", "3.13") then empty else 124 | "zstd-dev" 125 | end, 126 | empty 127 | else 128 | if is_slim then 129 | "dpkg-dev", 130 | "gcc", 131 | "gnupg", 132 | "libbluetooth-dev", 133 | "libbz2-dev", 134 | "libc6-dev", 135 | "libdb-dev", 136 | "libffi-dev", 137 | "libgdbm-dev", 138 | "liblzma-dev", 139 | "libncursesw5-dev", 140 | "libreadline-dev", 141 | "libsqlite3-dev", 142 | "libssl-dev", 143 | "make", 144 | "tk-dev", 145 | "uuid-dev", 146 | "wget", 147 | "xz-utils", 148 | "zlib1g-dev", 149 | empty 150 | else empty end, 151 | if IN(env.version; "3.10", "3.11", "3.12", "3.13") then empty else 152 | "libzstd-dev" 153 | end, 154 | empty 155 | end 156 | ] -}} 157 | {{ build_deps | if length > 0 then sort | ( -}} 158 | {{ if is_alpine then ( -}} 159 | apk add --no-cache --virtual .build-deps \ 160 | {{ map( -}} 161 | {{ . }} \ 162 | {{ ) | add -}} 163 | ; \ 164 | \ 165 | {{ ) else ( -}} 166 | savedAptMark="$(apt-mark showmanual)"; \ 167 | apt-get update; \ 168 | apt-get install -y --no-install-recommends \ 169 | {{ map( -}} 170 | {{ . }} \ 171 | {{ ) | add -}} 172 | ; \ 173 | \ 174 | {{ ) end -}} 175 | {{ ) else "" end -}} 176 | wget -O python.tar.xz "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz"; \ 177 | {{ if .checksums.source.sha256 then ( -}} 178 | echo "$PYTHON_SHA256 *python.tar.xz" | sha256sum -c -; \ 179 | {{ ) else "" end -}} 180 | {{ if should_pgp then ( -}} 181 | wget -O python.tar.xz.asc "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz.asc"; \ 182 | GNUPGHOME="$(mktemp -d)"; export GNUPGHOME; \ 183 | gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$GPG_KEY"; \ 184 | gpg --batch --verify python.tar.xz.asc python.tar.xz; \ 185 | gpgconf --kill all; \ 186 | rm -rf "$GNUPGHOME" python.tar.xz.asc; \ 187 | {{ ) else "" end -}} 188 | mkdir -p /usr/src/python; \ 189 | tar --extract --directory /usr/src/python --strip-components=1 --file python.tar.xz; \ 190 | rm python.tar.xz; \ 191 | \ 192 | cd /usr/src/python; \ 193 | gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \ 194 | ./configure \ 195 | --build="$gnuArch" \ 196 | --enable-loadable-sqlite-extensions \ 197 | {{ 198 | # https://github.com/docker-library/python/pull/980 (fixing PGO runs tests that fail, but shouldn't) 199 | # https://github.com/python/cpython/issues/90548 (alpine failures; not likely to be fixed any time soon) 200 | if is_alpine then "" else ( 201 | -}} 202 | --enable-optimizations \ 203 | {{ ) end -}} 204 | --enable-option-checking=fatal \ 205 | --enable-shared \ 206 | {{ # skip LTO on riscv64: https://github.com/docker-library/python/pull/935, https://github.com/docker-library/python/pull/1038 -}} 207 | $(test "${gnuArch%%-*}" != 'riscv64' && echo '--with-lto') \ 208 | --with-ensurepip \ 209 | ; \ 210 | nproc="$(nproc)"; \ 211 | {{ if is_alpine then ( -}} 212 | # set thread stack size to 1MB so we don't segfault before we hit sys.getrecursionlimit() 213 | # https://github.com/alpinelinux/aports/commit/2026e1259422d4e0cf92391ca2d3844356c649d0 214 | EXTRA_CFLAGS="-DTHREAD_STACK_SIZE=0x100000"; \ 215 | {{ ) else ( -}} 216 | EXTRA_CFLAGS="$(dpkg-buildflags --get CFLAGS)"; \ 217 | LDFLAGS="$(dpkg-buildflags --get LDFLAGS)"; \ 218 | {{ ) end -}} 219 | {{ if is_slim or is_alpine then ( -}} 220 | LDFLAGS="${LDFLAGS:--Wl},--strip-all"; \ 221 | {{ ) else "" end -}} 222 | {{ 223 | # Enabling frame-pointers only makes sense for Python 3.12 and newer as those have perf profiler support 224 | if rcVersion | IN("3.10", "3.11") then "" else ( 225 | -}} 226 | {{ if is_alpine then ( -}} 227 | arch="$(apk --print-arch)"; \ 228 | {{ ) else ( -}} 229 | arch="$(dpkg --print-architecture)"; arch="${arch##*-}"; \ 230 | {{ ) end -}} 231 | # https://docs.python.org/3.12/howto/perf_profiling.html 232 | # https://github.com/docker-library/python/pull/1000#issuecomment-2597021615 233 | case "$arch" in \ 234 | {{ if is_alpine then ( -}} 235 | x86_64|aarch64) \ 236 | {{ ) else ( -}} 237 | amd64|arm64) \ 238 | {{ ) end -}} 239 | # only add "-mno-omit-leaf" on arches that support it 240 | # https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/x86-Options.html#index-momit-leaf-frame-pointer-2 241 | # https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/AArch64-Options.html#index-momit-leaf-frame-pointer 242 | EXTRA_CFLAGS="${EXTRA_CFLAGS:-} -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer"; \ 243 | ;; \ 244 | {{ if is_alpine then ( -}} 245 | x86) \ 246 | {{ ) else ( -}} 247 | i386) \ 248 | {{ ) end -}} 249 | # don't enable frame-pointers on 32bit x86 due to performance drop. 250 | ;; \ 251 | *) \ 252 | # other arches don't support "-mno-omit-leaf" 253 | EXTRA_CFLAGS="${EXTRA_CFLAGS:-} -fno-omit-frame-pointer"; \ 254 | ;; \ 255 | esac; \ 256 | {{ ) end -}} 257 | make -j "$nproc" \ 258 | "EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \ 259 | "LDFLAGS=${LDFLAGS:-}" \ 260 | ; \ 261 | # https://github.com/docker-library/python/issues/784 262 | # prevent accidental usage of a system installed libpython of the same version 263 | rm python; \ 264 | make -j "$nproc" \ 265 | "EXTRA_CFLAGS=${EXTRA_CFLAGS:-}" \ 266 | "LDFLAGS=${LDFLAGS:--Wl},-rpath='\$\$ORIGIN/../lib'" \ 267 | python \ 268 | ; \ 269 | make install; \ 270 | {{ if is_alpine or is_slim then "" else ( -}} 271 | \ 272 | # enable GDB to load debugging data: https://github.com/docker-library/python/pull/701 273 | bin="$(readlink -ve /usr/local/bin/python3)"; \ 274 | dir="$(dirname "$bin")"; \ 275 | mkdir -p "/usr/share/gdb/auto-load/$dir"; \ 276 | cp -vL Tools/gdb/libpython.py "/usr/share/gdb/auto-load/$bin-gdb.py"; \ 277 | {{ ) end -}} 278 | \ 279 | cd /; \ 280 | rm -rf /usr/src/python; \ 281 | \ 282 | find /usr/local -depth \ 283 | \( \ 284 | \( -type d -a \( -name test -o -name tests -o -name idle_test \) \) \ 285 | -o \( -type f -a \( -name '*.pyc' -o -name '*.pyo' -o -name 'libpython*.a' \) \) \ 286 | \) -exec rm -rf '{}' + \ 287 | ; \ 288 | \ 289 | {{ if is_alpine and (build_deps | length > 0) then ( -}} 290 | find /usr/local -type f -executable -not \( -name '*tkinter*' \) -exec scanelf --needed --nobanner --format '%n#p' '{}' ';' \ 291 | | tr ',' '\n' \ 292 | | sort -u \ 293 | | awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \ 294 | | xargs -rt apk add --no-network --virtual .python-rundeps \ 295 | ; \ 296 | apk del --no-network .build-deps; \ 297 | {{ ) else ( -}} 298 | ldconfig; \ 299 | {{ if build_deps | length > 0 then ( -}} 300 | \ 301 | apt-mark auto '.*' > /dev/null; \ 302 | apt-mark manual $savedAptMark; \ 303 | find /usr/local -type f -executable -not \( -name '*tkinter*' \) -exec ldd '{}' ';' \ 304 | | awk '/=>/ { so = $(NF-1); if (index(so, "/usr/local/") == 1) { next }; gsub("^/(usr/)?", "", so); printf "*%s\n", so }' \ 305 | | sort -u \ 306 | | xargs -rt dpkg-query --search \ 307 | # https://manpages.debian.org/bookworm/dpkg/dpkg-query.1.en.html#S (we ignore diversions and it'll be really unusual for more than one package to provide any given .so file) 308 | | awk 'sub(":$", "", $1) { print $1 }' \ 309 | | sort -u \ 310 | | xargs -r apt-mark manual \ 311 | ; \ 312 | apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ 313 | {{ clean_apt }}; \ 314 | {{ ) else "" end -}} 315 | {{ ) end -}} 316 | \ 317 | export PYTHONDONTWRITEBYTECODE=1; \ 318 | python3 --version; \ 319 | {{ if .setuptools then ( -}} 320 | \ 321 | pip3 install \ 322 | --disable-pip-version-check \ 323 | --no-cache-dir \ 324 | --no-compile \ 325 | {{ "setuptools==\( .setuptools.version )" | @sh }} \ 326 | # https://github.com/docker-library/python/issues/1023 327 | 'wheel<0.46' \ 328 | ; \ 329 | {{ ) else "" end -}} 330 | pip3 --version 331 | 332 | # make some useful symlinks that are expected to exist ("/usr/local/bin/python" and friends) 333 | RUN set -eux; \ 334 | for src in idle3 pip3 pydoc3 python3 python3-config; do \ 335 | dst="$(echo "$src" | tr -d 3)"; \ 336 | [ -s "/usr/local/bin/$src" ]; \ 337 | [ ! -e "/usr/local/bin/$dst" ]; \ 338 | ln -svT "$src" "/usr/local/bin/$dst"; \ 339 | done 340 | 341 | CMD ["python3"] 342 | --------------------------------------------------------------------------------