diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 381bb4c58e..77ec906b13 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -42,6 +42,8 @@ jobs: uses: actions/setup-python@v5 with: python-version: '3.12' + - name: Install uv + uses: astral-sh/setup-uv@v4 - name: Install python dependencies run: | python -m venv .venv diff --git a/vscode/extension/tests/utils.ts b/vscode/extension/tests/utils.ts index e765487b0d..d6a2ac7aaa 100644 --- a/vscode/extension/tests/utils.ts +++ b/vscode/extension/tests/utils.ts @@ -39,19 +39,18 @@ export interface PythonEnvironment { } /** - * Create a virtual environment in the given directory. + * Create a virtual environment in the given directory using uv. * @param venvDir The directory to create the virtual environment in. */ export const createVirtualEnvironment = async ( venvDir: string, ): Promise => { - const pythonCmd = process.platform === 'win32' ? 'python' : 'python3' - const { stderr, exitCode } = await execAsync( - `${pythonCmd} -m venv "${venvDir}"`, - ) + // Try to use uv first, fallback to python -m venv + const { exitCode, stderr } = await execAsync(`uv venv "${venvDir}"`) if (exitCode !== 0) { - throw new Error(`Failed to create venv: ${stderr}`) + throw new Error(`Failed to create venv with uv: ${stderr}`) } + // Get paths const isWindows = process.platform === 'win32' const binDir = path.join(venvDir, isWindows ? 'Scripts' : 'bin') @@ -65,7 +64,7 @@ export const createVirtualEnvironment = async ( } /** - * Install packages in the given virtual environment. + * Install packages in the given virtual environment using uv. * @param pythonDetails The Python environment to use. * @param packagePaths The paths to the packages to install (string[]). */ @@ -73,11 +72,11 @@ export const pipInstall = async ( pythonDetails: PythonEnvironment, packagePaths: string[], ): Promise => { - const { pipPath } = pythonDetails - const execString = `"${pipPath}" install -e "${packagePaths.join('" -e "')}"` + const packages = packagePaths.map(pkg => `-e "${pkg}"`).join(' ') + const execString = `uv pip install --python "${pythonDetails.pythonPath}" ${packages}` const { stderr, exitCode } = await execAsync(execString) if (exitCode !== 0) { - throw new Error(`Failed to install package: ${stderr}`) + throw new Error(`Failed to install package with uv: ${stderr}`) } }