Skip to content

Commit 4aa8111

Browse files
authored
Merge pull request #605 from per1234/correct-python-error
Correct constraint extraction code for Python not installed error message
2 parents 328a48c + 0838eb9 commit 4aa8111

File tree

2 files changed

+44
-38
lines changed

2 files changed

+44
-38
lines changed

Taskfile.yml

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -827,35 +827,29 @@ tasks:
827827
-r "{{.STYLELINTRC_SCHEMA_PATH}}" \
828828
-d "{{.INSTANCE_PATH}}"
829829
830-
# Print the version constraint for the project's Poetry tool dependency.
831830
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/poetry-task/Taskfile.yml
832-
poetry:get-version:
831+
poetry:install:
832+
desc: Install Poetry
833+
run: once
833834
cmds:
834835
- |
835836
if ! which yq &>/dev/null; then
836837
echo "yq not found or not in PATH."
837838
echo "Please install: https://github.com/mikefarah/yq/#install"
838839
exit 1
839840
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:
855841
- |
856842
if ! which python &>/dev/null; then
843+
python_constraint="$( \
844+
yq \
845+
--input-format toml \
846+
--output-format yaml \
847+
'.tool.poetry.dependencies.python' \
848+
< pyproject.toml
849+
)"
850+
857851
echo "Python not found or not in PATH."
858-
echo "Please install a version of Python meeting the constraint {{.POETRY_VERSION}}:"
852+
echo "Please install a version of Python satisfying the constraint ${python_constraint}:"
859853
echo "https://wiki.python.org/moin/BeginnersGuide/Download"
860854
exit 1
861855
fi
@@ -870,9 +864,18 @@ tasks:
870864
task utility:normalize-path \
871865
RAW_PATH="$(which python)" \
872866
)"
867+
868+
poetry_constraint="$( \
869+
yq \
870+
--input-format toml \
871+
--output-format yaml \
872+
'.tool.poetry.group.pipx.dependencies.poetry' \
873+
< pyproject.toml
874+
)"
875+
873876
pipx install \
874877
--force \
875-
"poetry=={{.POETRY_VERSION}}"
878+
"poetry==$poetry_constraint"
876879
877880
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/poetry-task/Taskfile.yml
878881
poetry:install-deps:

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

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,29 @@
22
version: "3"
33

44
tasks:
5-
# Print the version constraint for the project's Poetry tool dependency.
65
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/poetry-task/Taskfile.yml
7-
poetry:get-version:
6+
poetry:install:
7+
desc: Install Poetry
8+
run: once
89
cmds:
910
- |
1011
if ! which yq &>/dev/null; then
1112
echo "yq not found or not in PATH."
1213
echo "Please install: https://github.com/mikefarah/yq/#install"
1314
exit 1
1415
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:
3016
- |
3117
if ! which python &>/dev/null; then
18+
python_constraint="$( \
19+
yq \
20+
--input-format toml \
21+
--output-format yaml \
22+
'.tool.poetry.dependencies.python' \
23+
< pyproject.toml
24+
)"
25+
3226
echo "Python not found or not in PATH."
33-
echo "Please install a version of Python meeting the constraint {{.POETRY_VERSION}}:"
27+
echo "Please install a version of Python satisfying the constraint ${python_constraint}:"
3428
echo "https://wiki.python.org/moin/BeginnersGuide/Download"
3529
exit 1
3630
fi
@@ -45,9 +39,18 @@ tasks:
4539
task utility:normalize-path \
4640
RAW_PATH="$(which python)" \
4741
)"
42+
43+
poetry_constraint="$( \
44+
yq \
45+
--input-format toml \
46+
--output-format yaml \
47+
'.tool.poetry.group.pipx.dependencies.poetry' \
48+
< pyproject.toml
49+
)"
50+
4851
pipx install \
4952
--force \
50-
"poetry=={{.POETRY_VERSION}}"
53+
"poetry==$poetry_constraint"
5154
5255
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/poetry-task/Taskfile.yml
5356
poetry:install-deps:

0 commit comments

Comments
 (0)