mirror of
https://github.com/astral-sh/uv.git
synced 2025-09-27 04:29:10 +00:00
Use env variables in Github Actions docs (#5411)
## Summary Use [Github Actions](https://docs.github.com/en/actions/learn-github-actions/variables#defining-environment-variables-for-a-single-workflow) `env` to define environment variables. After: <img width="751" alt="Screenshot 2024-07-24 at 17 24 23" src="https://github.com/user-attachments/assets/9c7861f0-e95d-4778-96c0-261df539a0bd">
This commit is contained in:
parent
4bc04f91e9
commit
b304d66719
1 changed files with 36 additions and 3 deletions
|
@ -137,12 +137,45 @@ steps:
|
||||||
|
|
||||||
## Using `uv pip`
|
## Using `uv pip`
|
||||||
|
|
||||||
If using the `uv pip` interface instead of the uv project interface, uv requires a virtual environment by default. To allow installing packages into the system environment, use the `--system` flag on all `uv` invocations or set the `UV_SYSTEM_PYTHON` variable, e.g.:
|
If using the `uv pip` interface instead of the uv project interface, uv requires a virtual environment by default. To allow installing packages into the system environment, use the `--system` flag on all `uv` invocations or set the `UV_SYSTEM_PYTHON` variable.
|
||||||
|
|
||||||
|
### Setting `UV_SYSTEM_PYTHON`
|
||||||
|
|
||||||
|
`UV_SYSTEM_PYTHON` variable can be defined in various scopes:
|
||||||
|
|
||||||
|
i. Workflow-wide Environment Variables
|
||||||
|
|
||||||
|
Set the variable for the entire workflow by defining it at the top level:
|
||||||
|
|
||||||
|
```yaml title="example.yml"
|
||||||
|
env:
|
||||||
|
UV_SYSTEM_PYTHON: 1
|
||||||
|
|
||||||
|
jobs: ...
|
||||||
|
```
|
||||||
|
|
||||||
|
ii. Job-specific Environment Variables
|
||||||
|
|
||||||
|
Set the variable for a specific job within the workflow:
|
||||||
|
|
||||||
|
```yaml title="example.yml"
|
||||||
|
jobs:
|
||||||
|
install_job:
|
||||||
|
env:
|
||||||
|
UV_SYSTEM_PYTHON: 1
|
||||||
|
...
|
||||||
|
```
|
||||||
|
|
||||||
|
iii. Step-specific Environment Variables
|
||||||
|
|
||||||
|
Set the variable for a specific step:
|
||||||
|
|
||||||
```yaml title="example.yml"
|
```yaml title="example.yml"
|
||||||
steps:
|
steps:
|
||||||
- name: Allow uv to use the system Python by default
|
- name: Install requirements
|
||||||
run: echo "UV_SYSTEM_PYTHON=1" >> $GITHUB_ENV
|
run: uv pip install -r requirements.txt
|
||||||
|
env:
|
||||||
|
UV_SYSTEM_PYTHON: 1
|
||||||
```
|
```
|
||||||
|
|
||||||
Now, `uv pip` can modify the system environment without creating and activating a virtual environment.
|
Now, `uv pip` can modify the system environment without creating and activating a virtual environment.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue