Skip to content

Commit

Permalink
Upgrade Python to version 3.12
Browse files Browse the repository at this point in the history
  • Loading branch information
foarsitter committed Mar 18, 2024
1 parent 5c71441 commit b488056
Show file tree
Hide file tree
Showing 26 changed files with 38 additions and 38 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/django-issue-checker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pre-commit-autoupdate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update-changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update-contributors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 4 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion docs/deployment-on-pythonanywhere.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
--------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions docs/developing-locally.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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_
Expand All @@ -18,7 +18,7 @@ First things first.

#. Create a virtualenv: ::

$ python3.11 -m venv <virtual env path>
$ python3.12 -m venv <virtual env path>

#. Activate the virtualenv you have just created: ::

Expand Down
2 changes: 1 addition & 1 deletion hooks/pre_gen_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
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:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ norecursedirs = [
# ==== black ====
[tool.black]
line-length = 119
target-version = ['py311']
target-version = ['py312']


# ==== isort ====
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"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",
],
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tox]
skipsdist = true
envlist = py311,black-template
envlist = py312,black-template

[testenv]
deps = -rrequirements.txt
Expand Down
4 changes: 2 additions & 2 deletions {{cookiecutter.project_slug}}/.drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions {{cookiecutter.project_slug}}/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions {{cookiecutter.project_slug}}/.gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion {{cookiecutter.project_slug}}/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion {{cookiecutter.project_slug}}/.readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions {{cookiecutter.project_slug}}/.travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ dist: focal

language: python
python:
- "3.11"
- "3.12"

services:
- {% if cookiecutter.use_docker == 'y' %}docker{% else %}postgresql{% endif %}
Expand Down Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions {{cookiecutter.project_slug}}/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 = [
Expand Down
2 changes: 1 addition & 1 deletion {{cookiecutter.project_slug}}/runtime.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
python-3.11.8
python-3.12.2

0 comments on commit b488056

Please sign in to comment.