Skip to content

Commit d4e6240

Browse files
committed
Only install Python package dependencies from relevant group
The "Poetry" tool is used to manage the project's Python package dependencies. Dependencies might be classified into distinct categories. The most basic classification would be: - Application dependencies: used by the project's applications - Development dependencies: tools used in the development and maintenance of the project, but not by the application By default, Poetry installs all non-optional dependencies. This can be inefficient in a case where a specific operation is being performed, since a given operation might only require the dependencies from one category and so the installation of dependencies from the other is pointless for that operation. For this reason, Poetry allows the user to organize dependencies into arbitrary "groups", and to specify which groups should be installed. The Python package installation task is hereby updated to allow dependency groups to be specified, and the calls to that task updated to specify the groups they require.
1 parent 0838eb9 commit d4e6240

File tree

7 files changed

+34
-2
lines changed

7 files changed

+34
-2
lines changed

Taskfile.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,8 @@ tasks:
520520
desc: Check for commonly misspelled words
521521
deps:
522522
- task: poetry:install-deps
523+
vars:
524+
POETRY_GROUPS: dev
523525
cmds:
524526
- poetry run codespell
525527

@@ -555,6 +557,8 @@ tasks:
555557
desc: Correct commonly misspelled words where possible
556558
deps:
557559
- task: poetry:install-deps
560+
vars:
561+
POETRY_GROUPS: dev
558562
cmds:
559563
- poetry run codespell --write-changes
560564

@@ -898,6 +902,8 @@ tasks:
898902
desc: Format Python files
899903
deps:
900904
- task: poetry:install-deps
905+
vars:
906+
POETRY_GROUPS: dev
901907
cmds:
902908
- poetry run black .
903909

@@ -906,6 +912,8 @@ tasks:
906912
desc: Lint Python code
907913
deps:
908914
- task: poetry:install-deps
915+
vars:
916+
POETRY_GROUPS: dev
909917
cmds:
910918
- poetry run flake8 --show-source
911919

@@ -1012,5 +1020,7 @@ tasks:
10121020
desc: Check for problems with YAML files
10131021
deps:
10141022
- task: poetry:install-deps
1023+
vars:
1024+
POETRY_GROUPS: dev
10151025
cmds:
10161026
- poetry run yamllint --format {{default "colored" .YAMLLINT_FORMAT}} .

workflow-templates/assets/check-mkdocs-task/Taskfile.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ tasks:
1313
deps:
1414
- task: docs:generate
1515
- task: poetry:install-deps
16+
vars:
17+
POETRY_GROUPS: dev
1618
cmds:
1719
- poetry run mkdocs build --strict
1820

@@ -22,5 +24,7 @@ tasks:
2224
deps:
2325
- task: docs:generate
2426
- task: poetry:install-deps
27+
vars:
28+
POETRY_GROUPS: dev
2529
cmds:
2630
- poetry run mkdocs serve

workflow-templates/assets/check-python-task/Taskfile.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ tasks:
77
desc: Format Python files
88
deps:
99
- task: poetry:install-deps
10+
vars:
11+
POETRY_GROUPS: dev
1012
cmds:
1113
- poetry run black .
1214

@@ -15,5 +17,7 @@ tasks:
1517
desc: Lint Python code
1618
deps:
1719
- task: poetry:install-deps
20+
vars:
21+
POETRY_GROUPS: dev
1822
cmds:
1923
- poetry run flake8 --show-source

workflow-templates/assets/check-yaml-task/Taskfile.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,7 @@ tasks:
77
desc: Check for problems with YAML files
88
deps:
99
- task: poetry:install-deps
10+
vars:
11+
POETRY_GROUPS: dev
1012
cmds:
1113
- poetry run yamllint --format {{default "colored" .YAMLLINT_FORMAT}} .

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,17 @@ tasks:
5454
5555
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/poetry-task/Taskfile.yml
5656
poetry:install-deps:
57-
desc: Install dependencies managed by Poetry
57+
desc: |
58+
Install dependencies managed by Poetry.
59+
Environment variable parameters:
60+
- POETRY_GROUPS: Poetry dependency groups to install (default: install all dependencies).
61+
run: when_changed
5862
deps:
5963
- task: poetry:install
6064
cmds:
61-
- poetry install --no-root
65+
- |
66+
poetry install \
67+
{{if .POETRY_GROUPS}} --only {{.POETRY_GROUPS}} {{end}}
6268
6369
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/poetry-task/Taskfile.yml
6470
poetry:update-deps:

workflow-templates/assets/spell-check-task/Taskfile.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ tasks:
77
desc: Check for commonly misspelled words
88
deps:
99
- task: poetry:install-deps
10+
vars:
11+
POETRY_GROUPS: dev
1012
cmds:
1113
- poetry run codespell
1214

@@ -15,5 +17,7 @@ tasks:
1517
desc: Correct commonly misspelled words where possible
1618
deps:
1719
- task: poetry:install-deps
20+
vars:
21+
POETRY_GROUPS: dev
1822
cmds:
1923
- poetry run codespell --write-changes

workflow-templates/assets/test-go-integration-task/Taskfile.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,7 @@ tasks:
88
deps:
99
- task: go:build
1010
- task: poetry:install-deps
11+
vars:
12+
POETRY_GROUPS: dev
1113
cmds:
1214
- poetry run pytest tests

0 commit comments

Comments
 (0)