From 611c849f40bd1dbc0d0af6145acd62256f9137d0 Mon Sep 17 00:00:00 2001 From: Ahmed Ilyas Date: Wed, 24 Jul 2024 17:12:57 +0200 Subject: [PATCH 1/2] Use env variables in Github Actions docs --- docs/guides/integration/github.md | 43 ++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/docs/guides/integration/github.md b/docs/guides/integration/github.md index ac4d5961aa32..b9635951fadc 100644 --- a/docs/guides/integration/github.md +++ b/docs/guides/integration/github.md @@ -137,7 +137,36 @@ steps: ## 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 + ... +``` + +Or using a shell command: ```yaml title="example.yml" steps: @@ -145,6 +174,18 @@ steps: run: echo "UV_SYSTEM_PYTHON=1" >> $GITHUB_ENV ``` +iii. Step-specific Environment Variables + +Set the variable for a specific step: + +```yaml title="example.yml" +steps: + - name: Install requirements + 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. ```yaml title="example.yml" From c0ce652789762d9d9f5bcac9d7a6a1090e0c71bc Mon Sep 17 00:00:00 2001 From: Ahmed Ilyas Date: Wed, 24 Jul 2024 17:22:53 +0200 Subject: [PATCH 2/2] Remove shell command export for env --- docs/guides/integration/github.md | 8 -------- 1 file changed, 8 deletions(-) diff --git a/docs/guides/integration/github.md b/docs/guides/integration/github.md index b9635951fadc..07eed1054dd6 100644 --- a/docs/guides/integration/github.md +++ b/docs/guides/integration/github.md @@ -166,14 +166,6 @@ jobs: ... ``` -Or using a shell command: - -```yaml title="example.yml" -steps: - - name: Allow uv to use the system Python by default - run: echo "UV_SYSTEM_PYTHON=1" >> $GITHUB_ENV -``` - iii. Step-specific Environment Variables Set the variable for a specific step: