@@ -132,6 +132,14 @@ async function findConda(): Promise<readonly string[] | undefined> {
132132 }
133133}
134134
135+ /**
136+ * Resolves the path to the conda executable using multiple fallback strategies:
137+ * 1. Cached path if available
138+ * 2. Previously saved path from persistent workspace state
139+ * 3. Search in system PATH
140+ * 4. Query native finder for conda installations
141+ * Throws if conda cannot be found through any method.
142+ */
135143async function getCondaExecutable ( native ?: NativePythonFinder ) : Promise < string > {
136144 if ( condaPath ) {
137145 traceInfo ( `Using conda from cache: ${ condaPath } ` ) ;
@@ -180,6 +188,11 @@ export async function getConda(native?: NativePythonFinder): Promise<string> {
180188 return await getCondaExecutable ( native ) ;
181189}
182190
191+ /**
192+ * Internal function to execute conda commands with proper error handling, logging, and cancellation support.
193+ * Spawns a shell process to run conda and collects both stdout and stderr output.
194+ * Handles command cancellation and non-zero exit codes.
195+ */
183196async function _runConda (
184197 conda : string ,
185198 args : string [ ] ,
@@ -280,6 +293,12 @@ function isPrefixOf(roots: string[], e: string): boolean {
280293 return false ;
281294}
282295
296+ /**
297+ * Constructs environment info for a named conda environment with shell-specific activation/deactivation commands.
298+ * Handles different shell types (bash, zsh, cmd, powershell, git bash) and their specific activation requirements.
299+ * For absolute conda paths, includes the full conda.sh/conda-hook.ps1 activation sequence.
300+ * For conda on PATH, uses direct conda activate/deactivate commands.
301+ */
283302async function getNamedCondaPythonInfo (
284303 name : string ,
285304 prefix : string ,
@@ -468,6 +487,10 @@ async function getPrefixesCondaPythonInfo(
468487 } ;
469488}
470489
490+ /**
491+ * Creates a special PythonEnvironmentInfo object for conda environments that don't have Python installed.
492+ * These environments are marked with a stop icon and version 'no-python' to indicate their incomplete state.
493+ */
471494function getCondaWithoutPython ( name : string , prefix : string , conda : string ) : PythonEnvironmentInfo {
472495 return {
473496 name : name ,
@@ -487,6 +510,14 @@ function getCondaWithoutPython(name: string, prefix: string, conda: string): Pyt
487510 } ;
488511}
489512
513+ /**
514+ * Converts a native environment info object (found via PET) into a Python environment object.
515+ * Handles different types of conda environments:
516+ * - Base environment
517+ * - Named environments in conda prefixes
518+ * - Prefix-based environments outside conda prefixes
519+ * - Environments without Python installed
520+ */
490521async function nativeToPythonEnv (
491522 e : NativeEnvInfo ,
492523 api : PythonEnvironmentApi ,
@@ -551,6 +582,11 @@ export async function resolveCondaPath(
551582 }
552583}
553584
585+ /**
586+ * Discovers and refreshes the list of conda environments in the system.
587+ * Uses the native finder (PET) to detect environments (both on and not on the PATH) and converts them to PythonEnvironment objects.
588+ * Returns a sorted list of all found conda environments.
589+ */
554590export async function refreshCondaEnvs (
555591 hardRefresh : boolean ,
556592 nativeFinder : NativePythonFinder ,
@@ -629,6 +665,13 @@ async function getLocation(api: PythonEnvironmentApi, uris: Uri | Uri[]): Promis
629665 return api . getPythonProject ( Array . isArray ( uris ) ? uris [ 0 ] : uris ) ?. uri . fsPath ;
630666}
631667
668+ /**
669+ * Creates a new conda environment with user interaction to determine the type and location.
670+ * Supports two types of environments:
671+ * 1. Named environments (stored in conda's envs directory)
672+ * 2. Prefix environments (stored in a specific location)
673+ * Handles both single and multi-project scenarios for environment creation.
674+ */
632675export async function createCondaEnvironment (
633676 api : PythonEnvironmentApi ,
634677 log : LogOutputChannel ,
@@ -891,6 +934,13 @@ export async function refreshPackages(
891934 return packages ;
892935}
893936
937+ /**
938+ * Handles package installation, uninstallation and updates in a conda environment.
939+ * Can perform multiple operations in sequence:
940+ * 1. Uninstall specified packages
941+ * 2. Install new packages with optional upgrade of existing packages
942+ * Returns the updated list of installed packages after operations complete.
943+ */
894944export async function managePackages (
895945 environment : PythonEnvironment ,
896946 options : PackageManagementOptions ,
0 commit comments