mirror of
https://github.com/astral-sh/setup-uv.git
synced 2025-10-19 09:07:00 +00:00
committed by
GitHub
parent
f9c6974d8b
commit
f2859da213
@@ -6,6 +6,7 @@ import {
|
||||
STATE_CACHE_KEY,
|
||||
STATE_CACHE_MATCHED_KEY,
|
||||
} from "./cache/restore-cache";
|
||||
import { STATE_UV_PATH } from "./utils/constants";
|
||||
import {
|
||||
cacheLocalPath,
|
||||
enableCache,
|
||||
@@ -91,7 +92,8 @@ async function pruneCache(): Promise<void> {
|
||||
const execArgs = ["cache", "prune", "--ci"];
|
||||
|
||||
core.info("Pruning cache...");
|
||||
await exec.exec("uv", execArgs, options);
|
||||
const uvPath = core.getState(STATE_UV_PATH);
|
||||
await exec.exec(uvPath, execArgs, options);
|
||||
}
|
||||
|
||||
run();
|
||||
|
@@ -9,6 +9,7 @@ import {
|
||||
resolveVersion,
|
||||
tryGetFromToolCache,
|
||||
} from "./download/download-version";
|
||||
import { STATE_UV_PATH } from "./utils/constants";
|
||||
import {
|
||||
activateEnvironment as activateEnvironmentInput,
|
||||
addProblemMatchers,
|
||||
@@ -163,18 +164,31 @@ async function determineVersion(
|
||||
|
||||
function addUvToPathAndOutput(cachedPath: string): void {
|
||||
core.setOutput("uv-path", `${cachedPath}${path.sep}uv`);
|
||||
core.saveState(STATE_UV_PATH, `${cachedPath}${path.sep}uv`);
|
||||
core.setOutput("uvx-path", `${cachedPath}${path.sep}uvx`);
|
||||
core.addPath(cachedPath);
|
||||
core.info(`Added ${cachedPath} to the path`);
|
||||
if (process.env.UV_NO_MODIFY_PATH !== undefined) {
|
||||
core.info("UV_NO_MODIFY_PATH is set, not modifying PATH");
|
||||
} else {
|
||||
core.addPath(cachedPath);
|
||||
core.info(`Added ${cachedPath} to the path`);
|
||||
}
|
||||
}
|
||||
|
||||
function addToolBinToPath(): void {
|
||||
if (toolBinDir !== undefined) {
|
||||
core.exportVariable("UV_TOOL_BIN_DIR", toolBinDir);
|
||||
core.info(`Set UV_TOOL_BIN_DIR to ${toolBinDir}`);
|
||||
core.addPath(toolBinDir);
|
||||
core.info(`Added ${toolBinDir} to the path`);
|
||||
if (process.env.UV_NO_MODIFY_PATH !== undefined) {
|
||||
core.info(`UV_NO_MODIFY_PATH is set, not adding ${toolBinDir} to path`);
|
||||
} else {
|
||||
core.addPath(toolBinDir);
|
||||
core.info(`Added ${toolBinDir} to the path`);
|
||||
}
|
||||
} else {
|
||||
if (process.env.UV_NO_MODIFY_PATH !== undefined) {
|
||||
core.info("UV_NO_MODIFY_PATH is set, not adding user local bin to path");
|
||||
return;
|
||||
}
|
||||
if (process.env.XDG_BIN_HOME !== undefined) {
|
||||
core.addPath(process.env.XDG_BIN_HOME);
|
||||
core.info(`Added ${process.env.XDG_BIN_HOME} to the path`);
|
||||
@@ -204,6 +218,11 @@ function setupPython(): void {
|
||||
|
||||
async function activateEnvironment(): Promise<void> {
|
||||
if (activateEnvironmentInput) {
|
||||
if (process.env.UV_NO_MODIFY_PATH !== undefined) {
|
||||
throw new Error(
|
||||
"UV_NO_MODIFY_PATH and activate-environment cannot be used together.",
|
||||
);
|
||||
}
|
||||
const execArgs = ["venv", ".venv", "--directory", workingDirectory];
|
||||
|
||||
core.info("Activating python venv...");
|
||||
|
@@ -1,3 +1,4 @@
|
||||
export const REPO = "uv";
|
||||
export const OWNER = "astral-sh";
|
||||
export const TOOL_CACHE_NAME = "uv";
|
||||
export const STATE_UV_PATH = "uv-path";
|
||||
|
Reference in New Issue
Block a user