Skip to content

Commit 8b3b0e8

Browse files
authored
Add binary build support for Heroku-26 (#2056)
Adds support for building the binaries for the upcoming Heroku-26 stack based on Ubuntu 26.04. A later PR will add support for the stack to the buildpack itself, once the Heroku build system supports Heroku-26 (since until that point we can't run Hatchet in CI anyway). The `libcrypt-dev` library had to be added to the `Dockerfile` used for binary building, since the headers package is no longer in `heroku/heroku:26-build` as it was previously only a transitive dependency in the build image, and with the upstream Ubuntu 26.04 package changes is now no longer pulled in. (From searching it doesn't appear to be widely used, so I don't think it's worth adding back to the Heroku-26 build image.) Doing so fixes this warning on Python 3.12 and older (the `crypt` module only exists in older Python versions): ``` *** WARNING: renaming "_crypt" since importing it failed: /tmp/src/build/lib.linux-x86_64-3.10/_crypt.cpython-310-x86_64-linux-gnu.so: undefined symbol: crypt ... Following modules built successfully but were removed because they could not be imported: _crypt ``` Dry-run test builds using this branch succeeded. e.g.: https://github.com/heroku/heroku-buildpack-python/actions/runs/23343385460 https://github.com/heroku/heroku-buildpack-python/actions/runs/23343379302 GUS-W-20775546.
1 parent 3303da8 commit 8b3b0e8

File tree

4 files changed

+40
-1
lines changed

4 files changed

+40
-1
lines changed

.github/workflows/build_python_runtime.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ on:
1515
- auto
1616
- heroku-22
1717
- heroku-24
18+
- heroku-26
1819
default: auto
1920
required: false
2021
dry_run:
@@ -80,3 +81,28 @@ jobs:
8081
- name: Upload Python runtime archive to S3
8182
if: (!inputs.dry_run)
8283
run: aws s3 sync ./upload "s3://${S3_BUCKET}"
84+
85+
heroku-26:
86+
if: inputs.stack == 'heroku-26' || inputs.stack == 'auto'
87+
strategy:
88+
fail-fast: false
89+
matrix:
90+
arch: ["amd64", "arm64"]
91+
runs-on: ${{ matrix.arch == 'arm64' && 'pub-hk-ubuntu-24.04-arm-xlarge' || 'pub-hk-ubuntu-24.04-xlarge' }}
92+
env:
93+
STACK_VERSION: "26"
94+
steps:
95+
- name: Checkout
96+
uses: actions/checkout@v6
97+
- name: Build Docker image
98+
run: docker build --platform="linux/${{ matrix.arch }}" --pull --tag buildenv --build-arg=STACK_VERSION builds/
99+
- name: Compile and package Python runtime
100+
run: docker run --rm --volume="${PWD}/upload:/tmp/upload" buildenv ./build_python_runtime.sh "${{ inputs.python_version }}"
101+
- name: Test Python runtime
102+
run: |
103+
RUN_IMAGE='heroku/heroku:${{ env.STACK_VERSION }}'
104+
ARCHIVE_FILENAME='python-${{ inputs.python_version }}-ubuntu-${{ env.STACK_VERSION }}.04-${{ matrix.arch }}.tar.zst'
105+
docker run --rm --volume="${PWD}/upload:/upload:ro" --volume="${PWD}/builds:/builds:ro" "${RUN_IMAGE}" /builds/test_python_runtime.sh "/upload/${ARCHIVE_FILENAME}"
106+
- name: Upload Python runtime archive to S3
107+
if: (!inputs.dry_run)
108+
run: aws s3 sync ./upload "s3://${S3_BUCKET}"

builds/Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,12 @@ ENV STACK="heroku-${STACK_VERSION}"
88
# For Heroku-24 and newer, the build image sets a non-root default `USER`.
99
USER root
1010

11+
# `libcrypt-dev` can be removed once we drop support for Python 3.12,
12+
# since the `crypt` module was removed in Python 3.13:
13+
# https://docs.python.org/3.13/whatsnew/3.13.html#whatsnew313-pep594
1114
RUN apt-get update --error-on=any \
1215
&& apt-get install -y --no-install-recommends \
16+
libcrypt-dev \
1317
libdb-dev \
1418
libreadline-dev \
1519
libsqlite3-dev \

builds/build_python_runtime.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ function abort() {
2525
}
2626

2727
case "${STACK:?}" in
28-
heroku-22 | heroku-24)
28+
heroku-22 | heroku-24 | heroku-26)
2929
SUPPORTED_PYTHON_VERSIONS=(
3030
"3.10"
3131
"3.11"

builds/test_python_runtime.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,22 @@ optional_stdlib_modules=(
6868
zlib
6969
)
7070

71+
# zstd support was added in Python 3.14:
7172
# https://docs.python.org/3.14/whatsnew/3.14.html#whatsnew314-zstandard
7273
if [[ "${major_python_version}" == "3.14" ]]; then
7374
optional_stdlib_modules+=(
7475
compression.zstd
7576
)
7677
fi
7778

79+
# crypt was removed in Python 3.13:
80+
# https://docs.python.org/3.13/whatsnew/3.13.html#whatsnew313-pep594
81+
if [[ "${major_python_version}" == +(3.10|3.11|3.12) ]]; then
82+
optional_stdlib_modules+=(
83+
crypt
84+
)
85+
fi
86+
7887
if "${INSTALL_DIR}/bin/python3" -c "import $(
7988
IFS=,
8089
echo "${optional_stdlib_modules[*]}"

0 commit comments

Comments
 (0)