Skip to content

Commit 328a48c

Browse files
authored
Merge pull request #604 from per1234/manage-poetry
Manage versioning of Poetry tool dependency
2 parents 5354160 + 1319758 commit 328a48c

25 files changed

+1556
-80
lines changed

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,6 @@ jobs:
7171
with:
7272
python-version-file: pyproject.toml
7373

74-
- name: Install Poetry
75-
run: pip install poetry
76-
7774
- name: Install Task
7875
uses: arduino/setup-task@v2
7976
with:
@@ -102,9 +99,6 @@ jobs:
10299
with:
103100
python-version-file: pyproject.toml
104101

105-
- name: Install Poetry
106-
run: pip install poetry
107-
108102
- name: Install Task
109103
uses: arduino/setup-task@v2
110104
with:

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,6 @@ jobs:
9999
with:
100100
python-version-file: pyproject.toml
101101

102-
- name: Install Poetry
103-
run: pip install poetry
104-
105102
- name: Install Task
106103
uses: arduino/setup-task@v2
107104
with:

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,6 @@ jobs:
5353
with:
5454
python-version-file: pyproject.toml
5555

56-
- name: Install Poetry
57-
run: pip install poetry
58-
5956
- name: Install Task
6057
uses: arduino/setup-task@v2
6158
with:

.github/workflows/test-python-poetry-task.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,6 @@ jobs:
6767
with:
6868
python-version-file: pyproject.toml
6969

70-
- name: Install Poetry
71-
run: pip install poetry
72-
7370
- name: Install Task
7471
uses: arduino/setup-task@v2
7572
with:

Taskfile.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -827,15 +827,66 @@ tasks:
827827
-r "{{.STYLELINTRC_SCHEMA_PATH}}" \
828828
-d "{{.INSTANCE_PATH}}"
829829
830+
# Print the version constraint for the project's Poetry tool dependency.
831+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/poetry-task/Taskfile.yml
832+
poetry:get-version:
833+
cmds:
834+
- |
835+
if ! which yq &>/dev/null; then
836+
echo "yq not found or not in PATH."
837+
echo "Please install: https://github.com/mikefarah/yq/#install"
838+
exit 1
839+
fi
840+
- |
841+
yq \
842+
--input-format toml \
843+
--output-format yaml \
844+
'.tool.poetry.group.pipx.dependencies.poetry' \
845+
< pyproject.toml
846+
847+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/poetry-task/Taskfile.yml
848+
poetry:install:
849+
desc: Install Poetry
850+
run: once
851+
vars:
852+
POETRY_VERSION:
853+
sh: task poetry:get-version
854+
cmds:
855+
- |
856+
if ! which python &>/dev/null; then
857+
echo "Python not found or not in PATH."
858+
echo "Please install a version of Python meeting the constraint {{.POETRY_VERSION}}:"
859+
echo "https://wiki.python.org/moin/BeginnersGuide/Download"
860+
exit 1
861+
fi
862+
- |
863+
if ! which pipx &>/dev/null; then
864+
echo "pipx not found or not in PATH."
865+
echo "Please install: https://pipx.pypa.io/stable/installation/#installing-pipx"
866+
exit 1
867+
fi
868+
- |
869+
export PIPX_DEFAULT_PYTHON="$( \
870+
task utility:normalize-path \
871+
RAW_PATH="$(which python)" \
872+
)"
873+
pipx install \
874+
--force \
875+
"poetry=={{.POETRY_VERSION}}"
876+
830877
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/poetry-task/Taskfile.yml
831878
poetry:install-deps:
832879
desc: Install dependencies managed by Poetry
880+
deps:
881+
- task: poetry:install
833882
cmds:
834883
- poetry install --no-root
835884

836885
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/poetry-task/Taskfile.yml
837886
poetry:update-deps:
838887
desc: Update all dependencies managed by Poetry to their newest versions
888+
deps:
889+
- task: poetry:install
839890
cmds:
840891
- poetry update
841892

