secularbird / cpplint-extension

vscode cpplint extension
MIT License
22 stars 12 forks source link

Issue running using non Anaconda based windows cpplint #16

Closed buxtonpaul closed 6 years ago

buxtonpaul commented 6 years ago

I am using python 3.6 installed from python.org and cpplint installed using pip. I can run cpplint from the commandprompt with no problems. If I try and use the cpplint-extension then it does not provide any results.

E.g.

CppLint started: Mon Apr 09 2018 19:20:44 GMT+0100 (GMT Summer Time)

CppLint ended: Mon Apr 09 2018 19:20:44 GMT+0100 (GMT Summer Time)

The same file when processed with cpplint at the commandline produces plenty of things to look at e.g.

C:\Users\paulb>c:\users\paulb\AppData\Local\Programs\Python\Python36\Lib\site-packages\cpplint.py "c:\Users\paulb\workspace\cppstuff\graphcpp\src\main.cpp"
c:\Users\paulb\workspace\cppstuff\graphcpp\src\main.cpp:0:  No copyright message found.  You should have a line: "Copyright [year] <Copyright Owner>"  [legal/copyright] [5]
c:\Users\paulb\workspace\cppstuff\graphcpp\src\main.cpp:8:  Include the directory when naming .h files  [build/include_subdir] [4]

My path is configured using the \ as required for windows to prevent the characters being escaped "cpplint.cpplintPath": "c:\\users\\paulb\\AppData\\Local\\Programs\\Python\\Python36\\Lib\\site-packages\\cpplint.py"

Note the difference with your Anaconda based example is the file is a .py rather than .exe. Thanks, Paul

secularbird commented 6 years ago

I don't have a windows pc right now, and had not installed python in a windows pc before, I will try it later

buxtonpaul commented 6 years ago

No worries. Anaconda is nice for some users but it can end up kind of invasive and doesn't play nice with other python installs. I used it when I first started looking at python but in the end decided that it is just as easy to get the 'reference' python from python.org and install packages using pip, that way you end up with an experience close to when you run on linux.

If you want me to enable extra debug etc and report output then give me a shout. I have my windows dev machine with me so can quickly try things out in my lunch break :-)

On Tue, 10 Apr 2018 at 08:55 secularbird notifications@github.com wrote:

I don't have a windows pc right now, and had not installed python in a windows pc before, I will try it later

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/secularbird/cpplint-extension/issues/16#issuecomment-380009045, or mute the thread https://github.com/notifications/unsubscribe-auth/ASrkbGpxWynpWhvSqXgAf_xXNptIHaDdks5tnGVrgaJpZM4TNAk6 .

secularbird commented 6 years ago

I think it is about the python executable search path, py file need to set python search path in PATH environment, so it can find the python interpreter, your terminal PATH contains that path. When using vscode , vscode does not contain the search path of python interpreter

If you wrapper cpplint.py as a script cpplint.exe which is like bellow:

c:\users\paulb\AppData\Local\Programs\Python\bin\python.exe c:\users\paulb\AppData\Local\Programs\Python\Python36\Lib\site-packages\cpplint.py

and the set "cpplint.cpplintPath" as

c:\\path\\to\\cpplint.exe

this would work

buxtonpaul commented 6 years ago

That doesn't pass the parameters to cpplint You need to add % to the end of command in the script. E.g. `c:\users\paulb\AppData\Local\Programs\Python\Python36\python.exe c:\users\paulb\AppData\Local\Programs\Python\Python36\Lib\site-packages\cpplint.py %` In addition the script should be a .bat file rather than .exe This now works though :-) :+1:

weycen commented 3 years ago

Create a script file cpplint.bat, the content of the file is: PATH1\Python\Python36\python.exe PATH2\Python\Python36\Lib\site-packages\cpplint.py %* The PATH1 is where your python.exe is located, and the PATH2 is where cpplint.py is located, and set "cpplint.cpplintPath"(setting of cpplint-extension ) to the location of thecpplint.bat file.