Skip to content

Commit

Permalink
Chore/python 3.12 upgrade (#1996)
Browse files Browse the repository at this point in the history
  • Loading branch information
sastels authored Dec 4, 2024
1 parent 10033ac commit 992103f
Show file tree
Hide file tree
Showing 17 changed files with 139 additions and 136 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM mcr.microsoft.com/vscode/devcontainers/python:1-3.10@sha256:c5b379b09a94ac1ccb437e000dd54c96164a8322d0c53d2bcb25f225e27924e6
FROM mcr.microsoft.com/vscode/devcontainers/python:3.12

ENV POETRY_VERSION="1.7.1"

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: actions/setup-python@b64ffcaf5b410884ad320a9cfac8866006a109aa # v4.8.0
with:
python-version: '3.10'
python-version: '3.12'
- uses: actions/setup-node@1a4442cacd436585916779262731d5b162bc6ec7 # v3.8.2
with:
node-version: '16.x'
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/test_endpoints.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ jobs:
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Set up Python 3.10
- name: Set up Python 3.12
uses: actions/setup-python@b64ffcaf5b410884ad320a9cfac8866006a109aa # v4.8.0
with:
python-version: '3.10'
python-version: '3.12'

- name: Upgrade pip
run: python -m pip install --upgrade pip
Expand Down Expand Up @@ -45,7 +45,7 @@ jobs:
working-directory: ${{ github.workspace }}
shell: bash
run: |
mkdir -p "${{ github.workspace }}/env/" && cp -fR $(poetry env list | poetry env info -p)/lib/python3.10/site-packages "${{ github.workspace }}/env/"
mkdir -p "${{ github.workspace }}/env/" && cp -fR $(poetry env list | poetry env info -p)/lib/python3.12/site-packages "${{ github.workspace }}/env/"
- name: Install development .env file
working-directory: ${{ github.workspace }}
Expand All @@ -58,7 +58,7 @@ jobs:
echo "PYTHONPATH=/github/workspace/env/site-packages:${{ env.PYTHONPATH}}" >> $GITHUB_ENV
- name: Checks for new endpoints against AWS WAF rules
uses: cds-snc/notification-utils/.github/actions/waffles@52.2.2
uses: cds-snc/notification-utils/.github/actions/waffles@53.0.1
with:
app-loc: '/github/workspace'
app-libs: '/github/workspace/env/site-packages'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test_prod_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: actions/setup-python@b64ffcaf5b410884ad320a9cfac8866006a109aa # v4.8.0
with:
python-version: '3.10'
python-version: '3.12'
- uses: actions/setup-node@1a4442cacd436585916779262731d5b162bc6ec7 # v3.8.2
with:
node-version: '16.x'
Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ coverage: venv ## Create coverage report
run-dev:
poetry run flask run -p 6012 --host=localhost

.PHONY: run-gunicorn
run-gunicorn:
PORT=6012 poetry run gunicorn -c gunicorn_config.py application

.PHONY: format
format:
ruff check --select I --fix .
Expand Down
34 changes: 17 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ https://github.com/alphagov/notifications-admin
```

Languages needed
- Python 3.10
- Python 3.12
- [Node](https://nodejs.org/) 10.15.3 or greater
- [npm](https://www.npmjs.com/) 6.4.1 or greater

Expand All @@ -58,15 +58,15 @@ On OS X:

`brew install pyenv`

2. Install Python 3.10.8 or whatever is the latest
2. Install Python 3.12.7 or whatever is the latest

`pyenv install 3.10.8`
`pyenv install 3.12.7`

3. If you expect no conflicts, set `3.10.8` as you default
3. If you expect no conflicts, set `3.12.7` as you default

`pyenv global 3.10.8`
`pyenv global 3.12.7`

4. Ensure that version `3.10.8` is now the default by running
4. Ensure that version `3.12.7` is now the default by running

`python --version`

Expand All @@ -77,15 +77,15 @@ eval "$(pyenv init -)"
```
and open a new terminal.

If you are still not running Python 3.10.8 take a look here: https://github.com/pyenv/pyenv/issues/660
If you are still not running Python 3.12.7 take a look here: https://github.com/pyenv/pyenv/issues/660

5. Install `poetry`:

`pip install poetry==1.3.2`

6. Restart your terminal and make your virtual environtment:

`mkvirtualenv -p ~/.pyenv/versions/3.10.8/bin/python notifications-admin`
`mkvirtualenv -p ~/.pyenv/versions/3.12.7/bin/python notifications-admin`

7. You can now return to your environment any time by entering

Expand Down Expand Up @@ -278,7 +278,7 @@ https://github.com/alphagov/notifications-admin
```

Langages nécessaires
- Python 3.10
- Python 3.12
- [Node](https://nodejs.org/) 10.15.3 ou supérieur
- [npm](https://www.npmjs.com/) 6.4.1 ou plus
```shell
Expand All @@ -302,15 +302,15 @@ Sur macOS :

`brew install pyenv`

2. Installez Python 3.10.8 ou la dernière version
1. Installez Python 3.12.7 ou la dernière version

`pyenv install 3.10.8`
`pyenv install 3.12.7`

3. Si vous n'attendez aucun conflit, mettez `3.10.8` comme valeur par défaut
3. Si vous n'attendez aucun conflit, mettez `3.12.7` comme valeur par défaut

`pyenv global 3.10.8`
`pyenv global 3.12.7`

4. Assurez-vous que la version 3.10.8 est maintenant la version par défaut en exécutant
4. Assurez-vous que la version 3.12.7 est maintenant la version par défaut en exécutant

`python --version`

Expand All @@ -320,7 +320,7 @@ eval "$(pyenv init --path)"
eval "$(pyenv init -)"
```
et ouvrez un nouveau terminal.
Si vous n’utilisez toujours pas Python 3.10.8, jetez un coup d’œil ici : https://github.com/pyenv/pyenv/issues/660
Si vous n’utilisez toujours pas Python 3.12.7, jetez un coup d’œil ici : https://github.com/pyenv/pyenv/issues/660

5. Installez `virtualenv` :

Expand All @@ -331,12 +331,12 @@ Si vous n’utilisez toujours pas Python 3.10.8, jetez un coup d’œil ici : ht
```
export WORKON_HOME=$HOME/.virtualenvs
export PROJECT_HOME=$HOME/Devel
source ~/.pyenv/versions/3.10.8/bin/virtualenvwrapper.sh
source ~/.pyenv/versions/3.12.7/bin/virtualenvwrapper.sh
```

7. Redémarrez votre terminal et créez votre environnement virtuel :

`mkvirtualenv -p ~/.pyenv/versions/3.10.8/bin/python notifications-admin`
`mkvirtualenv -p ~/.pyenv/versions/3.12.7/bin/python notifications-admin`

8. Vous pouvez maintenant retourner dans votre environnement à tout moment en entrant

Expand Down
2 changes: 1 addition & 1 deletion ci/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.10-alpine3.18@sha256:d5ee9613c89c9bd4c4112465d2136512ea8629bce6ff15fa27144f3cc16b5c6b
FROM python:3.12.7-alpine3.20

ENV PYTHONDONTWRITEBYTECODE 1
ENV POETRY_VERSION="1.7.1"
Expand Down
4 changes: 2 additions & 2 deletions ci/Dockerfile.lambda
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ARG POETRY_VERSION="1.7.1"
ARG POETRY_VIRTUALENVS_CREATE="false"

# Build image
FROM python:3.10-alpine3.18@sha256:d5ee9613c89c9bd4c4112465d2136512ea8629bce6ff15fa27144f3cc16b5c6b as base
FROM python:3.12-alpine3.20@sha256:5049c050bdc68575a10bcb1885baa0689b6c15152d8a56a7e399fb49f783bf98 as base

ARG APP_DIR
ARG APP_VENV
Expand Down Expand Up @@ -68,7 +68,7 @@ RUN . ${APP_VENV}/bin/activate \
&& make generate-version-file

# Final image
FROM python:3.10-alpine3.18@sha256:d5ee9613c89c9bd4c4112465d2136512ea8629bce6ff15fa27144f3cc16b5c6b as lambda
FROM python:3.12-alpine3.20@sha256:5049c050bdc68575a10bcb1885baa0689b6c15152d8a56a7e399fb49f783bf98 as lambda

ARG APP_DIR
ARG APP_VENV
Expand Down
2 changes: 1 addition & 1 deletion ci/Dockerfile.test
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.10-alpine3.16@sha256:afe68972cc00883d70b3760ee0ffbb7375cf09706c122dda7063ffe64c5be21b
FROM python:3.12-alpine3.20@sha256:5049c050bdc68575a10bcb1885baa0689b6c15152d8a56a7e399fb49f783bf98

ENV PYTHONDONTWRITEBYTECODE 1

Expand Down
2 changes: 1 addition & 1 deletion mypy.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[mypy]
python_version = 3.10
python_version = 3.12

[mypy-pytest.*]
ignore_missing_imports = True
Expand Down
Loading

0 comments on commit 992103f

Please sign in to comment.