Skip to content

Commit

Permalink
Add support for Python 3.12 (#1490)
Browse files Browse the repository at this point in the history
And release Python 3.12.0. The default Python version remains
unchanged (at 3.11.x) for now.

Release announcement:
https://blog.python.org/2023/10/python-3120-final-now-available.html
https://www.python.org/downloads/release/python-3120/

Details on what's new in Python 3.12:
https://docs.python.org/3.12/whatsnew/3.12.html

Binary builds on GitHub Actions:
https://github.com/heroku/heroku-buildpack-python/actions/runs/6382585145

GUS-W-12345517.
GUS-W-12345519.
  • Loading branch information
edmorley authored Oct 2, 2023
1 parent 8f09642 commit 3ac9ded
Show file tree
Hide file tree
Showing 14 changed files with 75 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Unreleased

- Added support for Python 3.12. ([#1490](https://github.com/heroku/heroku-buildpack-python/pull/1490))

## v235 (2023-08-25)

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ Specify a Python Runtime

Supported runtime options include:

- `python-3.12.0` on all [supported stacks](https://devcenter.heroku.com/articles/stack#stack-support-details)
- `python-3.11.5` on all [supported stacks](https://devcenter.heroku.com/articles/stack#stack-support-details)
- `python-3.10.13` on all [supported stacks](https://devcenter.heroku.com/articles/stack#stack-support-details)
- `python-3.9.18` on all [supported stacks](https://devcenter.heroku.com/articles/stack#stack-support-details)
Expand Down
1 change: 1 addition & 0 deletions bin/default_pythons
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# the env vars to subprocesses.
# shellcheck disable=2034

LATEST_312="python-3.12.0"
LATEST_311="python-3.11.5"
LATEST_310="python-3.10.13"
LATEST_39="python-3.9.18"
Expand Down
3 changes: 3 additions & 0 deletions bin/steps/pipenv-python-version
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ if [[ -f $BUILD_DIR/Pipfile ]]; then
3.11)
echo "${LATEST_311}" > "${BUILD_DIR}/runtime.txt"
;;
3.12)
echo "${LATEST_312}" > "${BUILD_DIR}/runtime.txt"
;;
esac
fi

Expand Down
3 changes: 3 additions & 0 deletions bin/steps/python
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ function warn_if_patch_update_available() {
}

case "${PYTHON_VERSION}" in
python-3.12.*)
warn_if_patch_update_available "${PYTHON_VERSION}" "${LATEST_312}"
;;
python-3.11.*)
warn_if_patch_update_available "${PYTHON_VERSION}" "${LATEST_311}"
;;
Expand Down
8 changes: 7 additions & 1 deletion builds/build_python_runtime.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ case "${STACK}" in
"3.9"
"3.10"
"3.11"
"3.12"
)
;;
heroku-20)
Expand All @@ -28,6 +29,7 @@ case "${STACK}" in
"3.9"
"3.10"
"3.11"
"3.12"
)
;;
*)
Expand All @@ -41,6 +43,10 @@ fi

# The release keys can be found on https://www.python.org/downloads/ -> "OpenPGP Public Keys".
case "${PYTHON_MAJOR_VERSION}" in
3.12)
# https://github.com/Yhg1s.gpg
GPG_KEY_FINGERPRINT='7169605F62C751356D054A26A821E680E5FA6305'
;;
3.10|3.11)
# https://keybase.io/pablogsal/
GPG_KEY_FINGERPRINT='A035C8C19219BA821ECEA86B64E628F8D684696D'
Expand Down Expand Up @@ -115,7 +121,7 @@ if [[ "${PYTHON_MAJOR_VERSION}" != 3.[8-9] ]]; then
)
fi

if [[ "${PYTHON_MAJOR_VERSION}" == "3.11" ]]; then
if [[ "${PYTHON_MAJOR_VERSION}" == "3.11" || "${PYTHON_MAJOR_VERSION}" == "3.12" ]]; then
CONFIGURE_OPTS+=(
# Skip building the test modules, since we remove them after the build anyway.
# This feature was added in Python 3.10+, however it wasn't until Python 3.11
Expand Down
12 changes: 12 additions & 0 deletions spec/fixtures/pipenv_python_3.12/Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]
urllib3 = "*"

[dev-packages]

[requires]
python_version = "3.12"
30 changes: 30 additions & 0 deletions spec/fixtures/pipenv_python_3.12/Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions spec/fixtures/python_3.12/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
urllib3
1 change: 1 addition & 0 deletions spec/fixtures/python_3.12/runtime.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
python-3.12.0
6 changes: 6 additions & 0 deletions spec/hatchet/pipenv_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,12 @@
include_examples 'builds using Pipenv with the requested Python version', LATEST_PYTHON_3_11
end

context 'with a Pipfile.lock containing python_version 3.12' do
let(:app) { Hatchet::Runner.new('spec/fixtures/pipenv_python_3.12') }

include_examples 'builds using Pipenv with the requested Python version', LATEST_PYTHON_3_12
end

context 'with a Pipfile.lock containing python_full_version 3.10.7' do
let(:allow_failure) { false }
let(:app) { Hatchet::Runner.new('spec/fixtures/pipenv_python_full_version', allow_failure:) }
Expand Down
2 changes: 2 additions & 0 deletions spec/hatchet/python_update_warning_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,6 @@

include_examples 'warns there is a Python update available', '3.11.0', LATEST_PYTHON_3_11
end

# TODO: Add a Python 3.12.0 outdated test once Python 3.12.1 is released.
end
6 changes: 6 additions & 0 deletions spec/hatchet/python_version_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,12 @@
include_examples 'builds with the requested Python version', LATEST_PYTHON_3_11
end

context 'when runtime.txt contains python-3.12.0' do
let(:app) { Hatchet::Runner.new('spec/fixtures/python_3.12') }

include_examples 'builds with the requested Python version', LATEST_PYTHON_3_12
end

context 'when runtime.txt contains pypy3.6-7.3.2' do
let(:app) { Hatchet::Runner.new('spec/fixtures/pypy_3.6', allow_failure: true) }

Expand Down
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
LATEST_PYTHON_3_9 = '3.9.18'
LATEST_PYTHON_3_10 = '3.10.13'
LATEST_PYTHON_3_11 = '3.11.5'
LATEST_PYTHON_3_12 = '3.12.0'
DEFAULT_PYTHON_VERSION = LATEST_PYTHON_3_11

# The requirement versions are effectively buildpack constants, however, we want
Expand Down

0 comments on commit 3ac9ded

Please sign in to comment.