From b488056b63597f5a790ef263ec6e71d582c482f9 Mon Sep 17 00:00:00 2001 From: Jelmer Draaijer Date: Mon, 18 Mar 2024 19:55:00 +0100 Subject: [PATCH] Upgrade Python to version 3.12 --- .github/workflows/ci.yml | 6 +++--- .github/workflows/django-issue-checker.yml | 2 +- .github/workflows/pre-commit-autoupdate.yml | 2 +- .github/workflows/update-changelog.yml | 2 +- .github/workflows/update-contributors.yml | 2 +- .pre-commit-config.yaml | 4 ++-- .readthedocs.yaml | 2 +- CONTRIBUTING.md | 8 ++++---- README.md | 2 +- docs/deployment-on-pythonanywhere.rst | 2 +- docs/developing-locally.rst | 4 ++-- hooks/pre_gen_project.py | 2 +- pyproject.toml | 2 +- setup.py | 2 +- tox.ini | 2 +- {{cookiecutter.project_slug}}/.drone.yml | 4 ++-- {{cookiecutter.project_slug}}/.github/workflows/ci.yml | 4 ++-- {{cookiecutter.project_slug}}/.gitlab-ci.yml | 4 ++-- {{cookiecutter.project_slug}}/.pre-commit-config.yaml | 2 +- {{cookiecutter.project_slug}}/.readthedocs.yml | 2 +- {{cookiecutter.project_slug}}/.travis.yml | 4 ++-- .../compose/local/django/Dockerfile | 2 +- .../compose/local/docs/Dockerfile | 2 +- .../compose/production/django/Dockerfile | 2 +- {{cookiecutter.project_slug}}/pyproject.toml | 4 ++-- {{cookiecutter.project_slug}}/runtime.txt | 2 +- 26 files changed, 38 insertions(+), 38 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 82f7887f..1db46291 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,7 +25,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: - python-version: "3.11" + python-version: "3.12" cache: pip - name: Install dependencies run: pip install -r requirements.txt @@ -56,7 +56,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: - python-version: "3.11" + python-version: "3.12" cache: pip - name: Install dependencies run: pip install -r requirements.txt @@ -100,7 +100,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: - python-version: "3.11" + python-version: "3.12" cache: pip cache-dependency-path: | requirements.txt diff --git a/.github/workflows/django-issue-checker.yml b/.github/workflows/django-issue-checker.yml index e1b36f29..2185da81 100644 --- a/.github/workflows/django-issue-checker.yml +++ b/.github/workflows/django-issue-checker.yml @@ -19,7 +19,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: - python-version: "3.11" + python-version: "3.12" - name: Install dependencies run: | python -m pip install --upgrade pip diff --git a/.github/workflows/pre-commit-autoupdate.yml b/.github/workflows/pre-commit-autoupdate.yml index 0ad41439..c01cd514 100644 --- a/.github/workflows/pre-commit-autoupdate.yml +++ b/.github/workflows/pre-commit-autoupdate.yml @@ -24,7 +24,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: - python-version: "3.11" + python-version: "3.12" - name: Install pre-commit run: pip install pre-commit diff --git a/.github/workflows/update-changelog.yml b/.github/workflows/update-changelog.yml index b0150507..305a608d 100644 --- a/.github/workflows/update-changelog.yml +++ b/.github/workflows/update-changelog.yml @@ -19,7 +19,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: "3.11" + python-version: "3.12" - name: Install dependencies run: | python -m pip install --upgrade pip diff --git a/.github/workflows/update-contributors.yml b/.github/workflows/update-contributors.yml index 0cda836d..e814039d 100644 --- a/.github/workflows/update-contributors.yml +++ b/.github/workflows/update-contributors.yml @@ -22,7 +22,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: "3.11" + python-version: "3.12" - name: Install dependencies run: | python -m pip install --upgrade pip diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f8c482d9..20d2f9c9 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,7 +2,7 @@ exclude: "{{cookiecutter.project_slug}}|.github/contributors.json|CHANGELOG.md|C default_stages: [commit] default_language_version: - python: python3.11 + python: python3.12 repos: - repo: https://github.com/pre-commit/pre-commit-hooks @@ -29,7 +29,7 @@ repos: rev: v3.15.1 hooks: - id: pyupgrade - args: [--py311-plus] + args: [--py312-plus] exclude: hooks/ - repo: https://github.com/psf/black diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 4598ff77..872e43a2 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -8,7 +8,7 @@ version: 2 build: os: ubuntu-22.04 tools: - python: "3.11" + python: "3.12" # Build documentation in the docs/ directory with Sphinx sphinx: diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 94ecbdd7..753e827a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -18,20 +18,20 @@ This last step is very important, don't start developing from master, it'll caus ## Testing -You'll need to run the tests using Python 3.11. We recommend using [tox](https://tox.readthedocs.io/en/latest/) to run the tests. It will automatically create a fresh virtual environment and install our test dependencies, such as [pytest-cookies](https://pypi.python.org/pypi/pytest-cookies/) and [flake8](https://pypi.python.org/pypi/flake8/). +You'll need to run the tests using Python 3.12. We recommend using [tox](https://tox.readthedocs.io/en/latest/) to run the tests. It will automatically create a fresh virtual environment and install our test dependencies, such as [pytest-cookies](https://pypi.python.org/pypi/pytest-cookies/) and [flake8](https://pypi.python.org/pypi/flake8/). We'll also run the tests on GitHub actions when you send your pull request, but it's a good idea to run them locally before you send it. ### Installation -First, make sure that your version of Python is 3.11: +First, make sure that your version of Python is 3.12: ```bash $ python --version -Python 3.11.3 +Python 3.12.2 ``` -Any version that starts with 3.11 will do. If you need to install it, you can get it from [python.org](https://www.python.org/downloads/). +Any version that starts with 3.12 will do. If you need to install it, you can get it from [python.org](https://www.python.org/downloads/). Then install `tox`, if not already installed: diff --git a/README.md b/README.md index a9bf1990..3141aed8 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ production-ready Django projects quickly. ## Features - For Django 4.2 -- Works with Python 3.11 +- Works with Python 3.12 - Renders Django projects with 100% starting test coverage - Twitter [Bootstrap](https://github.com/twbs/bootstrap) v5 - [12-Factor](https://12factor.net) based settings via [django-environ](https://github.com/joke2k/django-environ) diff --git a/docs/deployment-on-pythonanywhere.rst b/docs/deployment-on-pythonanywhere.rst index 2fa6a960..726f325e 100644 --- a/docs/deployment-on-pythonanywhere.rst +++ b/docs/deployment-on-pythonanywhere.rst @@ -37,7 +37,7 @@ Make sure your project is fully committed and pushed up to Bitbucket or Github o mkvirtualenv --python=/usr/bin/python3.10 my-project-name pip install -r requirements/production.txt # may take a few minutes -.. note:: We're creating the virtualenv using Python 3.10 (``--python=/usr/bin/python3.10```), although Cookiecutter Django generates a project for Python 3.11. This is because, at time of writing, PythonAnywhere only supports Python 3.10. It shouldn't be a problem, but if is, you may try changing the Python version to 3.11 and see if it works. If it does, please let us know, or even better, submit a pull request to update this section. +.. note:: We're creating the virtualenv using Python 3.10 (``--python=/usr/bin/python3.10```), although Cookiecutter Django generates a project for Python 3.12. This is because, at time of writing, PythonAnywhere only supports Python 3.10. It shouldn't be a problem, but if is, you may try changing the Python version to 3.12 and see if it works. If it does, please let us know, or even better, submit a pull request to update this section. Setting environment variables in the console -------------------------------------------- diff --git a/docs/developing-locally.rst b/docs/developing-locally.rst index 92379f4f..f7191d27 100644 --- a/docs/developing-locally.rst +++ b/docs/developing-locally.rst @@ -9,7 +9,7 @@ Setting Up Development Environment Make sure to have the following on your host: -* Python 3.11 +* Python 3.12 * PostgreSQL_. * Redis_, if using Celery * Cookiecutter_ @@ -18,7 +18,7 @@ First things first. #. Create a virtualenv: :: - $ python3.11 -m venv + $ python3.12 -m venv #. Activate the virtualenv you have just created: :: diff --git a/hooks/pre_gen_project.py b/hooks/pre_gen_project.py index 2956b9ab..e58fd354 100644 --- a/hooks/pre_gen_project.py +++ b/hooks/pre_gen_project.py @@ -39,7 +39,7 @@ if "{{ cookiecutter.use_docker }}".lower() == "n": if python_major_version == 2: print( WARNING + "You're running cookiecutter under Python 2, but the generated " - "project requires Python 3.11+. Do you want to proceed (y/n)? " + TERMINATOR + "project requires Python 3.12+. Do you want to proceed (y/n)? " + TERMINATOR ) yes_options, no_options = frozenset(["y"]), frozenset(["n"]) while True: diff --git a/pyproject.toml b/pyproject.toml index 2a9f00b2..6e68762f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -15,7 +15,7 @@ norecursedirs = [ # ==== black ==== [tool.black] line-length = 119 -target-version = ['py311'] +target-version = ['py312'] # ==== isort ==== diff --git a/setup.py b/setup.py index 7f55f00a..3b685a03 100644 --- a/setup.py +++ b/setup.py @@ -30,7 +30,7 @@ setup( "License :: OSI Approved :: BSD License", "Programming Language :: Python", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "Programming Language :: Python :: Implementation :: CPython", "Topic :: Software Development", ], diff --git a/tox.ini b/tox.ini index 903d5a53..3b7a9508 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,6 @@ [tox] skipsdist = true -envlist = py311,black-template +envlist = py312,black-template [testenv] deps = -rrequirements.txt diff --git a/{{cookiecutter.project_slug}}/.drone.yml b/{{cookiecutter.project_slug}}/.drone.yml index dc08bfba..969374f7 100644 --- a/{{cookiecutter.project_slug}}/.drone.yml +++ b/{{cookiecutter.project_slug}}/.drone.yml @@ -13,7 +13,7 @@ environment: steps: - name: lint pull: if-not-exists - image: python:3.11 + image: python:3.12 environment: PRE_COMMIT_HOME: ${CI_PROJECT_DIR}/.cache/pre-commit volumes: @@ -36,7 +36,7 @@ steps: - docker-compose -f local.yml up -d - docker-compose -f local.yml run django pytest {%- else %} - image: python:3.11 + image: python:3.12 commands: - pip install -r requirements/local.txt - pytest diff --git a/{{cookiecutter.project_slug}}/.github/workflows/ci.yml b/{{cookiecutter.project_slug}}/.github/workflows/ci.yml index 414ee1e6..48dad257 100644 --- a/{{cookiecutter.project_slug}}/.github/workflows/ci.yml +++ b/{{cookiecutter.project_slug}}/.github/workflows/ci.yml @@ -28,7 +28,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v4 with: - python-version: '3.11' + python-version: '3.12' {%- if cookiecutter.open_source_license != 'Not open source' %} # Consider using pre-commit.ci for open source project @@ -84,7 +84,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v4 with: - python-version: '3.11' + python-version: '3.12' cache: pip cache-dependency-path: | requirements/base.txt diff --git a/{{cookiecutter.project_slug}}/.gitlab-ci.yml b/{{cookiecutter.project_slug}}/.gitlab-ci.yml index 35021200..984e36a2 100644 --- a/{{cookiecutter.project_slug}}/.gitlab-ci.yml +++ b/{{cookiecutter.project_slug}}/.gitlab-ci.yml @@ -13,7 +13,7 @@ variables: precommit: stage: lint - image: python:3.11 + image: python:3.12 variables: PRE_COMMIT_HOME: ${CI_PROJECT_DIR}/.cache/pre-commit cache: @@ -40,7 +40,7 @@ pytest: script: - docker compose -f local.yml run django pytest {%- else %} - image: python:3.11 + image: python:3.12 tags: - python services: diff --git a/{{cookiecutter.project_slug}}/.pre-commit-config.yaml b/{{cookiecutter.project_slug}}/.pre-commit-config.yaml index 05a06772..5b8cc318 100644 --- a/{{cookiecutter.project_slug}}/.pre-commit-config.yaml +++ b/{{cookiecutter.project_slug}}/.pre-commit-config.yaml @@ -2,7 +2,7 @@ exclude: '^docs/|/migrations/|devcontainer.json' default_stages: [commit] default_language_version: - python: python3.11 + python: python3.12 repos: - repo: https://github.com/pre-commit/pre-commit-hooks diff --git a/{{cookiecutter.project_slug}}/.readthedocs.yml b/{{cookiecutter.project_slug}}/.readthedocs.yml index d5a8ef66..55643887 100644 --- a/{{cookiecutter.project_slug}}/.readthedocs.yml +++ b/{{cookiecutter.project_slug}}/.readthedocs.yml @@ -8,7 +8,7 @@ version: 2 build: os: ubuntu-22.04 tools: - python: '3.11' + python: '3.12' # Build documentation in the docs/ directory with Sphinx sphinx: diff --git a/{{cookiecutter.project_slug}}/.travis.yml b/{{cookiecutter.project_slug}}/.travis.yml index 78709191..18f9c052 100644 --- a/{{cookiecutter.project_slug}}/.travis.yml +++ b/{{cookiecutter.project_slug}}/.travis.yml @@ -2,7 +2,7 @@ dist: focal language: python python: - - "3.11" + - "3.12" services: - {% if cookiecutter.use_docker == 'y' %}docker{% else %}postgresql{% endif %} @@ -37,7 +37,7 @@ jobs: - sudo apt-get install -qq libsqlite3-dev libxml2 libxml2-dev libssl-dev libbz2-dev wget curl llvm language: python python: - - "3.11" + - "3.12" install: - pip install -r requirements/local.txt script: diff --git a/{{cookiecutter.project_slug}}/compose/local/django/Dockerfile b/{{cookiecutter.project_slug}}/compose/local/django/Dockerfile index 412865d2..d607550a 100644 --- a/{{cookiecutter.project_slug}}/compose/local/django/Dockerfile +++ b/{{cookiecutter.project_slug}}/compose/local/django/Dockerfile @@ -1,5 +1,5 @@ # define an alias for the specific python version used in this file. -FROM docker.io/python:3.11.8-slim-bookworm as python +FROM docker.io/python:3.12.2-slim-bookworm as python # Python build stage FROM python as python-build-stage diff --git a/{{cookiecutter.project_slug}}/compose/local/docs/Dockerfile b/{{cookiecutter.project_slug}}/compose/local/docs/Dockerfile index 2b155f86..c95fa666 100644 --- a/{{cookiecutter.project_slug}}/compose/local/docs/Dockerfile +++ b/{{cookiecutter.project_slug}}/compose/local/docs/Dockerfile @@ -1,5 +1,5 @@ # define an alias for the specific python version used in this file. -FROM docker.io/python:3.11.8-slim-bookworm as python +FROM docker.io/python:3.12.2-slim-bookworm as python # Python build stage diff --git a/{{cookiecutter.project_slug}}/compose/production/django/Dockerfile b/{{cookiecutter.project_slug}}/compose/production/django/Dockerfile index 05b18aa2..ea4f1899 100644 --- a/{{cookiecutter.project_slug}}/compose/production/django/Dockerfile +++ b/{{cookiecutter.project_slug}}/compose/production/django/Dockerfile @@ -25,7 +25,7 @@ RUN npm run build {%- endif %} # define an alias for the specific python version used in this file. -FROM docker.io/python:3.11.8-slim-bookworm as python +FROM docker.io/python:3.12.2-slim-bookworm as python # Python build stage FROM python as python-build-stage diff --git a/{{cookiecutter.project_slug}}/pyproject.toml b/{{cookiecutter.project_slug}}/pyproject.toml index a056c71c..ed27e2c9 100644 --- a/{{cookiecutter.project_slug}}/pyproject.toml +++ b/{{cookiecutter.project_slug}}/pyproject.toml @@ -18,7 +18,7 @@ plugins = ["django_coverage_plugin"] # ==== mypy ==== [tool.mypy] -python_version = "3.11" +python_version = "3.12" check_untyped_defs = true ignore_missing_imports = true warn_unused_ignores = true @@ -88,7 +88,7 @@ exclude = [ # Same as Django: https://github.com/cookiecutter/cookiecutter-django/issues/4792. line-length = 88 indent-width = 4 -target-version = "py311" +target-version = "py312" [tool.ruff.lint] select = [ diff --git a/{{cookiecutter.project_slug}}/runtime.txt b/{{cookiecutter.project_slug}}/runtime.txt index cf3b8042..6e797d46 100644 --- a/{{cookiecutter.project_slug}}/runtime.txt +++ b/{{cookiecutter.project_slug}}/runtime.txt @@ -1 +1 @@ -python-3.11.8 +python-3.12.2