Skip to content

Commit

Permalink
Auto activate venv when python-version is set
Browse files Browse the repository at this point in the history
  • Loading branch information
eifinger committed Dec 13, 2024
1 parent 856099c commit a3f221d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 9 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -155,5 +155,4 @@ jobs:
if [ "$UV_PYTHON" != "${{ matrix.python-version }}" ]; then
exit 1
fi
- run: uv sync
working-directory: __tests__/fixtures/uv-project
- run: uv pip install --python=${{ matrix.python-version }} -i https://pypi.anaconda.org/scientific-python-nightly-wheels/simple cython
19 changes: 14 additions & 5 deletions dist/setup/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 10 additions & 2 deletions src/setup-uv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
toolDir,
version,
} from "./utils/inputs";
import * as exec from "@actions/exec";

async function run(): Promise<void> {
const platform = getPlatform();
Expand All @@ -46,7 +47,7 @@ async function run(): Promise<void> {
addUvToPath(setupResult.uvDir);
addToolBinToPath();
setToolDir();
setupPython();
await setupPython();
addMatchers();
setCacheDir(cacheLocalPath);

Expand Down Expand Up @@ -125,10 +126,17 @@ function setToolDir(): void {
}
}

function setupPython(): void {
async function setupPython(): Promise<void> {
if (pythonVersion !== "") {
core.exportVariable("UV_PYTHON", pythonVersion);
core.info(`Set UV_PYTHON to ${pythonVersion}`);
const options: exec.ExecOptions = {
silent: !core.isDebug(),
};
const execArgs = ["venv", "--python", pythonVersion];

core.info("Activating python venv...");
await exec.exec("uv", execArgs, options);
}
}

Expand Down

0 comments on commit a3f221d

Please sign in to comment.