Skip to content

Commit

Permalink
feat: add support for Python 3.12 (#632)
Browse files Browse the repository at this point in the history
  • Loading branch information
jenstroeger authored May 14, 2024
1 parent 5d47f3c commit f70fd7c
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 13 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/_build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#
# Even though we run the build in a matrix to check against different platforms, due to a known
# limitation of reusable workflows that do not support setting strategy property from the caller
# workflow, we only generate artifacts for ubuntu-latest and Python 3.11, which can be used to
# workflow, we only generate artifacts for ubuntu-latest and Python 3.12, which can be used to
# create a release. For details see:
#
# https://docs.github.com/en/actions/using-workflows/reusing-workflows#limitations
Expand Down Expand Up @@ -35,7 +35,7 @@ permissions:
contents: read
env:
ARTIFACT_OS: ubuntu-latest # The default OS for release.
ARTIFACT_PYTHON: '3.11' # The default Python version for release.
ARTIFACT_PYTHON: '3.12' # The default Python version for release.

jobs:
build:
Expand All @@ -51,7 +51,7 @@ jobs:
# It is recommended to pin a Runner version specifically:
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners
os: [ubuntu-latest, macos-latest, windows-latest]
python: ['3.10', '3.11']
python: ['3.10', '3.11', '3.12']
steps:

- name: Harden Runner
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Learn more about CodeQL language support at https://git.io/codeql-language-support
language: [python]
python: ['3.11']
python: ['3.12']
steps:

- name: Harden Runner
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr-conventional-commits.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0
with:
python-version: '3.11'
python-version: '3.12'

# Install Commitizen without using the package's Makefile: that's much faster than
# creating a venv and installing heaps of dependencies that aren't required for this job.
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0
with:
python-version: '3.11'
python-version: '3.12'

- name: Set up Commitizen
run: |
Expand Down Expand Up @@ -126,7 +126,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0
with:
python-version: '3.11'
python-version: '3.12'

- name: Set up Commitizen
run: |
Expand Down Expand Up @@ -250,7 +250,7 @@ jobs:
# Github disallows passing environment variables as arguments to a reusable
# workflow, so we have to duplicate these values here. Related discussion
# here: https://github.com/actions/toolkit/issues/931
artifact-name: artifact-ubuntu-latest-python-3.11
artifact-name: artifact-ubuntu-latest-python-3.12
git-user-name: jenstroeger
git-user-email: [email protected]
secrets:
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ endif
.PHONY: all
all: check test dist docs

# Create a virtual environment, either for Python3.11 (default) or using
# Create a virtual environment, either for Python3.12 (default) or using
# the Python interpreter specified in the PYTHON environment variable. Also
# create an empty pip.conf file to ensure that `pip config` modifies this
# venv only, unless told otherwise. For more background, see:
Expand All @@ -70,8 +70,8 @@ venv:
echo "Found an inactive Python virtual environment, please activate or nuke it" && exit 1; \
fi
if [ -z "${PYTHON}" ]; then \
echo "Creating virtual environment in .venv/ for python3.11"; \
python3.11 -m venv --upgrade-deps --prompt . .venv; \
echo "Creating virtual environment in .venv/ for python3.12"; \
python3.12 -m venv --upgrade-deps --prompt . .venv; \
else \
echo "Creating virtual environment in .venv/ for ${PYTHON}"; \
${PYTHON} -m venv --upgrade-deps --prompt . .venv; \
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ The badges above give you an idea of what this project template provides. It’s

### Typing

The package requires a minimum of [Python 3.10](https://www.python.org/downloads/release/python-3109/) and supports [Python 3.11](https://www.python.org/downloads/release/python-3111/). All code requires comprehensive [typing](https://docs.python.org/3/library/typing.html). The [mypy](http://mypy-lang.org/) static type checker and the [flake8-pyi](https://github.com/PyCQA/flake8-pyi) plugin are invoked by git hooks and through a Github Action to enforce continuous type checks on Python source and [stub files](https://peps.python.org/pep-0484/#stub-files). Make sure to add type hints to your code or to use [stub files](https://mypy.readthedocs.io/en/stable/stubs.html) for types, to ensure that users of your package can `import` and type-check your code (see also [PEP 561](https://www.python.org/dev/peps/pep-0561/)).
The package requires a minimum of [Python 3.10](https://www.python.org/downloads/release/python-31014/), and it supports [Python 3.11](https://www.python.org/downloads/release/python-3118/) and [Python 3.12](https://www.python.org/downloads/release/python-3121/) (default). All code requires comprehensive [typing](https://docs.python.org/3/library/typing.html). The [mypy](http://mypy-lang.org/) static type checker and the [flake8-pyi](https://github.com/PyCQA/flake8-pyi) plugin are invoked by git hooks and through a Github Action to enforce continuous type checks on Python source and [stub files](https://peps.python.org/pep-0484/#stub-files). Make sure to add type hints to your code or to use [stub files](https://mypy.readthedocs.io/en/stable/stubs.html) for types, to ensure that users of your package can `import` and type-check your code (see also [PEP 561](https://www.python.org/dev/peps/pep-0561/)).

### Quality assurance

Expand Down Expand Up @@ -111,7 +111,7 @@ PYTHON=python3.10 make venv # Same virtual environment for a different Python v
or manually:

```bash
python3.11 -m venv .venv # Or use .venv311 for more than one local virtual environments.
python3.12 -m venv .venv # Or use .venv312 for more than one local virtual environments.
```

When working with this Makefile _it is important to always [activate the virtual environment](https://docs.python.org/3/library/venv.html)_ because some of the [git hooks](#git-hooks) (see below) depend on that:
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ classifiers = [
"Programming Language :: Python",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: Implementation :: CPython",
"Topic :: Software Development :: Libraries :: Python Modules",
Expand Down

0 comments on commit f70fd7c

Please sign in to comment.