GeezerVison is showing github.com — Feature proposal: Integrate dependency support · Issue #77 · actions/setup-python
Feature proposal: Integrate dependency support #77DescriptionI think a most users of this action run an "install dependencies" step immediately after. I think it would improve the developer experience if the "install dependencies" step was integrated into this action.
Current workflow:
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
Option 1: Support installing packages with pip
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
pip-install: -r requirements.txt
# or if you use a different package manager...
# pip-install: pipenv
# - name: Install dependencies
# run: pipenv install
Option 2: Add full support for all package managers
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
# Pip
package-manager: pip
package-manager-args: -r requirements.txt
# Pipenv
package-manager: pipenv
package-manager-args: --pre --dev --deploy
# Poetry
package-manager: poetry
package-manager-args: --no-dev
What do you think? Option 1 is much smaller in scope than option 2, but I think both would be low maintenance (Python has a lot of package managers, but not that many). Reacted by Carl Anderson, Brian Rutledge, Bruno Alla, Rick Staa, cschaaf, Yury V. Zaytsev, Pascal Chorus, mm-matthias, Marcel Arns, offa and 11 more Activityzyv commented on Jan 3, 2021 We would very much like to use this action, because it will be a huge speed improvement as compared to pulling our pre-baked CI docker image. However, we absolutely need dependency management support - and specifically poetry. So sadly we can't switch until some kind of poetry support is implemented... Reacted by Pascal Chorus, Felix Hoffmann, Marcel Arns, mm-matthias, Christian Nicolai, Jeremy Witte, Viktor Andersson and Ram Vasuthevan omBratteng commented on Apr 30, 2021 omBratteng commented on Apr 30, 2021 Reacted by Yury V. Zaytsev zyv commented on Apr 30, 2021 We ended up creating an action to install Poetry after setting up Python - it's still faster than pulling a complete pre-baked docker image with the operating system:
https://github.com/moneymeets/action-setup-poetry
Adding poetry to the base action images would of course only make it better! omBratteng commented on May 5, 2021 They closed my PR, as they think because poetry only takes a few seconds to install, it is not needed in the action image, and using actions is better. ricardo-dematos commented on Sep 19, 2022 Like many of you, I also immediately run an "install dependencies" step after running this action, thus I've created a composite action:
name: 'Set up python'
description: 'Set up GitHub Actions workflow with a version of Python configured with our settings'
inputs:
python-version:
description: "Version range or exact version of Python to use, using SemVer's version range syntax"
required: false
default: '3.9'
python-requirements-file:
description: "Path to the python requirements file"
required: false
default: 'requirements.txt'
outputs:
python-path:
description: "The absolute path to the Python executable"
value: '${{ steps.python.outputs.python-path }}'
python-version:
description: "The installed and configured Python version"
value: '${{ steps.python.outputs.python-version }}'
cache-hit:
description: "A boolean value to indicate a cache entry was found"
value: '${{ steps.python.outputs.cache-hit }}'
runs:
using: composite
steps:
- id: python
uses: actions/setup-python@v4
with:
token: '${{ env.GITHUB_TOKEN }}'
python-version: '${{ inputs.python-version }}'
cache: 'pip'
cache-dependency-path: '${{ inputs.python-requirements-file }}'
- id: libxmlsec1-dev
run: sudo apt-get update && sudo apt-get --assume-yes install pkg-config libxmlsec1-dev
shell: bash
- id: requirements
run: pip install --exists-action w --requirement "${{ inputs.python-requirements-file }}"
shell: bash
The action documentation states:
The action has built-in functionality for caching and restoring dependencies. It uses toolkit/cache under the hood for caching dependencies but requires less configuration settings. Supported package managers are pip, pipenv and poetry. The cache input is optional, and caching is turned off by default.
The action defaults to searching for a dependency file (requirements.txt for pip, Pipfile.lock for pipenv or poetry.lock for poetry) in the repository, and uses its hash as a part of the cache key. Input cache-dependency-path is used for cases when multiple dependency files are used, they are located in different subdirectories or different files for the hash that want to be used.
This means that the inputs to run the "install dependencies" step are already available, at least for the currently supported package managers, thus this action could execute it in one go. brcrista commented on Sep 26, 2022 My usual take on this is that actions should follow the Unix philosophy. But in this case, by adding built-in dependency caching, we’ve already tightly coupled with the popular Python package managers. We'd welcome a PR for this if anyone wants to take that on. v-gowridurgad commented on Sep 18, 2025 Hi everyone,
We’ve raised PR #1201 to address the above requirement by introducing support for a new pip-install input, allowing dependencies to be installed directly via actions/setup-python. This implementation currently supports only pip. Please validate it against the requirement and confirm. Any feedback or suggestions would be welcome.
Thanks in advance! v-gowridurgad commented on Sep 29, 2025 Hi everyone,
We’re excited to to share that this feature has been implemented in PR #1201. This update introduces support for a new pip-install input, allowing dependencies to be installed directly via actions/setup-python.
To start using this feature, you can use the actions/setup-python@main branch in your workflows for now, and the changes will be reflected in the upcoming releases.
We’ll be closing this issue. Please feel free to reach out if you have any further concerns or need additional assistance. zyv commented on Sep 29, 2025 @gowridurgad It would be great to provide an example in the README of how to use the new input with pyproject.toml. I assume this should work without any issues. No one wants to deal with requirements.txt in 2025! v-gowridurgad commented on Oct 1, 2025 Hi @zyv, Thanks for the feedback!
Currently, the pip-install input feature has been implemented to support only pip, and pip does not read or install dependencies directly from pyproject.toml (e.g. [tool.poetry.dependencies] ).
This behaviour is a known limitation. For reference, please see:
Support for other package managers like Poetry or Pipenv is not included yet, but we’re definitely considering adding it in the future based on community demand.
For now, if you're using Poetry or another package manager, you’ll need to run those install commands in a separate step after setting up Python.
We appreciate your understanding and contributions. zyv commented on Oct 6, 2025
Currently, the pip-install input feature has been implemented to support only pip, and pip does not read or install dependencies directly from pyproject.toml (e.g. [tool.poetry.dependencies] ).
This behaviour is a known limitation.
@gowridurgad this is not correct; pip does support the installation from standard pyproject.toml key (project.dependencies) and was able to do so for a long time now. The only downside is that it installs the project itself in addition to the dependencies, but for most projects this actually isn't an issue. The issue of not installing the project itself is tracked here:
The syntax for pip to install the dependencies from pyproject.toml is pip install . - if you can support this, then most projects using the standard layout (e.g. because they use uv) will be automatically supported.
I only find it logical to allow pip install . with this action if -r has been implemented to avoid the need of pulling in more actions and/or writing more commands. v-gowridurgad commented on Oct 10, 2025 Hi @zyv, thank you for following up. You are absolutely correct, pip can install dependencies specified in the standard [project.dependencies] section of pyproject.toml via pip install ..
My previous response was specifically referring to [tool.poetry.dependencies], which pip does not natively support for reading or installing dependencies.
To clarify, the pip-install input does support pip install . and will install everything defined under [project.dependencies] in pyproject.toml.
The following step can be used in a workflow to install the dependencies:
name: Set up Python
uses: actions/setup-python@main
with:
python-version: '3.11'
cache: pip
pip-install: .
If there are any further suggestions or feedback, please let us know. zyv commented on Oct 10, 2025
name: Set up Python
uses: actions/setup-python@main
with:
python-version: '3.11'
cache: pip
pip-install: .
If there are any further suggestions or feedback, please let us know.
@gowridurgad Yes, see above. My suggestion is to document exactly that in the README, so that people know that they can use the action to install dependencies automatically without any further actions if they use the standard [project.dependencies] key. v-gowridurgad commented on Oct 22, 2025 Hi @zyv, Regarding the suggestion to document the usage of pip install with pyproject.toml, since there is already an example in the README demonstrating how to use the pip-install input, a clarifying note has been added in this PR #1199 instead of adding another example to avoid repetition and maintain concise documentation. The note would state:
Note: The pip-install input mirrors the flexibility of a standard pip install command and supports most of its arguments.
This should make it clear to users that the pip-install input can be used with a wide range of standard pip install command options, including installing from pyproject.toml with pip install ., without the need for multiple examples for every use case.
If you have any further suggestions or feedback, please let us know!
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|