Skip to content

Commit 926d5fa

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 03b00b7 commit 926d5fa

File tree

4 files changed

+81
-63
lines changed

4 files changed

+81
-63
lines changed

.github/workflows/deploy-cobra-mkdocs-versioned-poetry.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,9 @@ jobs:
8282
run: task docs:generate
8383

8484
- name: Install Dependencies
85-
run: task poetry:install-deps
85+
run: |
86+
task poetry:install-deps \
87+
POETRY_GROUPS=dev
8688
8789
- name: Determine versioning parameters
8890
id: determine-versioning

Taskfile.yml

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,8 @@ tasks:
233233
desc: Check for commonly misspelled words
234234
deps:
235235
- task: poetry:install-deps
236+
vars:
237+
POETRY_GROUPS: dev
236238
cmds:
237239
- poetry run codespell
238240

@@ -241,6 +243,8 @@ tasks:
241243
desc: Correct commonly misspelled words where possible
242244
deps:
243245
- task: poetry:install-deps
246+
vars:
247+
POETRY_GROUPS: dev
244248
cmds:
245249
- |
246250
poetry run \
@@ -377,6 +381,8 @@ tasks:
377381
- task: go:build
378382
- task: go:rule-docs:build
379383
- task: poetry:install-deps
384+
vars:
385+
POETRY_GROUPS: dev
380386
cmds:
381387
- |
382388
poetry run \
@@ -635,11 +641,17 @@ tasks:
635641
636642
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/poetry-task/Taskfile.yml
637643
poetry:install-deps:
638-
desc: Install dependencies managed by Poetry
644+
desc: |
645+
Install dependencies managed by Poetry.
646+
Environment variable parameters:
647+
- POETRY_GROUPS: Poetry dependency groups to install (default: install all dependencies).
648+
run: when_changed
639649
deps:
640650
- task: poetry:install
641651
cmds:
642-
- poetry install
652+
- |
653+
poetry install \
654+
{{if .POETRY_GROUPS}} --only {{.POETRY_GROUPS}} {{end}}
643655
644656
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/poetry-task/Taskfile.yml
645657
poetry:update-deps:
@@ -654,6 +666,8 @@ tasks:
654666
desc: Format Python files
655667
deps:
656668
- task: poetry:install-deps
669+
vars:
670+
POETRY_GROUPS: dev
657671
cmds:
658672
- |
659673
poetry run \
@@ -665,6 +679,8 @@ tasks:
665679
desc: Lint Python code
666680
deps:
667681
- task: poetry:install-deps
682+
vars:
683+
POETRY_GROUPS: dev
668684
cmds:
669685
- |
670686
poetry run \
@@ -772,6 +788,8 @@ tasks:
772788
deps:
773789
- task: docs:generate
774790
- task: poetry:install-deps
791+
vars:
792+
POETRY_GROUPS: dev
775793
cmds:
776794
- |
777795
poetry run \
@@ -784,6 +802,8 @@ tasks:
784802
deps:
785803
- task: docs:generate
786804
- task: poetry:install-deps
805+
vars:
806+
POETRY_GROUPS: dev
787807
cmds:
788808
- |
789809
poetry run \

0 commit comments

Comments
 (0)