Skip to content

Commit a7ac767

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 3601b0a commit a7ac767

File tree

4 files changed

+82
-64
lines changed

4 files changed

+82
-64
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
@@ -234,6 +234,8 @@ tasks:
234234
desc: Check for commonly misspelled words
235235
deps:
236236
- task: poetry:install-deps
237+
vars:
238+
POETRY_GROUPS: dev
237239
cmds:
238240
- poetry run codespell
239241

@@ -242,6 +244,8 @@ tasks:
242244
desc: Correct commonly misspelled words where possible
243245
deps:
244246
- task: poetry:install-deps
247+
vars:
248+
POETRY_GROUPS: dev
245249
cmds:
246250
- |
247251
poetry run \
@@ -378,6 +382,8 @@ tasks:
378382
- task: go:build
379383
- task: go:rule-docs:build
380384
- task: poetry:install-deps
385+
vars:
386+
POETRY_GROUPS: dev
381387
cmds:
382388
- |
383389
poetry run \
@@ -636,11 +642,17 @@ tasks:
636642
637643
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/poetry-task/Taskfile.yml
638644
poetry:install-deps:
639-
desc: Install dependencies managed by Poetry
645+
desc: |
646+
Install dependencies managed by Poetry.
647+
Environment variable parameters:
648+
- POETRY_GROUPS: Poetry dependency groups to install (default: install all dependencies).
649+
run: when_changed
640650
deps:
641651
- task: poetry:install
642652
cmds:
643-
- poetry install
653+
- |
654+
poetry install \
655+
{{if .POETRY_GROUPS}} --only {{.POETRY_GROUPS}} {{end}}
644656
645657
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/poetry-task/Taskfile.yml
646658
poetry:update-deps:
@@ -655,6 +667,8 @@ tasks:
655667
desc: Format Python files
656668
deps:
657669
- task: poetry:install-deps
670+
vars:
671+
POETRY_GROUPS: dev
658672
cmds:
659673
- |
660674
poetry run \
@@ -666,6 +680,8 @@ tasks:
666680
desc: Lint Python code
667681
deps:
668682
- task: poetry:install-deps
683+
vars:
684+
POETRY_GROUPS: dev
669685
cmds:
670686
- |
671687
poetry run \
@@ -773,6 +789,8 @@ tasks:
773789
deps:
774790
- task: docs:generate
775791
- task: poetry:install-deps
792+
vars:
793+
POETRY_GROUPS: dev
776794
cmds:
777795
- |
778796
poetry run \
@@ -785,6 +803,8 @@ tasks:
785803
deps:
786804
- task: docs:generate
787805
- task: poetry:install-deps
806+
vars:
807+
POETRY_GROUPS: dev
788808
cmds:
789809
- |
790810
poetry run \

0 commit comments

Comments
 (0)