@@ -7,7 +7,7 @@ import { EventNames } from '../telemetry/constants';
77import { sendTelemetryEvent } from '../telemetry/sender' ;
88import { isWindows } from '../utils/platformUtils' ;
99import { handlePythonPath } from '../utils/pythonPath' ;
10- import { showOpenDialog , showQuickPick , showQuickPickWithButtons , withProgress } from '../window.apis' ;
10+ import { showInputBoxWithButtons , showOpenDialog , showQuickPick , showQuickPickWithButtons , withProgress } from '../window.apis' ;
1111import { pickEnvironmentManager } from './managers' ;
1212
1313type QuickPickIcon =
@@ -69,6 +69,41 @@ async function browseForPython(
6969 return environment ;
7070}
7171
72+ async function enterPythonPath (
73+ managers : InternalEnvironmentManager [ ] ,
74+ projectEnvManagers : InternalEnvironmentManager [ ] ,
75+ ) : Promise < PythonEnvironment | undefined > {
76+ const placeholder = isWindows ( ) ? 'C:\\path\\to\\python\\executable' : '/path/to/python/executable' ;
77+ const inputPath = await showInputBoxWithButtons ( {
78+ prompt : 'Enter the path to the Python executable' ,
79+ placeHolder : placeholder ,
80+ ignoreFocusOut : true ,
81+ validateInput : ( value ) => {
82+ if ( ! value || value . trim ( ) . length === 0 ) {
83+ return 'Please enter a valid path' ;
84+ }
85+ return null ;
86+ } ,
87+ } ) ;
88+
89+ if ( ! inputPath ) {
90+ return ; // User cancelled
91+ }
92+
93+ const uri = Uri . file ( inputPath . trim ( ) ) ;
94+ const environment = await withProgress (
95+ {
96+ location : ProgressLocation . Notification ,
97+ cancellable : false ,
98+ } ,
99+ async ( reporter , token ) => {
100+ const env = await handlePythonPath ( uri , managers , projectEnvManagers , reporter , token ) ;
101+ return env ;
102+ } ,
103+ ) ;
104+ return environment ;
105+ }
106+
72107async function createEnvironment (
73108 managers : InternalEnvironmentManager [ ] ,
74109 projectEnvManagers : InternalEnvironmentManager [ ] ,
@@ -124,6 +159,8 @@ async function pickEnvironmentImpl(
124159 if ( selected && ! Array . isArray ( selected ) ) {
125160 if ( selected . label === Interpreter . browsePath ) {
126161 return browseForPython ( managers , projectEnvManagers ) ;
162+ } else if ( selected . label === Interpreter . enterPath ) {
163+ return enterPythonPath ( managers , projectEnvManagers ) ;
127164 } else if ( selected . label === Interpreter . createVirtualEnvironment ) {
128165 sendTelemetryEvent ( EventNames . CREATE_ENVIRONMENT , undefined , {
129166 manager : 'none' ,
@@ -146,6 +183,10 @@ export async function pickEnvironment(
146183 label : Interpreter . browsePath ,
147184 iconPath : new ThemeIcon ( 'folder' ) ,
148185 } ,
186+ {
187+ label : Interpreter . enterPath ,
188+ iconPath : new ThemeIcon ( 'edit' ) ,
189+ } ,
149190 {
150191 label : '' ,
151192 kind : QuickPickItemKind . Separator ,
0 commit comments