Skip to content

Commit b330ccb

Browse files
committed
Use pyproject.toml as Python version source
Python and Python-based tools are used in the development and maintenance of the project. A standardized version of Python is used for these operations. Poetry is used for Python package dependencies management. Poetry installs dependencies into a virtual environment. For this reason, the Poetry configuration includes a Python version number, which must match the correct version of Python for the project. This configuration is stored in the `pyproject.toml` file. Python is installed in the GitHub Actions runner environments using the "actions/setup-python" action, which also must be configured to install the correct version of Python. Previously the version number for use by the actions/setup-python action was defined in each workflow. This meant that we had multiple copies of the Python version information, all of which had to be kept in sync. Fortunately, support for using `pyproject.toml` as the source of version information for the "actions/setup-python" action was recently added. This means it is now possible for all components of the project infrastructure to get the Python version from a single source.
1 parent 66e8a8c commit b330ccb

1 file changed

Lines changed: 1 addition & 5 deletions

File tree

.github/workflows/check-python.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
# Source: https://github.com/per1234/.github/blob/main/workflow-templates/check-python.md
22
name: Check Python
33

4-
env:
5-
# See: https://github.com/actions/setup-python/tree/main#available-versions-of-python
6-
PYTHON_VERSION: "3.9"
7-
84
# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows
95
on:
106
push:
@@ -62,7 +58,7 @@ jobs:
6258
- name: Install Python
6359
uses: actions/setup-python@v6
6460
with:
65-
python-version: ${{ env.PYTHON_VERSION }}
61+
python-version-file: pyproject.toml
6662

6763
- name: Check formatting
6864
uses: psf/black@stable

0 commit comments

Comments
 (0)