From 46953dcfa72c36547ede2500120ec16b42e52240 Mon Sep 17 00:00:00 2001 From: Ed Morley <501702+edmorley@users.noreply.github.com> Date: Thu, 10 Oct 2024 20:13:53 +0000 Subject: [PATCH] Add support for Python 3.13 (#280) Add support for Python 3.13, and release 3.13.0. The default Python version remains unchanged (at 3.12) for now. Release announcement: https://blog.python.org/2024/10/python-3130-final-released.html https://www.python.org/downloads/release/python-3130/ Details on what's new in Python 3.13: https://docs.python.org/3.13/whatsnew/3.13.html Binary builds: https://github.com/heroku/heroku-buildpack-python/actions/runs/11280580537 Python 3.13 readiness status of the top 360 packages on PyPI: https://pyreadiness.org/3.13/ GUS-W-14846841. --- CHANGELOG.md | 4 ++++ README.md | 6 +----- src/layers/python.rs | 2 +- src/python_version.rs | 6 ++++-- tests/fixtures/python_3.13/.python-version | 1 + tests/fixtures/python_3.13/requirements.txt | 0 tests/python_version_test.rs | 9 ++++++++- 7 files changed, 19 insertions(+), 9 deletions(-) create mode 100644 tests/fixtures/python_3.13/.python-version create mode 100644 tests/fixtures/python_3.13/requirements.txt diff --git a/CHANGELOG.md b/CHANGELOG.md index c5ee7ec..f5ee492 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] +### Added + +- Added support for Python 3.13. ([#280](https://github.com/heroku/buildpacks-python/pull/280)) + ## [0.18.1] - 2024-10-01 ### Changed diff --git a/README.md b/README.md index 237bc20..7b5762f 100644 --- a/README.md +++ b/README.md @@ -43,13 +43,9 @@ To install a different version, add a `.python-version` file to your app's root ```term $ cat .python-version -3.12 +3.13 ``` -In the future this buildpack will also support specifying the Python version using: - -- `tool.poetry.dependencies.python` in `pyproject.toml`: [#260](https://github.com/heroku/buildpacks-python/issues/260) - ## Contributing Issues and pull requests are welcome. See our [contributing guidelines](./CONTRIBUTING.md) if you would like to help. diff --git a/src/layers/python.rs b/src/layers/python.rs index 368f794..785a6c2 100644 --- a/src/layers/python.rs +++ b/src/layers/python.rs @@ -176,7 +176,7 @@ fn generate_layer_env(layer_path: &Path, python_version: &PythonVersion) -> Laye )), ) .chainable_insert(Scope::Build, ModificationBehavior::Delimiter, "CPATH", ":") - // Ensure Python uses a Unicode locate, to prevent the issues described in: + // Ensure Python uses a Unicode locale, to prevent the issues described in: // https://github.com/docker-library/python/pull/570 .chainable_insert( Scope::All, diff --git a/src/python_version.rs b/src/python_version.rs index 7ca7e61..ea6bfea 100644 --- a/src/python_version.rs +++ b/src/python_version.rs @@ -20,6 +20,7 @@ pub(crate) const LATEST_PYTHON_3_9: PythonVersion = PythonVersion::new(3, 9, 20) pub(crate) const LATEST_PYTHON_3_10: PythonVersion = PythonVersion::new(3, 10, 15); pub(crate) const LATEST_PYTHON_3_11: PythonVersion = PythonVersion::new(3, 11, 10); pub(crate) const LATEST_PYTHON_3_12: PythonVersion = PythonVersion::new(3, 12, 7); +pub(crate) const LATEST_PYTHON_3_13: PythonVersion = PythonVersion::new(3, 13, 0); /// The Python version that was requested for a project. #[derive(Clone, Debug, PartialEq)] @@ -163,7 +164,8 @@ pub(crate) fn resolve_python_version( (3, 10, None) => Ok(LATEST_PYTHON_3_10), (3, 11, None) => Ok(LATEST_PYTHON_3_11), (3, 12, None) => Ok(LATEST_PYTHON_3_12), - (3, 13.., _) | (4.., _, _) => Err(ResolvePythonVersionError::UnknownVersion( + (3, 13, None) => Ok(LATEST_PYTHON_3_13), + (3, 14.., _) | (4.., _, _) => Err(ResolvePythonVersionError::UnknownVersion( requested_python_version.clone(), )), (major, minor, Some(patch)) => Ok(PythonVersion::new(major, minor, patch)), @@ -182,7 +184,7 @@ mod tests { use super::*; const OLDEST_SUPPORTED_PYTHON_3_MINOR_VERSION: u16 = 8; - const NEWEST_SUPPORTED_PYTHON_3_MINOR_VERSION: u16 = 12; + const NEWEST_SUPPORTED_PYTHON_3_MINOR_VERSION: u16 = 13; #[test] fn python_version_url() { diff --git a/tests/fixtures/python_3.13/.python-version b/tests/fixtures/python_3.13/.python-version new file mode 100644 index 0000000..24ee5b1 --- /dev/null +++ b/tests/fixtures/python_3.13/.python-version @@ -0,0 +1 @@ +3.13 diff --git a/tests/fixtures/python_3.13/requirements.txt b/tests/fixtures/python_3.13/requirements.txt new file mode 100644 index 0000000..e69de29 diff --git a/tests/python_version_test.rs b/tests/python_version_test.rs index 91d85b7..eb7da6b 100644 --- a/tests/python_version_test.rs +++ b/tests/python_version_test.rs @@ -1,6 +1,7 @@ use crate::python_version::{ PythonVersion, DEFAULT_PYTHON_FULL_VERSION, DEFAULT_PYTHON_VERSION, LATEST_PYTHON_3_10, - LATEST_PYTHON_3_11, LATEST_PYTHON_3_12, LATEST_PYTHON_3_8, LATEST_PYTHON_3_9, + LATEST_PYTHON_3_11, LATEST_PYTHON_3_12, LATEST_PYTHON_3_13, LATEST_PYTHON_3_8, + LATEST_PYTHON_3_9, }; use crate::tests::{builder, default_build_config}; use indoc::{formatdoc, indoc}; @@ -90,6 +91,12 @@ fn python_3_12() { builds_with_python_version("tests/fixtures/python_3.12", &LATEST_PYTHON_3_12); } +#[test] +#[ignore = "integration test"] +fn python_3_13() { + builds_with_python_version("tests/fixtures/python_3.13", &LATEST_PYTHON_3_13); +} + fn builds_with_python_version(fixture_path: &str, python_version: &PythonVersion) { let PythonVersion { major,