11import * as ch from 'child_process' ;
22import { CancellationError , CancellationToken , LogOutputChannel } from 'vscode' ;
3- import { createDeferred } from '../../common/utils/deferred' ;
4- import { sendTelemetryEvent } from '../../common/telemetry/sender' ;
3+ import { EnvironmentGroupInfo } from '../../api' ;
54import { EventNames } from '../../common/telemetry/constants' ;
5+ import { sendTelemetryEvent } from '../../common/telemetry/sender' ;
6+ import { createDeferred } from '../../common/utils/deferred' ;
67import { getConfiguration } from '../../common/workspace.apis' ;
7- import { NativePythonEnvironmentKind } from '../common/nativePythonFinder' ;
88
99const available = createDeferred < boolean > ( ) ;
1010export async function isUvInstalled ( log ?: LogOutputChannel ) : Promise < boolean > {
@@ -28,33 +28,26 @@ export async function isUvInstalled(log?: LogOutputChannel): Promise<boolean> {
2828
2929/**
3030 * Determines if uv should be used for managing a virtual environment.
31- * @param envKind - The kind of environment (Venv, VenvUv, etc.)
32- * @param log - Optional log output channel
33- * @returns True if uv should be used, false otherwise
31+ * @param group - Optional environment group name (string) or EnvironmentGroupInfo object. If 'uv' or group.name is 'uv', uv will be used if available.
32+ * @param log - Optional log output channel for logging operations
33+ * @returns True if uv should be used, false otherwise. For 'uv' environments, returns true if uv is installed. For other environments, checks the 'python-envs.alwaysUseUv' setting and uv availability.
3434 */
35- export async function shouldUseUv (
36- envKind ?: NativePythonEnvironmentKind ,
37- log ?: LogOutputChannel ,
38- ) : Promise < boolean > {
39- // If the environment is explicitly a VenvUv type, always use uv
40- if ( envKind === NativePythonEnvironmentKind . venvUv ) {
35+ export async function shouldUseUv ( group ?: string | EnvironmentGroupInfo , log ?: LogOutputChannel ) : Promise < boolean > {
36+ if ( group === 'uv' || ( typeof group === 'object' && group . name === 'uv' ) ) {
37+ // Always use uv for VenvUv environments
4138 return await isUvInstalled ( log ) ;
4239 }
4340
44- // Check the alwaysUseUv setting
41+ // For other environments, check the user setting
4542 const config = getConfiguration ( 'python-envs' ) ;
4643 const alwaysUseUv = config . get < boolean > ( 'alwaysUseUv' , true ) ;
4744
48- // If alwaysUseUv is true and uv is installed, use it
4945 if ( alwaysUseUv ) {
5046 return await isUvInstalled ( log ) ;
5147 }
52-
53- // Otherwise, only use uv for VenvUv environments (already handled above)
5448 return false ;
5549}
5650
57-
5851export async function runUV (
5952 args : string [ ] ,
6053 cwd ?: string ,
0 commit comments