docs/development.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ The following development tools must be available in your local environment:
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)
1212
- The **Python** version in use is defined by the `tool.poetry.dependencies.python` key of [`pyproject.toml`](../pyproject.toml).
13-
- [**Poetry**](https://python-poetry.org/docs/#installation) - Python dependencies management tool
1413
- [**Task**](https://taskfile.dev/installation/) - task runner tool
1514

1615
## Building the Project

poetry.lock

Lines changed: 1431 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@ pep8-naming = "^0.15.1"
1616
pytest = "^8.4.1"
1717
GitPython = "^3.1.44"
1818

19+
# The dependencies in this group are installed using pipx; NOT Poetry. The use of the `tool.poetry.group` super-table
20+
# is a hack required in order to be able to manage updates of these dependencies via Dependabot.
21+
[tool.poetry.group.pipx]
22+
optional = true
23+
24+
[tool.poetry.group.pipx.dependencies]
25+
poetry = "2.1.3"
26+
1927
[build-system]
2028
requires = ["poetry-core>=1.0.0"]
2129
build-backend = "poetry.core.masonry.api"

workflow-templates/assets/poetry-task/Taskfile.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,65 @@
22
version: "3"
33

44
tasks:
5+
# Print the version constraint for the project's Poetry tool dependency.
6+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/poetry-task/Taskfile.yml
7+
poetry:get-version:
8+
cmds:
9+
- |
10+
if ! which yq &>/dev/null; then
11+
echo "yq not found or not in PATH."
12+
echo "Please install: https://github.com/mikefarah/yq/#install"
13+
exit 1
14+
fi
15+
- |
16+
yq \
17+
--input-format toml \
18+
--output-format yaml \
19+
'.tool.poetry.group.pipx.dependencies.poetry' \
20+
< pyproject.toml
21+
22+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/poetry-task/Taskfile.yml
23+
poetry:install:
24+
desc: Install Poetry
25+
run: once
26+
vars:
27+
POETRY_VERSION:
28+
sh: task poetry:get-version
29+
cmds:
30+
- |
31+
if ! which python &>/dev/null; then
32+
echo "Python not found or not in PATH."
33+
echo "Please install a version of Python meeting the constraint {{.POETRY_VERSION}}:"
34+
echo "https://wiki.python.org/moin/BeginnersGuide/Download"
35+
exit 1
36+
fi
37+
- |
38+
if ! which pipx &>/dev/null; then
39+
echo "pipx not found or not in PATH."
40+
echo "Please install: https://pipx.pypa.io/stable/installation/#installing-pipx"
41+
exit 1
42+
fi
43+
- |
44+
export PIPX_DEFAULT_PYTHON="$( \
45+
task utility:normalize-path \
46+
RAW_PATH="$(which python)" \
47+
)"
48+
pipx install \
49+
--force \
50+
"poetry=={{.POETRY_VERSION}}"
51+
552
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/poetry-task/Taskfile.yml
653
poetry:install-deps:
754
desc: Install dependencies managed by Poetry
55+
deps:
56+
- task: poetry:install
857
cmds:
958
- poetry install --no-root
1059

1160
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/poetry-task/Taskfile.yml
1261
poetry:update-deps:
1362
desc: Update all dependencies managed by Poetry to their newest versions
63+
deps:
64+
- task: poetry:install
1465
cmds:
1566
- poetry update

workflow-templates/assets/poetry/pyproject.toml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,13 @@ build-backend = "poetry.core.masonry.api"
77
[tool.poetry]
88
package-mode = false
99

10+
# The dependencies in this group are installed using pipx; NOT Poetry. The use of the `tool.poetry.group` super-table
11+
# is a hack required in order to be able to manage updates of these dependencies via Dependabot.
12+
[tool.poetry.group.pipx]
13+
optional = true
14+
15+
[tool.poetry.group.pipx.dependencies]
16+
poetry = "2.1.3"
17+
1018
[tool.poetry.dependencies]
11-
python = "^3.9"
19+
python = "~3.9"

0 commit comments

Comments
 (0)