@@ -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 */
4545export 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 */
7271export 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