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.
Related
I want to know becouse as far as i know how the python code works it is slower becouse is an interpretated languaje need to do some extra work in running time thus it is slower, but if i compiled it, it wuld be more performant? or ot will be the same? and what will be the difference between them? other thean performance and when i should compile the code? when i need no other dependencis of python interpretator?, larger proyects or somthing else?
I wanted to ask because there are a lot of peopol new in programing using python and that will be very useful information to know
When you use py2exe, that basically creates a big zip file that contains your source code, the modules you need, and a copy of the Python interpreter. When you run it, it unzips into a miniature self-contained Python environment and runs the interpreter. There is no difference in performance.
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.
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)
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).
I just installed Jython 2.5.1. I want to convert my Python file into Java class file and it is instructed on the website to use the jythonc command-line tool but I can't find it. Does anyone know where I could find it?
Basically what i was trying to accomplish is to get my Python code running client-side in a browser and the best way seemed to be by creating an applet using Jython. I don't want to create a desktop application and using Silverlight/IronPython is out of the question. Any other ideas are welcomed.
Cheers!
You can still compile your python-code to class-files:
import compileall;
compileall.compile_dir('Lib'); # to compile yor Lib-Dir
should work with 2.5 jython
i use it to create class-files to put in jars :-)
Jythonc was removed in Jython 2.2 and is no longer supported. The official way to embed Jython code in Java is to create an instance of the interpreter to run the Jython code directly. There is an article on this here.
Personally I preferred the jythonc method and hope it will be reinstated in a future version of Jython, even though it had a number of issues.