Skip to content

Commit 5e8e510

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 90ca1ab commit 5e8e510

File tree

4 files changed

+5
-16
lines changed

4 files changed

+5
-16
lines changed

.github/workflows/check-python-task.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-python-task.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/actions/using-workflows/events-that-trigger-workflows
95
on:
106
create:
@@ -70,7 +66,7 @@ jobs:
7066
- name: Install Python
7167
uses: actions/setup-python@v5
7268
with:
73-
python-version: ${{ env.PYTHON_VERSION }}
69+
python-version-file: pyproject.toml
7470

7571
- name: Install Poetry
7672
run: pip install poetry
@@ -99,7 +95,7 @@ jobs:
9995
- name: Install Python
10096
uses: actions/setup-python@v5
10197
with:
102-
python-version: ${{ env.PYTHON_VERSION }}
98+
python-version-file: pyproject.toml
10399

104100
- name: Install Poetry
105101
run: pip install poetry

.github/workflows/check-yaml-task.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-yaml-task.md
22
name: Check YAML
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/actions/using-workflows/events-that-trigger-workflows
95
on:
106
create:
@@ -98,7 +94,7 @@ jobs:
9894
- name: Install Python
9995
uses: actions/setup-python@v5
10096
with:
101-
python-version: ${{ env.PYTHON_VERSION }}
97+
python-version-file: pyproject.toml
10298

10399
- name: Install Poetry
104100
run: pip install poetry

.github/workflows/spell-check-task.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/spell-check-task.md
22
name: Spell Check
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/actions/using-workflows/events-that-trigger-workflows
95
on:
106
create:
@@ -52,7 +48,7 @@ jobs:
5248
- name: Install Python
5349
uses: actions/setup-python@v5
5450
with:
55-
python-version: ${{ env.PYTHON_VERSION }}
51+
python-version-file: pyproject.toml
5652

5753
- name: Install Poetry
5854
run: pip install poetry

docs/development.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ The following development tools must be available in your local environment:
189189
- [**Task**](https://taskfile.dev/installation/)
190190
- [**Node.js**](https://nodejs.dev/en/download/)
191191
- [**Python**](https://www.python.org/downloads/)
192+
- The **Python** version in use is defined in the `tool.poetry.dependencies` field of [`pyproject.toml`](../pyproject.toml).
192193
- [**Poetry**](https://python-poetry.org/docs/#installation)
193194

194195
### Running Checks

0 commit comments

Comments
 (0)