Skip to content

Commit 4e7f87a

Browse files
committed
chore(vscode): use uv to speed up e2e tests
1 parent 5ac6a11 commit 4e7f87a

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

.github/workflows/pr.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ jobs:
4242
uses: actions/setup-python@v5
4343
with:
4444
python-version: '3.12'
45+
- name: Install uv
46+
uses: astral-sh/setup-uv@v4
4547
- name: Install python dependencies
4648
run: |
4749
python -m venv .venv

vscode/extension/tests/utils.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,18 @@ export interface PythonEnvironment {
3939
}
4040

4141
/**
42-
* Create a virtual environment in the given directory.
42+
* Create a virtual environment in the given directory using uv.
4343
* @param venvDir The directory to create the virtual environment in.
4444
*/
4545
export const createVirtualEnvironment = async (
4646
venvDir: string,
4747
): Promise<PythonEnvironment> => {
48-
const pythonCmd = process.platform === 'win32' ? 'python' : 'python3'
49-
const { stderr, exitCode } = await execAsync(
50-
`${pythonCmd} -m venv "${venvDir}"`,
51-
)
48+
// Try to use uv first, fallback to python -m venv
49+
const { exitCode, stderr } = await execAsync(`uv venv "${venvDir}"`)
5250
if (exitCode !== 0) {
53-
throw new Error(`Failed to create venv: ${stderr}`)
51+
throw new Error(`Failed to create venv with uv: ${stderr}`)
5452
}
53+
5554
// Get paths
5655
const isWindows = process.platform === 'win32'
5756
const binDir = path.join(venvDir, isWindows ? 'Scripts' : 'bin')
@@ -65,19 +64,19 @@ export const createVirtualEnvironment = async (
6564
}
6665

6766
/**
68-
* Install packages in the given virtual environment.
67+
* Install packages in the given virtual environment using uv.
6968
* @param pythonDetails The Python environment to use.
7069
* @param packagePaths The paths to the packages to install (string[]).
7170
*/
7271
export const pipInstall = async (
7372
pythonDetails: PythonEnvironment,
7473
packagePaths: string[],
7574
): Promise<void> => {
76-
const { pipPath } = pythonDetails
77-
const execString = `"${pipPath}" install -e "${packagePaths.join('" -e "')}"`
75+
const packages = packagePaths.map(pkg => `-e "${pkg}"`).join(' ')
76+
const execString = `uv pip install --python "${pythonDetails.pythonPath}" ${packages}`
7877
const { stderr, exitCode } = await execAsync(execString)
7978
if (exitCode !== 0) {
80-
throw new Error(`Failed to install package: ${stderr}`)
79+
throw new Error(`Failed to install package with uv: ${stderr}`)
8180
}
8281
}
8382

0 commit comments

Comments
 (0)