diff --git a/Taskfile.yml b/Taskfile.yml index 8d972e75..78f4af30 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -827,9 +827,10 @@ tasks: -r "{{.STYLELINTRC_SCHEMA_PATH}}" \ -d "{{.INSTANCE_PATH}}" - # Print the version constraint for the project's Poetry tool dependency. # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/poetry-task/Taskfile.yml - poetry:get-version: + poetry:install: + desc: Install Poetry + run: once cmds: - | if ! which yq &>/dev/null; then @@ -837,25 +838,18 @@ tasks: echo "Please install: https://github.com/mikefarah/yq/#install" exit 1 fi - - | - yq \ - --input-format toml \ - --output-format yaml \ - '.tool.poetry.group.pipx.dependencies.poetry' \ - < pyproject.toml - - # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/poetry-task/Taskfile.yml - poetry:install: - desc: Install Poetry - run: once - vars: - POETRY_VERSION: - sh: task poetry:get-version - cmds: - | if ! which python &>/dev/null; then + python_constraint="$( \ + yq \ + --input-format toml \ + --output-format yaml \ + '.tool.poetry.dependencies.python' \ + < pyproject.toml + )" + echo "Python not found or not in PATH." - echo "Please install a version of Python meeting the constraint {{.POETRY_VERSION}}:" + echo "Please install a version of Python satisfying the constraint ${python_constraint}:" echo "https://wiki.python.org/moin/BeginnersGuide/Download" exit 1 fi @@ -870,9 +864,18 @@ tasks: task utility:normalize-path \ RAW_PATH="$(which python)" \ )" + + poetry_constraint="$( \ + yq \ + --input-format toml \ + --output-format yaml \ + '.tool.poetry.group.pipx.dependencies.poetry' \ + < pyproject.toml + )" + pipx install \ --force \ - "poetry=={{.POETRY_VERSION}}" + "poetry==$poetry_constraint" # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/poetry-task/Taskfile.yml poetry:install-deps: diff --git a/workflow-templates/assets/poetry-task/Taskfile.yml b/workflow-templates/assets/poetry-task/Taskfile.yml index 678f475e..12a0597a 100644 --- a/workflow-templates/assets/poetry-task/Taskfile.yml +++ b/workflow-templates/assets/poetry-task/Taskfile.yml @@ -2,9 +2,10 @@ version: "3" tasks: - # Print the version constraint for the project's Poetry tool dependency. # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/poetry-task/Taskfile.yml - poetry:get-version: + poetry:install: + desc: Install Poetry + run: once cmds: - | if ! which yq &>/dev/null; then @@ -12,25 +13,18 @@ tasks: echo "Please install: https://github.com/mikefarah/yq/#install" exit 1 fi - - | - yq \ - --input-format toml \ - --output-format yaml \ - '.tool.poetry.group.pipx.dependencies.poetry' \ - < pyproject.toml - - # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/poetry-task/Taskfile.yml - poetry:install: - desc: Install Poetry - run: once - vars: - POETRY_VERSION: - sh: task poetry:get-version - cmds: - | if ! which python &>/dev/null; then + python_constraint="$( \ + yq \ + --input-format toml \ + --output-format yaml \ + '.tool.poetry.dependencies.python' \ + < pyproject.toml + )" + echo "Python not found or not in PATH." - echo "Please install a version of Python meeting the constraint {{.POETRY_VERSION}}:" + echo "Please install a version of Python satisfying the constraint ${python_constraint}:" echo "https://wiki.python.org/moin/BeginnersGuide/Download" exit 1 fi @@ -45,9 +39,18 @@ tasks: task utility:normalize-path \ RAW_PATH="$(which python)" \ )" + + poetry_constraint="$( \ + yq \ + --input-format toml \ + --output-format yaml \ + '.tool.poetry.group.pipx.dependencies.poetry' \ + < pyproject.toml + )" + pipx install \ --force \ - "poetry=={{.POETRY_VERSION}}" + "poetry==$poetry_constraint" # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/poetry-task/Taskfile.yml poetry:install-deps: