@@ -77,56 +77,10 @@ export function getPrefixFromInterpreterPath(interpreterPath: string): string {
7777async function findPixiOnPath ( ) : Promise < readonly string [ ] > {
7878 try {
7979 return await which ( 'pixi' , { all : true } ) ;
80- } catch { }
81- return [ ] ;
82- }
83-
84- async function getPixiTool ( ) : Promise < Pixi | undefined > {
85- let pixi = getPythonSetting < string > ( PIXITOOLPATH_SETTING_KEY ) ;
86-
87- if ( ! pixi || pixi === 'pixi' || ! ( await pathExists ( pixi ) ) ) {
88- pixi = undefined ;
89- const paths = await findPixiOnPath ( ) ;
90- for ( let p of paths ) {
91- if ( await pathExists ( p ) ) {
92- pixi = p ;
93- break ;
94- }
95- }
80+ } catch {
81+ // Ignore errors
9682 }
97-
98- if ( ! pixi ) {
99- // Check the default installation location
100- const home = getUserHomeDir ( ) ;
101- if ( home ) {
102- const pixiToolPath = path . join ( home , '.pixi' , 'bin' , isWindows ( ) ? 'pixi.exe' : 'pixi' ) ;
103- if ( await pathExists ( pixiToolPath ) ) {
104- pixi = pixiToolPath ;
105- }
106- }
107- }
108-
109- return pixi ? new Pixi ( pixi ) : undefined ;
110- }
111-
112- /**
113- * Locating pixi binary can be expensive, since it potentially involves spawning or
114- * trying to spawn processes; so we only do it once per session.
115- */
116- let _pixi : Promise < Pixi | undefined > | undefined ;
117-
118- /**
119- * Returns a Pixi instance corresponding to the binary which can be used to run commands for the cwd.
120- *
121- * Pixi commands can be slow and so can be bottleneck to overall discovery time. So trigger command
122- * execution as soon as possible. To do that we need to ensure the operations before the command are
123- * performed synchronously.
124- */
125- export function getPixi ( ) {
126- if ( _pixi === undefined || isTestExecution ( ) ) {
127- _pixi = getPixiTool ( ) ;
128- }
129- return _pixi ;
83+ return [ ] ;
13084}
13185
13286/** Wraps the "pixi" utility, and exposes its functionality.
@@ -215,6 +169,54 @@ export class Pixi {
215169 }
216170}
217171
172+ async function getPixiTool ( ) : Promise < Pixi | undefined > {
173+ let pixi = getPythonSetting < string > ( PIXITOOLPATH_SETTING_KEY ) ;
174+
175+ if ( ! pixi || pixi === 'pixi' || ! ( await pathExists ( pixi ) ) ) {
176+ pixi = undefined ;
177+ const paths = await findPixiOnPath ( ) ;
178+ for ( const p of paths ) {
179+ if ( await pathExists ( p ) ) {
180+ pixi = p ;
181+ break ;
182+ }
183+ }
184+ }
185+
186+ if ( ! pixi ) {
187+ // Check the default installation location
188+ const home = getUserHomeDir ( ) ;
189+ if ( home ) {
190+ const pixiToolPath = path . join ( home , '.pixi' , 'bin' , isWindows ( ) ? 'pixi.exe' : 'pixi' ) ;
191+ if ( await pathExists ( pixiToolPath ) ) {
192+ pixi = pixiToolPath ;
193+ }
194+ }
195+ }
196+
197+ return pixi ? new Pixi ( pixi ) : undefined ;
198+ }
199+
200+ /**
201+ * Locating pixi binary can be expensive, since it potentially involves spawning or
202+ * trying to spawn processes; so we only do it once per session.
203+ */
204+ let _pixi : Promise < Pixi | undefined > | undefined ;
205+
206+ /**
207+ * Returns a Pixi instance corresponding to the binary which can be used to run commands for the cwd.
208+ *
209+ * Pixi commands can be slow and so can be bottleneck to overall discovery time. So trigger command
210+ * execution as soon as possible. To do that we need to ensure the operations before the command are
211+ * performed synchronously.
212+ */
213+ export function getPixi ( ) : Promise < Pixi | undefined > {
214+ if ( _pixi === undefined || isTestExecution ( ) ) {
215+ _pixi = getPixiTool ( ) ;
216+ }
217+ return _pixi ;
218+ }
219+
218220export type PixiEnvironmentInfo = {
219221 interpreterPath : string ;
220222 pixi : Pixi ;
@@ -300,6 +302,8 @@ export async function getPixiEnvironmentFromInterpreter(
300302 } catch ( error ) {
301303 traceWarn ( 'Error processing paths or getting Pixi Info:' , error ) ;
302304 }
305+
306+ return undefined ;
303307}
304308
305309/**
0 commit comments