diff --git a/autoload/ale/python.vim b/autoload/ale/python.vim index 9eb198fb46..148683d6d5 100644 --- a/autoload/ale/python.vim +++ b/autoload/ale/python.vim @@ -108,12 +108,17 @@ function! ale#python#AutoVirtualenvEnvString(buffer) abort if !empty(l:venv_dir) let l:strs = [ ] + " venv/bin directory + let l:pathdir = join([l:venv_dir, s:bin_dir], s:sep) " expand PATH correctly inside of the appropriate shell. + " set VIRTUAL_ENV to point to venv if has('win32') - call add(l:strs, 'set PATH=' . ale#Escape(l:venv_dir) . ';%PATH% && ') + call add(l:strs, 'set PATH=' . ale#Escape(l:pathdir) . ';%PATH% && ') + call add(l:strs, 'set VIRTUAL_ENV=' . ale#Escape(l:venv_dir) . ' && ') else - call add(l:strs, 'PATH=' . ale#Escape(l:venv_dir) . '":$PATH" ') + call add(l:strs, 'PATH=' . ale#Escape(l:pathdir) . '":$PATH" ') + call add(l:strs, 'VIRTUAL_ENV=' . ale#Escape(l:venv_dir) . ' ') endif return join(l:strs, '') diff --git a/test/test_python_virtualenv.vader b/test/test_python_virtualenv.vader index cb49d3155f..25699873ff 100644 --- a/test/test_python_virtualenv.vader +++ b/test/test_python_virtualenv.vader @@ -14,10 +14,10 @@ Execute(ale#python#FindVirtualenv falls back to $VIRTUAL_ENV when no directories Execute(ale#python#AutoVirtualenvEnvString should return the correct values): if has('win32') AssertEqual - \ 'set PATH=/opt/example/;%PATH% && ', + \ 'set PATH=/opt/example/\Scripts;%PATH% && set VIRTUAL_ENV=/opt/example/ && ', \ ale#python#AutoVirtualenvEnvString(bufnr('')) else AssertEqual - \ 'PATH=''/opt/example/''":$PATH" ', + \ 'PATH=''/opt/example//bin''":$PATH" VIRTUAL_ENV=''/opt/example/'' ', \ ale#python#AutoVirtualenvEnvString(bufnr('')) endif