Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for the .python-version file #1664

Merged
merged 1 commit into from
Oct 14, 2024
Merged

Conversation

edmorley
Copy link
Member

@edmorley edmorley commented Oct 14, 2024

Following on from the recent Python version refactoring in #1658, this now adds support for configuring the app's Python version using a .python-version file. This file is used by several tools in the Python ecosystem (such as pyenv, actions/setup-python, uv), whereas the existing runtime.txt file 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.txt file and a .python-version file are present, then the runtime.txt file will take precedence. However, use of the .python-version file is now recommended, since runtime.txt will be deprecated in the future. Both the runtime.txt file and .python-version file take precedence over any Python version specified in a Pipfile.lock for Pipenv users.

We support the following .python-version syntax:

  • Major Python version (e.g. 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.)
  • Exact Python version (e.g. 3.13.0)
  • Comments (lines starting with #)
  • Blank lines

We don't support the following .python-version features:

  • Specifying multiple Python versions
  • Prefixing versions with python- (since this form is undocumented and will likely be deprecated by pyenv in the future)

In addition, the existing runtime.txt support 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-version in their runtime.txt.

Closes #913.
Closes #932.
GUS-W-7671453.
GUS-W-16821357.

@edmorley edmorley self-assigned this Oct 14, 2024
@edmorley edmorley force-pushed the python-version-file branch from 1f42ba7 to bb32ece Compare October 14, 2024 13:45
@edmorley edmorley marked this pull request as ready for review October 14, 2024 13:49
@edmorley edmorley requested a review from a team as a code owner October 14, 2024 13:49
Following on from the recent Python version refactoring, this now adds
support for configuring the app's Python version using a
`.python-version` file. This file is used by several tools in the Python
ecosystem (such as pyenv, `actions/setup-python`, uv), whereas the
existing `runtime.txt` file 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.txt` file and a `.python-version` file are present,
then the `runtime.txt` file will take precedence. However, use of the
`.python-version` file is now recommended, since `runtime.txt` will
be deprecated in the future. Both the `runtime.txt` file and
`.python-version` file take precedence over any Python version specified
in a `Pipfile.lock` for Pipenv users.

We support the following `.python-version` syntax:
- Major Python version (e.g. `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.)
- Exact Python version (e.g. `3.13.0`)
- Comments (lines starting with `#`)
- Blank lines

We don't support the following `.python-version` features:
- Specifying multiple Python versions
- Prefixing versions with `python-` (since this form is undocumented
  and will likely be deprecated by pyenv in the future)

In addition, the existing `runtime.txt` support 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-version` in their
`runtime.txt`.

Refs #913.
Refs #932.
GUS-W-7671453.
GUS-W-16821357.
@edmorley edmorley force-pushed the python-version-file branch from bb32ece to d3a9e24 Compare October 14, 2024 13:59
@edmorley edmorley enabled auto-merge (squash) October 14, 2024 14:00
@edmorley edmorley merged commit d9bdeab into main Oct 14, 2024
7 checks passed
@edmorley edmorley deleted the python-version-file branch October 14, 2024 14:04
@heroku-linguist heroku-linguist bot mentioned this pull request Oct 14, 2024
@edmorley
Copy link
Member Author

@edmorley
Copy link
Member Author

Created entry in the public roadmap:
heroku/roadmap#317

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants