Skip to content

Commit

Permalink
Install poetry with pip (not pipx) in test jobs
Browse files Browse the repository at this point in the history
This is imperfect, but it allows the correct version of Python
to be installed and used with minimal complexity and special
casing. Furthermore, because poetry is being used and the project
is being installed in a virtual environment, polluting the global
Python environment with poetry itself and its dependencies is
unlikely to hide unstated dependency bugs or cause conflicts.

On Ubuntu runners, pipx works with whatever version of Python is
installed by setup-python, and commands like "python3.10" are
available in $PATH for pipx to find and use. That is not the case
on other GitHub Actions runners, however. This is especially a
problem on Windows, where even obtaining the full path to the
interpreter cannot be done in any straightforward portable way.
(setup-python provides the Python directory in the pythonLocation
Python_ROOT_DIR etc. environment variables, but where the Python
interpeter is in it can differ by OS. This is practical, though
cumbersome, to solve when only CPython is used. But if pypy is also
used, which may be desired at some point in the future, then even
more special-casing is required, on Windows.)
  • Loading branch information
EliahKagan committed Sep 17, 2023
1 parent 836293f commit ff16cf6
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion .github/actions/poetry_setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,20 @@ runs:
~/.cache/pip
key: pip-${{ runner.os }}-${{ runner.arch }}-py-${{ inputs.python-version }}

- run: pipx install poetry==${{ inputs.poetry-version }} --python python${{ inputs.python-version }}
- name: Update PyPI packages
shell: bash
run: |
python -m pip install -U pip wheel
# Python prior to 3.12 ships setuptools. Upgrade it if present.
if pip freeze --all | grep -q '^setuptools=='; then
python -m pip install -U setuptools
fi
- name: Install Poetry
shell: bash
run: |
pip install poetry==${{ inputs.poetry-version }}
- name: Check Poetry File
shell: bash
Expand Down

0 comments on commit ff16cf6

Please sign in to comment.