From 42c30dafcb587baa71710eae6058ce2e824d1f38 Mon Sep 17 00:00:00 2001 From: Jelmer Date: Sat, 15 Apr 2023 12:42:33 +0200 Subject: [PATCH] Upgrade Python to version 3.11 (Faster CPython) (#4256) * Upgrade Python to version 3.11 (Faster CPython) * Update pyupgrade config for Python 3.11 * Update tox env to Python 3.11 * Update to latest Python 3.11.3 * Add a note about lack of support in PythonAnywhere * Rephrase note * Fix casing --------- Co-authored-by: Bruno Alla Co-authored-by: Bruno Alla --- .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 | 2 +- CONTRIBUTING.md | 4 ++-- README.md | 2 +- docs/deployment-on-pythonanywhere.rst | 1 + docs/developing-locally.rst | 4 ++-- hooks/pre_gen_project.py | 2 +- setup.py | 2 +- tox.ini | 2 +- {{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 +- {{cookiecutter.project_slug}}/compose/local/docs/Dockerfile | 2 +- .../compose/production/django/Dockerfile | 3 +-- {{cookiecutter.project_slug}}/runtime.txt | 2 +- {{cookiecutter.project_slug}}/setup.cfg | 2 +- 23 files changed, 30 insertions(+), 30 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c31be1b7..714cd8ac 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,7 +25,7 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-python@v4 with: - python-version: "3.10" + python-version: "3.11" cache: pip - name: Install dependencies run: pip install -r requirements.txt @@ -56,7 +56,7 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-python@v4 with: - python-version: "3.10" + python-version: "3.11" cache: pip - name: Install dependencies run: pip install -r requirements.txt @@ -98,7 +98,7 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-python@v4 with: - python-version: "3.10" + python-version: "3.11" cache: pip cache-dependency-path: | requirements.txt diff --git a/.github/workflows/django-issue-checker.yml b/.github/workflows/django-issue-checker.yml index fd250604..cbfea922 100644 --- a/.github/workflows/django-issue-checker.yml +++ b/.github/workflows/django-issue-checker.yml @@ -19,7 +19,7 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-python@v4 with: - python-version: "3.10" + python-version: "3.11" - 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 c822da30..9e5232dc 100644 --- a/.github/workflows/pre-commit-autoupdate.yml +++ b/.github/workflows/pre-commit-autoupdate.yml @@ -24,7 +24,7 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-python@v4 with: - python-version: "3.10" + python-version: "3.11" - name: Install pre-commit run: pip install pre-commit diff --git a/.github/workflows/update-changelog.yml b/.github/workflows/update-changelog.yml index 27113a89..f48f297a 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@v4 with: - python-version: "3.10" + python-version: "3.11" - 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 83c651a4..2aea8003 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@v4 with: - python-version: "3.10" + python-version: "3.11" - name: Install dependencies run: | python -m pip install --upgrade pip diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2dc0f81c..34bcc6a2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,7 +12,7 @@ repos: rev: v3.3.1 hooks: - id: pyupgrade - args: [--py310-plus] + args: [--py311-plus] exclude: hooks/ - repo: https://github.com/psf/black diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 69bce6f2..5c4ca604 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -33,9 +33,9 @@ To run all tests using various versions of python in virtualenvs defined in tox. It is possible to test with a specific version of python. To do this, the command is: - $ tox -e py310 + $ tox -e py311 -This will run pytest with the python3.10 interpreter, for example. +This will run pytest with the python3.11 interpreter, for example. To run a particular test with tox for against your current Python version: diff --git a/README.md b/README.md index d951c7a2..10bf57c2 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ production-ready Django projects quickly. ## Features - For Django 4.1 -- Works with Python 3.10 +- Works with Python 3.11 - Renders Django projects with 100% starting test coverage - Twitter [Bootstrap](https://github.com/twbs/bootstrap) v5 - [12-Factor](http://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 7984d7b5..2fa6a960 100644 --- a/docs/deployment-on-pythonanywhere.rst +++ b/docs/deployment-on-pythonanywhere.rst @@ -37,6 +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. Setting environment variables in the console -------------------------------------------- diff --git a/docs/developing-locally.rst b/docs/developing-locally.rst index fb66536f..b8655a84 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.10 +* Python 3.11 * PostgreSQL_. * Redis_, if using Celery * Cookiecutter_ @@ -18,7 +18,7 @@ First things first. #. Create a virtualenv: :: - $ python3.10 -m venv + $ python3.11 -m venv #. Activate the virtualenv you have just created: :: diff --git a/hooks/pre_gen_project.py b/hooks/pre_gen_project.py index 4f4378f5..d067954d 100644 --- a/hooks/pre_gen_project.py +++ b/hooks/pre_gen_project.py @@ -44,7 +44,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.10+. Do you want to proceed (y/n)? " + TERMINATOR + "project requires Python 3.11+. Do you want to proceed (y/n)? " + TERMINATOR ) yes_options, no_options = frozenset(["y"]), frozenset(["n"]) while True: diff --git a/setup.py b/setup.py index d168cd13..3f20e29c 100644 --- a/setup.py +++ b/setup.py @@ -33,7 +33,7 @@ setup( "License :: OSI Approved :: BSD License", "Programming Language :: Python", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", "Programming Language :: Python :: Implementation :: CPython", "Topic :: Software Development", ], diff --git a/tox.ini b/tox.ini index 0400e4f9..f0c22d48 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,6 @@ [tox] skipsdist = true -envlist = py310,black-template +envlist = py311,black-template [testenv] deps = -rrequirements.txt diff --git a/{{cookiecutter.project_slug}}/.github/workflows/ci.yml b/{{cookiecutter.project_slug}}/.github/workflows/ci.yml index 89d83f25..497d0dd2 100644 --- a/{{cookiecutter.project_slug}}/.github/workflows/ci.yml +++ b/{{cookiecutter.project_slug}}/.github/workflows/ci.yml @@ -29,7 +29,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v4 with: - python-version: "3.10" + python-version: "3.11" {%- if cookiecutter.open_source_license != 'Not open source' %} # Consider using pre-commit.ci for open source project @@ -86,7 +86,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v4 with: - python-version: "3.10" + python-version: "3.11" 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 7892ad63..a312a41a 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.10 + image: python:3.11 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.10 + image: python:3.11 tags: - python services: diff --git a/{{cookiecutter.project_slug}}/.pre-commit-config.yaml b/{{cookiecutter.project_slug}}/.pre-commit-config.yaml index 073df732..54218742 100644 --- a/{{cookiecutter.project_slug}}/.pre-commit-config.yaml +++ b/{{cookiecutter.project_slug}}/.pre-commit-config.yaml @@ -13,7 +13,7 @@ repos: rev: v3.3.1 hooks: - id: pyupgrade - args: [--py310-plus] + args: [--py311-plus] - repo: https://github.com/psf/black rev: 23.3.0 diff --git a/{{cookiecutter.project_slug}}/.readthedocs.yml b/{{cookiecutter.project_slug}}/.readthedocs.yml index 08d7f9c2..44512245 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.10" + python: "3.11" # Build documentation in the docs/ directory with Sphinx sphinx: diff --git a/{{cookiecutter.project_slug}}/.travis.yml b/{{cookiecutter.project_slug}}/.travis.yml index 326d7839..5e5f92ff 100644 --- a/{{cookiecutter.project_slug}}/.travis.yml +++ b/{{cookiecutter.project_slug}}/.travis.yml @@ -2,7 +2,7 @@ dist: focal language: python python: - - "3.10" + - "3.11" 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.10" + - "3.11" 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 4be394f7..1d5c14af 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 specfic python version used in this file. -FROM python:3.10.10-slim-bullseye as python +FROM python:3.11.3-slim-bullseye 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 587b8d3a..f8bcc35b 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 specfic python version used in this file. -FROM python:3.10.10-slim-bullseye as python +FROM python:3.11.3-slim-bullseye as python # Python build stage diff --git a/{{cookiecutter.project_slug}}/compose/production/django/Dockerfile b/{{cookiecutter.project_slug}}/compose/production/django/Dockerfile index 8ca35f18..84c702db 100644 --- a/{{cookiecutter.project_slug}}/compose/production/django/Dockerfile +++ b/{{cookiecutter.project_slug}}/compose/production/django/Dockerfile @@ -24,9 +24,8 @@ ENV DJANGO_AZURE_ACCOUNT_NAME=${DJANGO_AZURE_ACCOUNT_NAME} RUN npm run build {%- endif %} - # define an alias for the specfic python version used in this file. -FROM python:3.10.10-slim-bullseye as python +FROM python:3.11.3-slim-bullseye as python # Python build stage FROM python as python-build-stage diff --git a/{{cookiecutter.project_slug}}/runtime.txt b/{{cookiecutter.project_slug}}/runtime.txt index 69b0ccfc..afe12ad1 100644 --- a/{{cookiecutter.project_slug}}/runtime.txt +++ b/{{cookiecutter.project_slug}}/runtime.txt @@ -1 +1 @@ -python-3.10.8 +python-3.11.3 diff --git a/{{cookiecutter.project_slug}}/setup.cfg b/{{cookiecutter.project_slug}}/setup.cfg index e282af36..ab191732 100644 --- a/{{cookiecutter.project_slug}}/setup.cfg +++ b/{{cookiecutter.project_slug}}/setup.cfg @@ -18,7 +18,7 @@ force_grid_wrap = 0 use_parentheses = true [mypy] -python_version = 3.10 +python_version = 3.11 check_untyped_defs = True ignore_missing_imports = True warn_unused_ignores = True