Skip to content

Commit

Permalink
Add support for Python 3.13 (#280)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
edmorley authored Oct 10, 2024
1 parent 1ecdca4 commit 46953dc
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 9 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]

### Added

- Added support for Python 3.13. ([#280](https://github.com/heroku/buildpacks-python/pull/280))

## [0.18.1] - 2024-10-01

### Changed
Expand Down
6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/layers/python.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 4 additions & 2 deletions src/python_version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -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)),
Expand All @@ -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() {
Expand Down
1 change: 1 addition & 0 deletions tests/fixtures/python_3.13/.python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.13
Empty file.
9 changes: 8 additions & 1 deletion tests/python_version_test.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 46953dc

Please sign in to comment.