Skip to content

Commit

Permalink
Update the default Python version from 3.12 to 3.13 (#299)
Browse files Browse the repository at this point in the history
Previously if an app did not specify a Python version (e.g. via a
`.python-version` file), then the buildpack would default to the latest
Python 3.12 release.

Now the buildpack will use the latest Python 3.13 release.

Apps that aren't compatible with Python 3.13 will now need to request
Python 3.12 explicitly by creating a `.python-version` file containing:
`3.12`

Note: Unlike in the classic Python buildpack, this change will affect
existing apps too, since the CNB does not perform version pinning (due
to the UX and app to app consistency issues it causes). Users are
strongly advised to never rely on the default version, and instead set
an explicit major Python version using a `.python-version` file.

See:
https://docs.python.org/3.13/whatsnew/3.13.html

GUS-W-14846979.
  • Loading branch information
edmorley authored Dec 6, 2024
1 parent 59d93ae commit a427f65
Show file tree
Hide file tree
Showing 11 changed files with 46 additions and 49 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Changed

- Updated the default Python version from 3.12 to 3.13. ([#299](https://github.com/heroku/buildpacks-python/pull/299))

## [0.19.2] - 2024-12-04

### Changed
Expand Down
6 changes: 3 additions & 3 deletions src/python_version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ use std::path::Path;
/// The Python version that will be installed if the project does not specify an explicit version.
pub(crate) const DEFAULT_PYTHON_VERSION: RequestedPythonVersion = RequestedPythonVersion {
major: 3,
minor: 12,
minor: 13,
patch: None,
origin: PythonVersionOrigin::BuildpackDefault,
};
pub(crate) const DEFAULT_PYTHON_FULL_VERSION: PythonVersion = LATEST_PYTHON_3_12;
pub(crate) const DEFAULT_PYTHON_FULL_VERSION: PythonVersion = LATEST_PYTHON_3_13;

pub(crate) const LATEST_PYTHON_3_8: PythonVersion = PythonVersion::new(3, 8, 20);
pub(crate) const LATEST_PYTHON_3_9: PythonVersion = PythonVersion::new(3, 9, 21);
Expand Down Expand Up @@ -270,7 +270,7 @@ mod tests {
.unwrap(),
RequestedPythonVersion {
major: 3,
minor: 12,
minor: 13,
patch: None,
origin: PythonVersionOrigin::BuildpackDefault
}
Expand Down
1 change: 1 addition & 0 deletions tests/fixtures/poetry_basic/.python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.13
18 changes: 9 additions & 9 deletions tests/fixtures/poetry_basic/poetry.lock

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

2 changes: 1 addition & 1 deletion tests/fixtures/poetry_basic/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
package-mode = false

[tool.poetry.dependencies]
python = "^3.12"
python = "^3.13"
typing-extensions = "*"

# This group shouldn't be installed due to us passing `--only main`.
Expand Down
6 changes: 3 additions & 3 deletions tests/fixtures/poetry_editable_git_compiled/poetry.lock

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

2 changes: 1 addition & 1 deletion tests/fixtures/poetry_editable_git_compiled/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
package-mode = false

[tool.poetry.dependencies]
python = "^3.12"
python = "^3.13"

# This requirement uses a VCS URL and `develop = true` in order to test that:
# - Git from the stack image can be found (ie: the system PATH has been correctly propagated to Poetry).
Expand Down
6 changes: 3 additions & 3 deletions tests/fixtures/poetry_outdated_lockfile/poetry.lock

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

2 changes: 1 addition & 1 deletion tests/fixtures/poetry_outdated_lockfile/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
package-mode = false

[tool.poetry.dependencies]
python = "^3.12"
python = "^3.13"

# This dependency isn't in the lockfile.
typing-extensions = "*"
14 changes: 7 additions & 7 deletions tests/pip_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ fn pip_basic_install_and_cache_reuse() {
Successfully installed typing-extensions-4.12.2
## Testing buildpack ##
CPATH=/layers/heroku_python/venv/include:/layers/heroku_python/python/include/python3.12:/layers/heroku_python/python/include
CPATH=/layers/heroku_python/venv/include:/layers/heroku_python/python/include/python3.13:/layers/heroku_python/python/include
LANG=C.UTF-8
LD_LIBRARY_PATH=/layers/heroku_python/venv/lib:/layers/heroku_python/python/lib:/layers/heroku_python/pip/lib
LIBRARY_PATH=/layers/heroku_python/venv/lib:/layers/heroku_python/python/lib:/layers/heroku_python/pip/lib
Expand All @@ -55,16 +55,16 @@ fn pip_basic_install_and_cache_reuse() {
VIRTUAL_ENV=/layers/heroku_python/venv
['',
'/layers/heroku_python/python/lib/python312.zip',
'/layers/heroku_python/python/lib/python3.12',
'/layers/heroku_python/python/lib/python3.12/lib-dynload',
'/layers/heroku_python/venv/lib/python3.12/site-packages']
'/layers/heroku_python/python/lib/python313.zip',
'/layers/heroku_python/python/lib/python3.13',
'/layers/heroku_python/python/lib/python3.13/lib-dynload',
'/layers/heroku_python/venv/lib/python3.13/site-packages']
pip {PIP_VERSION} from /layers/heroku_python/pip/lib/python3.12/site-packages/pip (python 3.12)
pip {PIP_VERSION} from /layers/heroku_python/pip/lib/python3.13/site-packages/pip (python 3.13)
Package Version
----------------- -------
typing_extensions 4.12.2
<module 'typing_extensions' from '/layers/heroku_python/venv/lib/python3.12/site-packages/typing_extensions.py'>
<module 'typing_extensions' from '/layers/heroku_python/venv/lib/python3.13/site-packages/typing_extensions.py'>
"}
);

Expand Down
34 changes: 13 additions & 21 deletions tests/poetry_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ fn poetry_basic_install_and_cache_reuse() {
context.pack_stdout,
&formatdoc! {"
[Determining Python version]
No Python version specified, using the current default of Python {DEFAULT_PYTHON_VERSION}.
We recommend setting an explicit version. In the root of your app create
a '.python-version' file, containing a Python version like '{DEFAULT_PYTHON_VERSION}'.
Using Python version {DEFAULT_PYTHON_VERSION} specified in .python-version
[Installing Python]
Installing Python {DEFAULT_PYTHON_FULL_VERSION}
Expand All @@ -39,7 +37,7 @@ fn poetry_basic_install_and_cache_reuse() {
- Installing typing-extensions (4.12.2)
## Testing buildpack ##
CPATH=/layers/heroku_python/venv/include:/layers/heroku_python/python/include/python3.12:/layers/heroku_python/python/include
CPATH=/layers/heroku_python/venv/include:/layers/heroku_python/python/include/python3.13:/layers/heroku_python/python/include
LANG=C.UTF-8
LD_LIBRARY_PATH=/layers/heroku_python/venv/lib:/layers/heroku_python/python/lib:/layers/heroku_python/poetry/lib
LIBRARY_PATH=/layers/heroku_python/venv/lib:/layers/heroku_python/python/lib:/layers/heroku_python/poetry/lib
Expand All @@ -52,14 +50,14 @@ fn poetry_basic_install_and_cache_reuse() {
VIRTUAL_ENV=/layers/heroku_python/venv
['',
'/layers/heroku_python/python/lib/python312.zip',
'/layers/heroku_python/python/lib/python3.12',
'/layers/heroku_python/python/lib/python3.12/lib-dynload',
'/layers/heroku_python/venv/lib/python3.12/site-packages']
'/layers/heroku_python/python/lib/python313.zip',
'/layers/heroku_python/python/lib/python3.13',
'/layers/heroku_python/python/lib/python3.13/lib-dynload',
'/layers/heroku_python/venv/lib/python3.13/site-packages']
Poetry (version {POETRY_VERSION})
typing-extensions 4.12.2 Backported and Experimental Type Hints for Python ...
<module 'typing_extensions' from '/layers/heroku_python/venv/lib/python3.12/site-packages/typing_extensions.py'>
<module 'typing_extensions' from '/layers/heroku_python/venv/lib/python3.13/site-packages/typing_extensions.py'>
"}
);

Expand Down Expand Up @@ -94,9 +92,7 @@ fn poetry_basic_install_and_cache_reuse() {
rebuild_context.pack_stdout,
&formatdoc! {"
[Determining Python version]
No Python version specified, using the current default of Python {DEFAULT_PYTHON_VERSION}.
We recommend setting an explicit version. In the root of your app create
a '.python-version' file, containing a Python version like '{DEFAULT_PYTHON_VERSION}'.
Using Python version {DEFAULT_PYTHON_VERSION} specified in .python-version
[Installing Python]
Using cached Python {DEFAULT_PYTHON_FULL_VERSION}
Expand Down Expand Up @@ -129,9 +125,7 @@ fn poetry_cache_invalidation_package_manager_changed() {
rebuild_context.pack_stdout,
&formatdoc! {"
[Determining Python version]
No Python version specified, using the current default of Python {DEFAULT_PYTHON_VERSION}.
We recommend setting an explicit version. In the root of your app create
a '.python-version' file, containing a Python version like '{DEFAULT_PYTHON_VERSION}'.
Using Python version {DEFAULT_PYTHON_VERSION} specified in .python-version
[Installing Python]
Using cached Python {DEFAULT_PYTHON_FULL_VERSION}
Expand Down Expand Up @@ -160,7 +154,7 @@ fn poetry_cache_invalidation_package_manager_changed() {
fn poetry_cache_previous_buildpack_version() {
let mut config = default_build_config("tests/fixtures/poetry_basic");
config.buildpacks([BuildpackReference::Other(
"docker://docker.io/heroku/buildpack-python:0.17.0".to_string(),
"docker://docker.io/heroku/buildpack-python:0.19.0".to_string(),
)]);
let rebuild_config = default_build_config("tests/fixtures/poetry_basic");

Expand All @@ -171,13 +165,11 @@ fn poetry_cache_previous_buildpack_version() {
rebuild_context.pack_stdout,
&formatdoc! {"
[Determining Python version]
No Python version specified, using the current default of Python {DEFAULT_PYTHON_VERSION}.
We recommend setting an explicit version. In the root of your app create
a '.python-version' file, containing a Python version like '{DEFAULT_PYTHON_VERSION}'.
Using Python version {DEFAULT_PYTHON_VERSION} specified in .python-version
[Installing Python]
Discarding cached Python 3.12.5 since:
- The Python version has changed from 3.12.5 to {DEFAULT_PYTHON_FULL_VERSION}
Discarding cached Python 3.13.0 since:
- The Python version has changed from 3.13.0 to {DEFAULT_PYTHON_FULL_VERSION}
Installing Python {DEFAULT_PYTHON_FULL_VERSION}
[Installing Poetry]
Expand Down

0 comments on commit a427f65

Please sign in to comment.