Skip to content

Commit a3ede40

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 6d50180 commit a3ede40

14 files changed

+16
-69
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/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows
95
on:
106
create:
@@ -73,7 +69,7 @@ jobs:
7369
- name: Install Python
7470
uses: actions/setup-python@v5
7571
with:
76-
python-version: ${{ env.PYTHON_VERSION }}
72+
python-version-file: pyproject.toml
7773

7874
- name: Install Poetry
7975
run: pip install poetry
@@ -104,7 +100,7 @@ jobs:
104100
- name: Install Python
105101
uses: actions/setup-python@v5
106102
with:
107-
python-version: ${{ env.PYTHON_VERSION }}
103+
python-version-file: pyproject.toml
108104

109105
- name: Install Poetry
110106
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/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows
95
on:
106
create:
@@ -101,7 +97,7 @@ jobs:
10197
- name: Install Python
10298
uses: actions/setup-python@v5
10399
with:
104-
python-version: ${{ env.PYTHON_VERSION }}
100+
python-version-file: pyproject.toml
105101

106102
- name: Install Poetry
107103
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/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows
95
on:
106
create:
@@ -55,7 +51,7 @@ jobs:
5551
- name: Install Python
5652
uses: actions/setup-python@v5
5753
with:
58-
python-version: ${{ env.PYTHON_VERSION }}
54+
python-version-file: pyproject.toml
5955

6056
- name: Install Poetry
6157
run: pip install poetry

.github/workflows/test-python-poetry-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/test-python-poetry-task.md
22
name: Test 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/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows
95
on:
106
create:
@@ -69,7 +65,7 @@ jobs:
6965
- name: Install Python
7066
uses: actions/setup-python@v5
7167
with:
72-
python-version: ${{ env.PYTHON_VERSION }}
68+
python-version-file: pyproject.toml
7369

7470
- name: Install Poetry
7571
run: pip install poetry

docs/development.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ The following development tools must be available in your local environment:
99
- [**Node.js** / **npm**](https://nodejs.org/en/download/) - Node.js dependencies management tool
1010
- The **Node.js** version in use is defined by the `engines.node` key of [`package.json`](../package.json).
1111
- [**Python**](https://wiki.python.org/moin/BeginnersGuide/Download)
12-
- <!-- PYTHON_VERSION -->
13-
This project uses Python 3.9.x
12+
- The **Python** version in use is defined by the `tool.poetry.dependencies.python` key of [`pyproject.toml`](../pyproject.toml).
1413
- [**Poetry**](https://python-poetry.org/docs/#installation) - Python dependencies management tool
1514
- [**Task**](https://taskfile.dev/installation/) - task runner tool
1615

workflow-templates/check-mkdocs-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-mkdocs-task.md
22
name: Check Website
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/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows
95
on:
106
create:
@@ -69,7 +65,7 @@ jobs:
6965
- name: Install Python
7066
uses: actions/setup-python@v5
7167
with:
72-
python-version: ${{ env.PYTHON_VERSION }}
68+
python-version-file: pyproject.toml
7369

7470
- name: Install Poetry
7571
run: pip install poetry

workflow-templates/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/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows
95
on:
106
create:
@@ -73,7 +69,7 @@ jobs:
7369
- name: Install Python
7470
uses: actions/setup-python@v5
7571
with:
76-
python-version: ${{ env.PYTHON_VERSION }}
72+
python-version-file: pyproject.toml
7773

7874
- name: Install Poetry
7975
run: pip install poetry
@@ -104,7 +100,7 @@ jobs:
104100
- name: Install Python
105101
uses: actions/setup-python@v5
106102
with:
107-
python-version: ${{ env.PYTHON_VERSION }}
103+
python-version-file: pyproject.toml
108104

109105
- name: Install Poetry
110106
run: pip install poetry

workflow-templates/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/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows
95
on:
106
create:
@@ -101,7 +97,7 @@ jobs:
10197
- name: Install Python
10298
uses: actions/setup-python@v5
10399
with:
104-
python-version: ${{ env.PYTHON_VERSION }}
100+
python-version-file: pyproject.toml
105101

106102
- name: Install Poetry
107103
run: pip install poetry

workflow-templates/deploy-cobra-mkdocs-versioned-poetry.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/deploy-cobra-mkdocs-versioned-poetry.md
22
name: Deploy Website
33

4-
env:
5-
# See: https://github.com/actions/setup-python/tree/main#available-versions-of-python
6-
PYTHON_VERSION: "3.9"
7-
84
on:
95
push:
106
branches:
@@ -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: |

workflow-templates/deploy-mkdocs-poetry.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/deploy-mkdocs-poetry.md
22
name: Deploy Website
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/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows
95
on:
106
push:
@@ -33,7 +29,7 @@ jobs:
3329
- name: Install Python
3430
uses: actions/setup-python@v5
3531
with:
36-
python-version: ${{ env.PYTHON_VERSION }}
32+
python-version-file: pyproject.toml
3733

3834
- name: Install Poetry
3935
run: pip install poetry

0 commit comments

Comments
 (0)