@@ -2,6 +2,8 @@ import * as vscode from 'vscode';
22import * as settings from './configSettings' ;
33import { createDeferred , isNotInstalledError } from './helpers' ;
44import { execPythonFile } from './utils' ;
5+ import * as os from 'os' ;
6+ import { Documentation } from './constants' ;
57
68export enum Product {
79 pytest ,
@@ -15,22 +17,34 @@ export enum Product {
1517 yapf ,
1618 autopep8 ,
1719 mypy ,
18- unittest
20+ unittest ,
21+ ctags
1922}
2023
2124const ProductInstallScripts = new Map < Product , string [ ] > ( ) ;
22- ProductInstallScripts . set ( Product . autopep8 , [ 'pip' , 'install' , 'autopep8' ] ) ;
23- ProductInstallScripts . set ( Product . flake8 , [ 'pip' , 'install' , 'flake8' ] ) ;
24- ProductInstallScripts . set ( Product . mypy , [ 'pip' , 'install' , 'mypy-lang' ] ) ;
25- ProductInstallScripts . set ( Product . nosetest , [ 'pip' , 'install' , 'nose' ] ) ;
26- ProductInstallScripts . set ( Product . pep8 , [ 'pip' , 'install' , 'pep8' ] ) ;
27- ProductInstallScripts . set ( Product . pylama , [ 'pip' , 'install' , 'pylama' ] ) ;
28- ProductInstallScripts . set ( Product . prospector , [ 'pip' , 'install' , 'prospector' ] ) ;
29- ProductInstallScripts . set ( Product . pydocstyle , [ 'pip' , 'install' , 'pydocstyle' ] ) ;
30- ProductInstallScripts . set ( Product . pylint , [ 'pip' , 'install' , 'pylint' ] ) ;
31- ProductInstallScripts . set ( Product . pytest , [ 'pip' , 'install' , '-U' , 'pytest' ] ) ;
32- ProductInstallScripts . set ( Product . yapf , [ 'pip' , 'install' , 'yapf' ] ) ;
33-
25+ ProductInstallScripts . set ( Product . autopep8 , [ '-m' , 'pip' , 'install' , 'autopep8' ] ) ;
26+ ProductInstallScripts . set ( Product . flake8 , [ '-m' , 'pip' , 'install' , 'flake8' ] ) ;
27+ ProductInstallScripts . set ( Product . mypy , [ '-m' , 'pip' , 'install' , 'mypy-lang' ] ) ;
28+ ProductInstallScripts . set ( Product . nosetest , [ '-m' , 'pip' , 'install' , 'nose' ] ) ;
29+ ProductInstallScripts . set ( Product . pep8 , [ '-m' , 'pip' , 'install' , 'pep8' ] ) ;
30+ ProductInstallScripts . set ( Product . pylama , [ '-m' , 'pip' , 'install' , 'pylama' ] ) ;
31+ ProductInstallScripts . set ( Product . prospector , [ '-m' , 'pip' , 'install' , 'prospector' ] ) ;
32+ ProductInstallScripts . set ( Product . pydocstyle , [ '-m' , 'pip' , 'install' , 'pydocstyle' ] ) ;
33+ ProductInstallScripts . set ( Product . pylint , [ '-m' , 'pip' , 'install' , 'pylint' ] ) ;
34+ ProductInstallScripts . set ( Product . pytest , [ '-m' , 'pip' , 'install' , '-U' , 'pytest' ] ) ;
35+ ProductInstallScripts . set ( Product . yapf , [ '-m' , 'pip' , 'install' , 'yapf' ] ) ;
36+ switch ( os . platform ( ) ) {
37+ case 'win32' : {
38+ // Nothing
39+ break ;
40+ }
41+ case 'darwin' : {
42+ ProductInstallScripts . set ( Product . ctags , [ 'brew install ctags' ] ) ;
43+ }
44+ default : {
45+ ProductInstallScripts . set ( Product . ctags , [ 'sudo apt-get install exuberant-ctags' ] ) ;
46+ }
47+ }
3448
3549const Linters : Product [ ] = [ Product . flake8 , Product . pep8 , Product . pylama , Product . prospector , Product . pylint , Product . mypy , Product . pydocstyle ] ;
3650const Formatters : Product [ ] = [ Product . autopep8 , Product . yapf ] ;
@@ -122,25 +136,31 @@ export class Installer {
122136 Installer . terminal = vscode . window . createTerminal ( 'Python Installer' ) ;
123137 }
124138
139+ if ( product === Product . ctags && os . platform ( ) === 'win32' ) {
140+ vscode . commands . executeCommand ( 'python.displayHelp' , Documentation . Workspace . InstallOnWindows ) ;
141+ return Promise . resolve ( ) ;
142+ }
143+
125144 let installArgs = ProductInstallScripts . get ( product ) ;
126145 const pythonPath = settings . PythonSettings . getInstance ( ) . pythonPath ;
127146
128- if ( this . outputChannel ) {
147+ if ( this . outputChannel && installArgs [ 0 ] === '-m' ) {
129148 // Errors are just displayed to the user
130149 this . outputChannel . show ( ) ;
131- return execPythonFile ( pythonPath , [ '-m' , ... installArgs ] , vscode . workspace . rootPath , true , ( data ) => {
150+ return execPythonFile ( pythonPath , installArgs , vscode . workspace . rootPath , true , ( data ) => {
132151 this . outputChannel . append ( data ) ;
133152 } ) ;
134153 }
135154 else {
136155 let installScript = installArgs . join ( ' ' ) ;
137- if ( pythonPath . indexOf ( ' ' ) >= 0 ) {
138- installScript = `"${ pythonPath } " -m ${ installScript } ` ;
139- }
140- else {
141- installScript = `${ pythonPath } -m ${ installScript } ` ;
156+ if ( installArgs [ 0 ] === '-m' ) {
157+ if ( pythonPath . indexOf ( ' ' ) >= 0 ) {
158+ installScript = `"${ pythonPath } " -m ${ installScript } ` ;
159+ }
160+ else {
161+ installScript = `${ pythonPath } -m ${ installScript } ` ;
162+ }
142163 }
143-
144164 Installer . terminal . sendText ( installScript ) ;
145165 Installer . terminal . show ( false ) ;
146166 // Unfortunately we won't know when the command has completed
0 commit comments