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

Pin Python minor version and document upgrade details #235

Merged
merged 2 commits into from
Aug 28, 2024

Conversation

chouinar
Copy link
Contributor

Changes

Pin the Python version and document details on how to upgrade

Context for reviewers

Python releases new minor versions (3.12, 3.13, etc.) every year in October. It usually takes a few weeks for all of our dependencies and tooling to also be upgraded to the latest version, causing our builds to break. There isn't much we can do except wait a few weeks and then do the upgrade (assuming no breaking changes in features we use).

However, we had some of our dependencies pinned to the major version (Python 3) so it has broken the past few years until it started working again when the dependencies got fixed. This is just getting ahead of that and making sure the upgrade to Python 3.13 doesn't cause any problems.

Testing

This change is largely documentation as the Python version used in the dockerfile + pyproject.toml already would have resolved to Python 3.12, this just makes it so it won't auto-upgrade to 3.13 when that releases in October.

@chouinar chouinar requested a review from lorenyu August 26, 2024 20:12
Copy link
Contributor

@lorenyu lorenyu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, left some suggestions

use semvar versioning, and their [minor releases](https://devguide.python.org/developer-workflow/development-cycle/#devcycle) contain
breaking changes.

We have this environment configured to use a specific minor version of python just in case anything would break when the yearly release does occur.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
We have this environment configured to use a specific minor version of python just in case anything would break when the yearly release does occur.
Pin to a specific minor version of python just in case anything would break when the yearly release does occur.


We have this environment configured to use a specific minor version of python just in case anything would break when the yearly release does occur.

We recommend as a starting point, only pin the minor versions of Python (eg. 3.12), and not the patch versions (eg. 3.12.1) as those contain bug and security fixes.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
We recommend as a starting point, only pin the minor versions of Python (eg. 3.12), and not the patch versions (eg. 3.12.1) as those contain bug and security fixes.
Only pin the minor versions of Python (eg. 3.12), and not the patch versions (eg. 3.12.1) as those contain bug and security fixes.

docs/app/README.md Outdated Show resolved Hide resolved
docs/app/README.md Outdated Show resolved Hide resolved
docs/app/README.md Outdated Show resolved Hide resolved
docs/app/README.md Outdated Show resolved Hide resolved
docs/app/README.md Outdated Show resolved Hide resolved
Comment on lines 179 to 211
## Dockerfile
The dockerfile that our API is built from specifies the Python version as the first step.
To upgrade this, simply change the version to the version you would like to use.

For example, to upgrade from 3.12 to 3.13, change the following line:
```dockerfile
FROM python:3.12-slim AS base
```
to
```dockerfile
FROM python:3.13-slim AS base
```

## Poetry
Adjust the pyproject.toml file line that specifies the version of Python used
to your new version. For example, to upgrade from 3.12 to 3.13, change it from:

```toml
[tool.poetry.dependencies]
python = "~3.12"
```

to
```toml
[tool.poetry.dependencies]
python = "~3.13"
```

You will then need to run `poetry lock --no-update` to make the lock file reflect this change.

## Misc
Some tools, include pyenv, reference the [.python-version](/app/.python-version) file in order to determine which
version of python should be used. Update this to the approach version as well.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we make this whole section more concise like:

To upgrade the Python version, make changes in the following places:
1. Local Python version (see more about managing local Python versions in [getting started](/docs/app/getting-started.md))
2. [Dockerfile](/app/Dockerfile)
    search for the line `FROM python:3.12-slim as base`
3. [pyproject.toml](/app/pyproject.toml)
    search for the line
    ```
    [tool.poetry.dependencies]
    python = "~3.12"
    ```
4. .python-version

I'm trying to think of ways to improve skimmability since this doc is pretty long and I think having a bunch of subheadings might make it harder to skim

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can minimize it a bit, but there are some important steps like in the pyproject file needing to run the Poetry command to fix the lock file.

@chouinar chouinar merged commit a29ce72 into main Aug 28, 2024
4 checks passed
@chouinar chouinar deleted the chouinar/python-version-pin branch August 28, 2024 15:37
chouinar added a commit to navapbc/simpler-grants-gov that referenced this pull request Aug 28, 2024
## Summary
Fixes #184

### Time to review: __5 mins__

## Changes proposed
Pin the Python version and document details on how to upgrade

Upgraded packages as well while I was tinkering with this

## Context for reviewers
This is mirroring changes from the template repo:
navapbc/template-application-flask#235

Python releases new minor versions (3.12, 3.13, etc.) every year in
October. It usually takes a few weeks for all of our dependencies and
tooling to also be upgraded to the latest version, causing our builds to
break. There isn't much we can do except wait a few weeks and then do
the upgrade (assuming no breaking changes in features we use).

However, we had some of our dependencies pinned to the major version
(Python 3) so it has broken the past few years until it started working
again when the dependencies got fixed. This is just getting ahead of
that and making sure the upgrade to Python 3.13 doesn't cause any
problems.

## Additional information
This change is largely documentation as the Python version used in the
dockerfile + pyproject.toml already would have resolved to Python 3.12,
this just makes it so it won't auto-upgrade to 3.13 when that releases
in October.

The package updates are all very minor - we updated them not too long
ago, mostly just cleaning up a few things like the types-requests issue
that is no longer present.
acouch pushed a commit to navapbc/simpler-grants-gov that referenced this pull request Sep 18, 2024
Fixes HHS#2035

Pin the Python version and document details on how to upgrade

Upgraded packages as well while I was tinkering with this

This is mirroring changes from the template repo:
navapbc/template-application-flask#235

Python releases new minor versions (3.12, 3.13, etc.) every year in
October. It usually takes a few weeks for all of our dependencies and
tooling to also be upgraded to the latest version, causing our builds to
break. There isn't much we can do except wait a few weeks and then do
the upgrade (assuming no breaking changes in features we use).

However, we had some of our dependencies pinned to the major version
(Python 3) so it has broken the past few years until it started working
again when the dependencies got fixed. This is just getting ahead of
that and making sure the upgrade to Python 3.13 doesn't cause any
problems.

This change is largely documentation as the Python version used in the
dockerfile + pyproject.toml already would have resolved to Python 3.12,
this just makes it so it won't auto-upgrade to 3.13 when that releases
in October.

The package updates are all very minor - we updated them not too long
ago, mostly just cleaning up a few things like the types-requests issue
that is no longer present.
acouch pushed a commit to navapbc/simpler-grants-gov that referenced this pull request Sep 18, 2024
Fixes HHS#2035

Pin the Python version and document details on how to upgrade

Upgraded packages as well while I was tinkering with this

This is mirroring changes from the template repo:
navapbc/template-application-flask#235

Python releases new minor versions (3.12, 3.13, etc.) every year in
October. It usually takes a few weeks for all of our dependencies and
tooling to also be upgraded to the latest version, causing our builds to
break. There isn't much we can do except wait a few weeks and then do
the upgrade (assuming no breaking changes in features we use).

However, we had some of our dependencies pinned to the major version
(Python 3) so it has broken the past few years until it started working
again when the dependencies got fixed. This is just getting ahead of
that and making sure the upgrade to Python 3.13 doesn't cause any
problems.

This change is largely documentation as the Python version used in the
dockerfile + pyproject.toml already would have resolved to Python 3.12,
this just makes it so it won't auto-upgrade to 3.13 when that releases
in October.

The package updates are all very minor - we updated them not too long
ago, mostly just cleaning up a few things like the types-requests issue
that is no longer present.
acouch pushed a commit to HHS/simpler-grants-gov that referenced this pull request Sep 18, 2024
…c#185)

Fixes #2035

Pin the Python version and document details on how to upgrade

Upgraded packages as well while I was tinkering with this

This is mirroring changes from the template repo:
navapbc/template-application-flask#235

Python releases new minor versions (3.12, 3.13, etc.) every year in
October. It usually takes a few weeks for all of our dependencies and
tooling to also be upgraded to the latest version, causing our builds to
break. There isn't much we can do except wait a few weeks and then do
the upgrade (assuming no breaking changes in features we use).

However, we had some of our dependencies pinned to the major version
(Python 3) so it has broken the past few years until it started working
again when the dependencies got fixed. This is just getting ahead of
that and making sure the upgrade to Python 3.13 doesn't cause any
problems.

This change is largely documentation as the Python version used in the
dockerfile + pyproject.toml already would have resolved to Python 3.12,
this just makes it so it won't auto-upgrade to 3.13 when that releases
in October.

The package updates are all very minor - we updated them not too long
ago, mostly just cleaning up a few things like the types-requests issue
that is no longer present.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants