Add support for the .python-version file
#1664
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Following on from the recent Python version refactoring in #1658, this now adds support for configuring the app's Python version using a
.python-versionfile. This file is used by several tools in the Python ecosystem (such as pyenv,actions/setup-python, uv), whereas the existingruntime.txtfile is proprietary to Heroku.This change is the classic Python buildpack equivalent of the Python CNB change here:
heroku/buildpacks-python#272
If both a
runtime.txtfile and a.python-versionfile are present, then theruntime.txtfile will take precedence. However, use of the.python-versionfile is now recommended, sinceruntime.txtwill be deprecated in the future. Both theruntime.txtfile and.python-versionfile take precedence over any Python version specified in aPipfile.lockfor Pipenv users.We support the following
.python-versionsyntax:3.13, which will then be resolved to the latest Python 3.13). (This form is recommended, since it allows for Python security updates to be pulled in without having to manually bump the version.)3.13.0)#)We don't support the following
.python-versionfeatures:python-(since this form is undocumented and will likely be deprecated by pyenv in the future)In addition, the existing
runtime.txtsupport has been updated to allow specifying just the major Python version, in order to increase feature parity between the files, and avoid confusion if users try to use the major version only syntax from.python-versionin theirruntime.txt.Closes #913.
Closes #932.
GUS-W-7671453.
GUS-W-16821357.