File tree Expand file tree Collapse file tree 2 files changed +18
-4
lines changed Expand file tree Collapse file tree 2 files changed +18
-4
lines changed Original file line number Diff line number Diff line change 11'use strict' ; 
22
33import  *  as  vscode  from  'vscode' ; 
4+ import  *  as  path  from  'path' ; 
5+ import  *  as  fs  from  'fs' ; 
46
57export  interface  IPythonSettings  { 
68 pythonPath : string ; 
@@ -49,12 +51,23 @@ export class PythonSettings implements IPythonSettings {
4951
5052 this . initializeSettings ( ) ; 
5153 } 
52- 
54+  private  getVirtualenvPath ( )  { 
55+  var  currentPath : string  =  vscode . workspace . rootPath ; 
56+  if  ( process . platform  ==  'win32' )  { 
57+  var  bin : string  =  "Scripts" ; 
58+  var  _path : string  =  path . join ( currentPath ,  bin ,  "python.exe" ) ; 
59+  } 
60+  else  { 
61+  var  bin : string  =  "bin" ; 
62+  var  _path : string  =  path . join ( currentPath ,  bin ,  "python" ) ; 
63+  } 
64+  return  fs . existsSync ( _path ) 
65+  ? _path 
66+  : this . pythonPath ; 
67+  } 
5368 private  initializeSettings ( )  { 
5469 var  pythonSettings  =  vscode . workspace . getConfiguration ( "python" ) ; 
55- 
56-  this . pythonPath  =  pythonSettings . get < string > ( "pythonPath" ) ; 
57- 
70+  this . pythonPath  =  this . getVirtualenvPath ( ) 
5871 var  lintingSettings  =  pythonSettings . get < ILintingSettings > ( "linting" ) ; 
5972 if  ( this . linting )  { 
6073 Object . assign < ILintingSettings ,  ILintingSettings > ( this . linting ,  lintingSettings ) ; 
Original file line number Diff line number Diff line change 144144 "dependencies" : {
145145 "named-js-regexp" : " ^1.3.1" 
146146 "tmp" : " 0.0.28" 
147+  "path" : " 0.12.7" 
147148 "uint64be" : " ^1.0.1" 
148149 "vscode-debugadapter" : " ^1.0.1" 
149150 "vscode-debugprotocol" : " ^1.0.1" 
                         You can’t perform that action at this time. 
           
                  
0 commit comments