From a427f65003f8dd00cca7c94a55ba98858b10ec89 Mon Sep 17 00:00:00 2001 From: Ed Morley <501702+edmorley@users.noreply.github.com> Date: Fri, 6 Dec 2024 19:28:57 +0000 Subject: [PATCH] Update the default Python version from 3.12 to 3.13 (#299) 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. --- CHANGELOG.md | 4 +++ src/python_version.rs | 6 ++-- tests/fixtures/poetry_basic/.python-version | 1 + tests/fixtures/poetry_basic/poetry.lock | 18 +++++----- tests/fixtures/poetry_basic/pyproject.toml | 2 +- .../poetry_editable_git_compiled/poetry.lock | 6 ++-- .../pyproject.toml | 2 +- .../poetry_outdated_lockfile/poetry.lock | 6 ++-- .../poetry_outdated_lockfile/pyproject.toml | 2 +- tests/pip_test.rs | 14 ++++---- tests/poetry_test.rs | 34 +++++++------------ 11 files changed, 46 insertions(+), 49 deletions(-) create mode 100644 tests/fixtures/poetry_basic/.python-version diff --git a/CHANGELOG.md b/CHANGELOG.md index 24a6d6e..6ecb03d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/src/python_version.rs b/src/python_version.rs index 20fb484..9c6f94d 100644 --- a/src/python_version.rs +++ b/src/python_version.rs @@ -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); @@ -270,7 +270,7 @@ mod tests { .unwrap(), RequestedPythonVersion { major: 3, - minor: 12, + minor: 13, patch: None, origin: PythonVersionOrigin::BuildpackDefault } diff --git a/tests/fixtures/poetry_basic/.python-version b/tests/fixtures/poetry_basic/.python-version new file mode 100644 index 0000000..24ee5b1 --- /dev/null +++ b/tests/fixtures/poetry_basic/.python-version @@ -0,0 +1 @@ +3.13 diff --git a/tests/fixtures/poetry_basic/poetry.lock b/tests/fixtures/poetry_basic/poetry.lock index 4a1944d..7fe5d07 100644 --- a/tests/fixtures/poetry_basic/poetry.lock +++ b/tests/fixtures/poetry_basic/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.8.3 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.8.4 and should not be changed by hand. [[package]] name = "colorama" @@ -24,13 +24,13 @@ files = [ [[package]] name = "packaging" -version = "24.1" +version = "24.2" description = "Core utilities for Python packages" optional = false python-versions = ">=3.8" files = [ - {file = "packaging-24.1-py3-none-any.whl", hash = "sha256:5b8f2217dbdbd2f7f384c41c628544e6d52f2d0f53c6d0c3ea61aa5d1d7ff124"}, - {file = "packaging-24.1.tar.gz", hash = "sha256:026ed72c8ed3fcce5bf8950572258698927fd1dbda10a5e981cdf0ac37f4f002"}, + {file = "packaging-24.2-py3-none-any.whl", hash = "sha256:09abb1bccd265c01f4a3aa3f7a7db064b36514d2cba19a2f694fe6150451a759"}, + {file = "packaging-24.2.tar.gz", hash = "sha256:c228a6dc5e932d346bc5739379109d49e8853dd8223571c7c5b55260edc0b97f"}, ] [[package]] @@ -50,13 +50,13 @@ testing = ["pytest", "pytest-benchmark"] [[package]] name = "pytest" -version = "8.3.2" +version = "8.3.4" description = "pytest: simple powerful testing with Python" optional = false python-versions = ">=3.8" files = [ - {file = "pytest-8.3.2-py3-none-any.whl", hash = "sha256:4ba08f9ae7dcf84ded419494d229b48d0903ea6407b030eaec46df5e6a73bba5"}, - {file = "pytest-8.3.2.tar.gz", hash = "sha256:c132345d12ce551242c87269de812483f5bcc87cdbb4722e48487ba194f9fdce"}, + {file = "pytest-8.3.4-py3-none-any.whl", hash = "sha256:50e16d954148559c9a74109af1eaf0c945ba2d8f30f0a3d3335edde19788b6f6"}, + {file = "pytest-8.3.4.tar.gz", hash = "sha256:965370d062bce11e73868e0335abac31b4d3de0e82f4007408d242b4f8610761"}, ] [package.dependencies] @@ -81,5 +81,5 @@ files = [ [metadata] lock-version = "2.0" -python-versions = "^3.12" -content-hash = "2e71a7976f439ce69fc771708b83dcfc6f795072ea73a7c2de0241878cbd378a" +python-versions = "^3.13" +content-hash = "56ec6342f4a39b402d2b65bd08cfb3af4136a02bb58674df49eac8d317376a7f" diff --git a/tests/fixtures/poetry_basic/pyproject.toml b/tests/fixtures/poetry_basic/pyproject.toml index 1b21050..9fc0e83 100644 --- a/tests/fixtures/poetry_basic/pyproject.toml +++ b/tests/fixtures/poetry_basic/pyproject.toml @@ -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`. diff --git a/tests/fixtures/poetry_editable_git_compiled/poetry.lock b/tests/fixtures/poetry_editable_git_compiled/poetry.lock index ee0ac73..1779c7a 100644 --- a/tests/fixtures/poetry_editable_git_compiled/poetry.lock +++ b/tests/fixtures/poetry_editable_git_compiled/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.8.3 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.8.4 and should not be changed by hand. [[package]] name = "extension.dist" @@ -18,5 +18,5 @@ subdirectory = "tests/testdata/extension.dist" [metadata] lock-version = "2.0" -python-versions = "^3.12" -content-hash = "8c333a07a0702492e3f7715c3372860fafc8c2aed2dde0e9ee5241e7723a5da2" +python-versions = "^3.13" +content-hash = "f6e97a6813e7715d3d1f4498a9d65dddad85905c4cb42e9ab492e00e5319ab3a" diff --git a/tests/fixtures/poetry_editable_git_compiled/pyproject.toml b/tests/fixtures/poetry_editable_git_compiled/pyproject.toml index b86182c..aa6be2a 100644 --- a/tests/fixtures/poetry_editable_git_compiled/pyproject.toml +++ b/tests/fixtures/poetry_editable_git_compiled/pyproject.toml @@ -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). diff --git a/tests/fixtures/poetry_outdated_lockfile/poetry.lock b/tests/fixtures/poetry_outdated_lockfile/poetry.lock index 1034779..e9d42af 100644 --- a/tests/fixtures/poetry_outdated_lockfile/poetry.lock +++ b/tests/fixtures/poetry_outdated_lockfile/poetry.lock @@ -1,7 +1,7 @@ -# This file is automatically @generated by Poetry 1.8.3 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.8.4 and should not be changed by hand. package = [] [metadata] lock-version = "2.0" -python-versions = "^3.12" -content-hash = "34e39677d8527182346093002688d17a5d2fc204b9eb3e094b2e6ac519028228" +python-versions = "^3.13" +content-hash = "f01b553f3895e558c34b4f10542e05acdef39bf0527c8090bd136d914dc73f94" diff --git a/tests/fixtures/poetry_outdated_lockfile/pyproject.toml b/tests/fixtures/poetry_outdated_lockfile/pyproject.toml index f0367e3..032945f 100644 --- a/tests/fixtures/poetry_outdated_lockfile/pyproject.toml +++ b/tests/fixtures/poetry_outdated_lockfile/pyproject.toml @@ -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 = "*" diff --git a/tests/pip_test.rs b/tests/pip_test.rs index 73451e3..0feea07 100644 --- a/tests/pip_test.rs +++ b/tests/pip_test.rs @@ -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 @@ -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 - + "} ); diff --git a/tests/poetry_test.rs b/tests/poetry_test.rs index 4b24cfe..81b7a4d 100644 --- a/tests/poetry_test.rs +++ b/tests/poetry_test.rs @@ -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} @@ -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 @@ -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 ... - + "} ); @@ -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} @@ -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} @@ -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"); @@ -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]