Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 9 additions & 10 deletions vscode/extension/tests/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<PythonEnvironment> => {
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')
Expand All @@ -65,19 +64,19 @@ 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[]).
*/
export const pipInstall = async (
pythonDetails: PythonEnvironment,
packagePaths: string[],
): Promise<void> => {
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}`)
}
}

Expand Down