mirror of
https://github.com/actions/setup-python.git
synced 2025-12-10 22:55:20 +00:00
add small docs
Signed-off-by: Jean-Yves LENHOF <jeanyves.lenhof.partner@decathlon.com>
This commit is contained in:
parent
8f931468e4
commit
efb69ecd61
@ -24,6 +24,7 @@
|
||||
- [Allow pre-releases](advanced-usage.md#allow-pre-releases)
|
||||
- [Using the pip-version input](advanced-usage.md#using-the-pip-version-input)
|
||||
- [Using the pip-install input](advanced-usage.md#using-the-pip-install-input)
|
||||
- [Managing pip packages with preclean and postclean](advanced-usage.md#managing-pip-packages-with-preclean-and-postclean)
|
||||
|
||||
## Using the `python-version` input
|
||||
|
||||
@ -692,3 +693,63 @@ The `pip-install` input allows you to install dependencies as part of the Python
|
||||
For complex workflows, or alternative package managers (e.g., poetry, pipenv), we recommend using separate steps to maintain clarity and flexibility.
|
||||
|
||||
> The `pip-install` input mirrors the flexibility of a standard pip install command and supports most of its arguments.
|
||||
|
||||
## Managing pip packages with preclean and postclean
|
||||
|
||||
The `preclean` and `postclean` inputs provide control over pip package management during the action lifecycle.
|
||||
|
||||
### Using the preclean input
|
||||
|
||||
The `preclean` input removes all existing pip packages before installing new ones. This is useful when you want to ensure a clean environment without any pre-existing packages that might conflict with your dependencies.
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v6
|
||||
with:
|
||||
python-version: '3.13'
|
||||
pip-install: -r requirements.txt
|
||||
preclean: true
|
||||
```
|
||||
|
||||
When `preclean` is set to `true`, all pip packages will be removed before any new packages are installed via the `pip-install` input.
|
||||
|
||||
### Using the postclean input
|
||||
|
||||
The `postclean` input removes all pip packages installed by this action after the action completes. This is useful for cleanup purposes or when you want to ensure that packages installed during setup don't persist beyond the workflow's execution.
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v6
|
||||
with:
|
||||
python-version: '3.13'
|
||||
pip-install: pytest requests
|
||||
postclean: true
|
||||
- name: Run tests
|
||||
run: pytest
|
||||
```
|
||||
|
||||
When `postclean` is set to `true`, packages installed during the setup will be removed after the whole workflow completes successfully.
|
||||
|
||||
### Using both preclean and postclean
|
||||
|
||||
You can combine both inputs for complete package lifecycle management:
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v6
|
||||
with:
|
||||
python-version: '3.13'
|
||||
pip-install: -r requirements.txt
|
||||
preclean: true
|
||||
postclean: true
|
||||
- name: Run your script
|
||||
run: python my_script.py
|
||||
```
|
||||
|
||||
> Note: Both `preclean` and `postclean` default to `false`. Set them to `true` only when you need explicit package management control.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user