Control Visual Studio using python - python

I am building an application in which I would like to control Visual Studio, or at least have access to its compilation and build functionalities using (hopefully) python. I know Visual Studio macros are possible and available but it appears they are in .NET (see doc). Since I would like to automate what I want to do with VS in python I'm looking more for something along the lines of:
import vs2016 as controller
controller.build()
controller.compile()
Please note I am not looking to run python code in Visual Studio. This is an altogether different problem that is already widely documented by Microsoft.
Is it possible to control Visual Studio within Python?
if so, how?
if not, what is a viable alternative? let's say I accept that it can only be done with dotnet. In this case how can I relay back to python while keeping it debuggable from a python script?
Thanks!

This sounds like a pretty big undertaking, but I would look in to a win32com.client.dispatch or comtypesto plug in to the COM object(there are several from a quick search and I dont know what any of them do)

Related

How to build application with python and C# in Visual studio

I want to build an application designed in C# forms Visual studio to get user input and want to process user input using python code? In python code, it has different methods to execute for each user input. I used simply for loops for that in python code.
How is it possible?
C# and Python are not compatible in that way. C# runs on .NET platform and Python runs in an interpreter written in C. You could try using PythonSharp, but it will be far from ideal (it's an old project). You could also write the whole application in Python with GUI toolkits. Most popular ones I know of are Tkinter and PyQT.
Edit: another project you might be interested in is IronPython.

visual studio code - language server extension that written in python

I would like to write a visual studio code extension that parse and analyse large log files.
I thought to start with language server extension.
I would like the server to be written in python.
Below, there is an example to server that is written in TypeScript
https://code.visualstudio.com/docs/extensions/example-language-server
it uses the library "vscode-languageserver".
Is there any module in python equivalent to "vscode-languageserver"?
Do you know any example language server extension that is written in python?
It looks like there are at least two to take a look at:
python-langserver by Sourcegraph
python-language-server by Palantir
Unfortunately, I’m not familiar enough with Python to know which of these are the better choice.
I realize this is an old question but in case someone else is looking for this information:
I'm working on a project that implements an LSP server in Python. To accomplish writing the language server in Python we are using a library called pygls.
As with anything, it has its good and bad points but I can say that it has gotten the job done for the aforementioned project, so far.

Which IronPython editor I can use to develop scripts for Tibco Spotfire controls

Can we use any IRONPython editor to develop scripts for Tibco Spotfire controls.
Can we use IDLE editor to develop IRONPython scripts for Tibco Spotfire? If yes then how to integrate the tibco module with IDLE editor, Can anyone help on this??
You should be able to use any development tool (ide) which supports ironpython. One of the best in my point of view is PTVS (Python Tools for Visual Studio), just search for it. But when you want some thing very lightweight with only some syntax hilighting, i prefer using Visual Studio Code or Atom. But PTVS has a lot of nice features. One of the most important ones are those for debugging, because they prevent you from using some console printing or some thing similar as debugging tool. Just take a look at it.
EDIT
As far as i can see, it should work just fines with PTVS. Taking a look at this, is't just some API as any other api: API-Doc
Spotfre has its own IDE for developing scripts but it is very poor one when analysing its functionalities. I dont think you can use any IDE to debug the scripts but you can at least use the one suggested by BendEg to make creation of the code more 'pleasant'.
Spotfire uses IronPython, which is a .NET implementation of python. In other words, is .NET driven by python. To test simple python functions, you can use CodeSkulptor, a cloud based python interpreter. For IronPython, you can use this java based online version but again, this is to test simple scripts

Efficient ways for Python debugging when called from within C++ code

I have a C++ application (on Windows XP) that invokes some Python code. I currently use Winpdb as my python debugger.
Using winpdb as the debugger has some disadvantages since firstly, I need to add a pdb statement, and there is little control afforded to me during the execution since I add dynamic breakpoints.
Does anyone know of tools that can be used that work in a similar fashion to Visual Studio 2010 (or Visual Studio in general)? Most important for me is to be able to set up and remove breakpoints while the application is executing, much like we can do using Visual Studio.
I have looked at ActiveState Komodo IDE6 and Eclipse Python PyDev, but I do not think either one actually fits the bill. This is because I have various python modules that are initialized
using the C++ function call "Py_InitModule" with a name that might be different from the name of the .py file. There modules are not recognized by Komodo and Eclipse Python PyDev.
Please let me know if you have any suggestions. Thank you for your help.
Well, for me it seems that it'd work in PyDev... The only thing is that you have to attach the tracing to the debugger -- use pydevd.settrace(suspend=False) on the thread you want to trace and after that it should 'synchronize' the current breakpoints and their additions/removals ( more references: http://pydev.org/manual_adv_remote_debugger.html ) -- note that you could use pydevd.settrace(suspend=True) to work as a breakpoint as in in pdb.
I didn't really understand why you said it wouldn't work. Can you post your specific example of what's not working to see how that would be solvable? (some things may be customized in pydevd_file_utils.py to help in translating breakpoint paths).

Python code generator for Visual Studio?

I had an idea, if I add a python .py file to my C# project, and tag the file with a custom generator that would execute the python file, and treat the output as the result of the code generation, ie. put it into a C# file, that would allow me to do quite a lot of code generation as part of the build process.
Does anyone know if such a custom generator for Visual Studio 2008 exists?
I think Cog does what you want.
OK, I see. Well, as far as I know there isn't any code generator for Python. There is a good introduction on how to roll your own here.
Actually, that's quite an under-used part of the environment, I suppose it's so because it needs you to use the IDE to compile the project, as it'd seem only the IDE knows about these "generators", but MSBuild ignores them.
I recall that in previous versions of VS, there was a way to add custom build steps to the build process. I used that a lot to do exactly the kind of automated code generation you describe.
I imagine the custom build step feature is still there in 2008.
I don't understand what you are trying to do here. Are you trying to execute a Python script that generates a C# file and then compile that with the project? Or are you trying to compile a Python script to C#?
I dug through my old bookmarks (I love Del.icio.us!) and found this article: Code Generation with Python, Cog, and Nant. Keep in mind that anything you can do in NAnt can probably be done in MSBuild as well. This should be enough to get you started.

Categories

Resources