Skip to content

Commit e22ef9c

Browse files

File tree

15 files changed

+101
-4
lines changed

15 files changed

+101
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## Unreleased
44

5+
- Add support for Python 3.11 ([#1379](https://github.com/heroku/heroku-buildpack-python/pull/1379)).
56

67
## v221 (2022-10-12)
78

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ Specify a Python Runtime
6060

6161
Supported runtime options include:
6262

63+
- `python-3.11.0` on all [supported stacks](https://devcenter.heroku.com/articles/stack#stack-support-details)
6364
- `python-3.10.8` on all [supported stacks](https://devcenter.heroku.com/articles/stack#stack-support-details)
6465
- `python-3.9.15` on all [supported stacks](https://devcenter.heroku.com/articles/stack#stack-support-details)
6566
- `python-3.8.15` on Heroku-18 and Heroku-20 only

bin/default_pythons

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
# the env vars to subprocesses.
66
# shellcheck disable=2034
77

8+
LATEST_311="python-3.11.0"
89
LATEST_310="python-3.10.8"
910
LATEST_39="python-3.9.15"
1011
LATEST_38="python-3.8.15"

bin/steps/pipenv-python-version

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ if [[ -f $BUILD_DIR/Pipfile ]]; then
4646
3.10)
4747
echo "${LATEST_310}" > "${BUILD_DIR}/runtime.txt"
4848
;;
49+
3.11)
50+
echo "${LATEST_311}" > "${BUILD_DIR}/runtime.txt"
51+
;;
4952
esac
5053
fi
5154

bin/steps/python

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ function warn_if_patch_update_available() {
4545
}
4646

4747
case "${PYTHON_VERSION}" in
48+
python-3.11.*)
49+
warn_if_patch_update_available "${PYTHON_VERSION}" "${LATEST_311}"
50+
;;
4851
python-3.10.*)
4952
warn_if_patch_update_available "${PYTHON_VERSION}" "${LATEST_310}"
5053
;;

builds/runtimes/python

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ fi
2020

2121
# See: https://www.python.org/downloads/ -> "OpenPGP Public Keys"
2222
case "${VERSION}" in
23-
3.10.*)
23+
3.1[0-1].*)
2424
# https://keybase.io/pablogsal/
2525
GPG_KEY_FINGERPRINT='A035C8C19219BA821ECEA86B64E628F8D684696D'
2626
;;
@@ -85,7 +85,7 @@ if [[ "${VERSION}" != 3.7.* ]]; then
8585
)
8686
fi
8787

88-
if [[ "${VERSION}" == 3.10.* ]]; then
88+
if [[ "${VERSION}" != 3.[7-9].* ]]; then
8989
CONFIGURE_OPTS+=(
9090
# Shared builds are beneficial for a number of reasons:
9191
# - Reduces the size of the build, since it avoids the duplication between
@@ -108,6 +108,17 @@ if [[ "${VERSION}" == 3.10.* ]]; then
108108
)
109109
fi
110110

111+
if [[ "${VERSION}" == 3.11.* ]]; then
112+
CONFIGURE_OPTS+=(
113+
# Skip building the test modules, since we remove them after the build anyway.
114+
# This feature was added in Python 3.10+, however it wasn't until Python 3.11
115+
# that compatibility issues between it and PGO were fixed:
116+
# https://github.com/python/cpython/pull/29315
117+
# TODO: See if a backport of that fix would be accepted to Python 3.10.
118+
"--disable-test-modules"
119+
)
120+
fi
121+
111122
./configure "${CONFIGURE_OPTS[@]}"
112123

113124
# Using LDFLAGS we instruct the linker to omit all symbol information from the final binary
@@ -134,8 +145,8 @@ fi
134145

135146
# Remove unneeded test directories, similar to the official Docker Python images:
136147
# https://github.com/docker-library/python
137-
# TODO: Explore using --disable-test-modules once the PGO fix is in a released Python version:
138-
# https://bugs.python.org/issue45668
148+
# This is a no-op on Python 3.11+, since --disable-test-modules will have prevented
149+
# the test files from having been built in the first place.
139150
find "${OUT_PREFIX}" -depth -type d -a \( -name 'test' -o -name 'tests' -o -name 'idle_test' \) -print -exec rm -rf '{}' +
140151

141152
# The `make install` step automatically generates `.pyc` files for the stdlib, however:

builds/runtimes/python-3.11.0

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env bash
2+
# Build Path: /app/.heroku/python
3+
4+
# shellcheck source-path=SCRIPTDIR
5+
source "$(dirname "${0}")/python"
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[[source]]
2+
url = "https://pypi.org/simple"
3+
verify_ssl = true
4+
name = "pypi"
5+
6+
[packages]
7+
urllib3 = "*"
8+
9+
[dev-packages]
10+
11+
[requires]
12+
python_version = "3.11"

spec/fixtures/pipenv_python_3.11/Pipfile.lock

Lines changed: 29 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
urllib3

0 commit comments

Comments
 (0)