setup-python icon indicating copy to clipboard operation
setup-python copied to clipboard

Install with package manager

Open Cologler opened this issue 1 year ago • 6 comments

Description:

Currently, if we use poetry, we have to write two steps:

      - name: Install poetry
        run: pipx install poetry

      - name: Set up Python
        uses: actions/setup-python@v4
        with:
          python-version: ...
          cache: poetry

I hope this can be easier:

      - name: Set up Python
        uses: actions/setup-python@v4
        with:
          python-version: ...
          package-manager: poetry@{version}
          cache: poetry

Cologler avatar Apr 27 '23 00:04 Cologler

Hello @Cologler. Thank you for your feature request. We'll take a look on it.

dmitry-shibanov avatar Apr 27 '23 13:04 dmitry-shibanov

There is a "cart before the horse" issue here depending on the OS.

MacOS can install pipx with brew, but Linux and Windows must use python (see the docs here). Hence, you have to install python to install pipx and then poetry all before you can run actions/setup-python, by which point you've already installed python...?

I believe the action should install poetry as a post-step if cache: poetry is used and set up the cache.

adam-grant-hendry avatar Sep 15 '23 22:09 adam-grant-hendry

There is a "cart before the horse" issue here depending on the OS.

Oops, I forgot about pre-installed software on each runner, and they all have python and pipx. My mistake...

adam-grant-hendry avatar Sep 15 '23 22:09 adam-grant-hendry

There's a more general use-case here that would be very useful to me, where setup-poetry could install a list of global/system tools via pipx, such as: Poetry, Tox, PDM, Invoke, Poe, etc. The idea being for a way to express pipx-installable tools (and their versions) that setup-python would then take care of installing, including caching the respective virtualenvs (eg /opt/pipx/venvs/) and command (eg /opt/pipx_bin/).

An extra bonus would be a way to express this in the pyproject.toml (as an alternative to passing as input) through a field like [tool.setup-python.pipx] or something like that.

I intend to write a stand-alone action as a proof-of-concept and will report back.

BrandonLWhite avatar Dec 07 '23 17:12 BrandonLWhite

Here is an action I've published to fill this need: https://github.com/BrandonLWhite/pipx-install-action

I do envision that one day this functionality is incorporated directly in actions/setup-python, but until then, please try out my action and see if it meets your needs!

BrandonLWhite avatar Jan 11 '24 18:01 BrandonLWhite

Hello @Cologler. Thank you for your feature request. We'll take a look on it.

Will you accept a PR with this feature? With one more input: "cache-packet-manager: BOOL".

Privat33r-dev avatar May 04 '24 14:05 Privat33r-dev