Skip to content

Commit 6158a48

Browse files
committed
Configure Poetry installation command to install project-defined version even when already installed
One of the reasons for adding the Poetry installation infrastructure to the project was to control the version of Poetry that is used by contributors and the infrastructure. The default behavior of the `pipx install` command is to skip the installation if Poetry is already installed, even though a different version is installed than that specified in the package version constraint, not even throwing an error exit status to communicate that the installation was not performed. It is possible to cause pipx to have the intended behavior of always installing the specified version by adding the `--force` flag to the command. Inexplicably, when this flag is added, pipx disregards the `--python` flag. During the initial development of the Poetry installation system, I found that if the path to Python is not specified then pipx will use the system installation of Python on the GitHub Actions runner machines instead of the installation of the project's standardized version of Python made via the actions/setup-python action. So now we must switch to using the PIPX_DEFAULT_PYTHON environment variable to configure which Python installation pipx should use.
1 parent 34022d1 commit 6158a48

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

Taskfile.yml

+5-4
Original file line numberDiff line numberDiff line change
@@ -384,9 +384,6 @@ tasks:
384384
poetry:install:
385385
desc: Install Poetry
386386
run: once
387-
vars:
388-
PYTHON_PATH:
389-
sh: task utility:normalize-path RAW_PATH="$(which python)"
390387
cmds:
391388
- |
392389
if ! which pipx &>/dev/null; then
@@ -401,8 +398,12 @@ tasks:
401398
exit 1
402399
fi
403400
- |
401+
export PIPX_DEFAULT_PYTHON="$( \
402+
task utility:normalize-path \
403+
RAW_PATH="$(which python)" \
404+
)"
404405
pipx install \
405-
--python "{{.PYTHON_PATH}}" \
406+
--force \
406407
"poetry==$( \
407408
yq \
408409
--input-format toml \

0 commit comments

Comments
 (0)