mirror of
https://github.com/astral-sh/setup-uv.git
synced 2025-05-17 06:34:45 +00:00
new inputs activate-environment and working-directory (#381)
venv activation was implicit when python-version was supplied. This now only happens when activate-environment is true. working-directory controls where we work and thus also where the .venv will be created Closes: #351 Closes: #271 Closes: #251 Closes: #211
This commit is contained in:
parent
aa1290542e
commit
ec4c691628
9 changed files with 203 additions and 179 deletions
58
README.md
58
README.md
|
@ -15,8 +15,9 @@ Set up your GitHub Actions workflow with a specific version of [uv](https://docs
|
|||
- [Install the latest version](#install-the-latest-version)
|
||||
- [Install a specific version](#install-a-specific-version)
|
||||
- [Install a version by supplying a semver range or pep440 specifier](#install-a-version-by-supplying-a-semver-range-or-pep440-specifier)
|
||||
- [Install a required-version](#install-a-required-version)
|
||||
- [Python version](#python-version)
|
||||
- [Activate environment](#activate-environment)
|
||||
- [Working directory](#working-directory)
|
||||
- [Validate checksum](#validate-checksum)
|
||||
- [Enable Caching](#enable-caching)
|
||||
- [Cache dependency glob](#cache-dependency-glob)
|
||||
|
@ -90,32 +91,9 @@ to install the latest version that satisfies the range.
|
|||
version: ">=0.4.25,<0.5"
|
||||
```
|
||||
|
||||
### Install a required-version
|
||||
|
||||
You can specify a [required-version](https://docs.astral.sh/uv/reference/settings/#required-version)
|
||||
in either a `uv.toml` or `pyproject.toml` file:
|
||||
|
||||
```yaml
|
||||
- name: Install required-version defined in uv.toml
|
||||
uses: astral-sh/setup-uv@v5
|
||||
with:
|
||||
uv-file: "path/to/uv.toml"
|
||||
```
|
||||
|
||||
```yaml
|
||||
- name: Install required-version defined in pyproject.toml
|
||||
uses: astral-sh/setup-uv@v5
|
||||
with:
|
||||
pyproject-file: "path/to/pyproject.toml"
|
||||
```
|
||||
|
||||
### Python version
|
||||
|
||||
You can use the input `python-version` to
|
||||
|
||||
- set the environment variable `UV_PYTHON` for the rest of your workflow
|
||||
- create a new virtual environment with the specified python version
|
||||
- activate the virtual environment for the rest of your workflow
|
||||
You can use the input `python-version` to set the environment variable `UV_PYTHON` for the rest of your workflow
|
||||
|
||||
This will override any python version specifications in `pyproject.toml` and `.python-version`
|
||||
|
||||
|
@ -146,6 +124,34 @@ jobs:
|
|||
run: uv run --frozen pytest
|
||||
```
|
||||
|
||||
### Activate environment
|
||||
|
||||
You can set `activate-environment` to `true` to automatically activate a venv.
|
||||
This allows directly using it in later steps:
|
||||
|
||||
```yaml
|
||||
- name: Install the latest version of uv and activate the environment
|
||||
uses: astral-sh/setup-uv@v5
|
||||
with:
|
||||
activate-environment: true
|
||||
- run: uv pip install pip
|
||||
```
|
||||
|
||||
### Working directory
|
||||
|
||||
You can set the working directory with the `working-directory` input.
|
||||
This controls where we look for `pyproject.toml`, `uv.toml` and `.python-version` files
|
||||
which are used to determine the version of uv and python to install.
|
||||
|
||||
It also controls where [the venv gets created](#activate-environment).
|
||||
|
||||
```yaml
|
||||
- name: Install uv based on the config files in the working-directory
|
||||
uses: astral-sh/setup-uv@v5
|
||||
with:
|
||||
working-directory: my/subproject/dir
|
||||
```
|
||||
|
||||
### Validate checksum
|
||||
|
||||
You can specify a checksum to validate the downloaded executable. Checksums up to the default version
|
||||
|
@ -383,7 +389,7 @@ This action downloads uv from the uv repo's official
|
|||
[GitHub Actions Toolkit](https://github.com/actions/toolkit) to cache it as a tool to speed up
|
||||
consecutive runs on self-hosted runners.
|
||||
|
||||
The installed version of uv is then added to the runner PATH, enabling subsequent steps to invoke it
|
||||
The installed version of uv is then added to the runner PATH, enabling later steps to invoke it
|
||||
by name (`uv`).
|
||||
|
||||
## FAQ
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue