1 Getting Started
This guide is based on Visual Studio 2013, this guidance may be relevant for other versions but mileage may vary!
- Install Visual Studio 2013 and update it.
- Download Python for Windows ( <= v2.7)
- Install Python Tools for Visual Studio
2 Setting up your Project
If you have existing code go to File -> New -> Project and select From Existing Python Code, otherwise select Python Application. these project templates are under Templates / Python Update the name and the location relevant to your choice.
2.1 From Existing Python Code
For the existing code option ensure all the files are added, if you miss some you can add them to the project later. On the next page select the Python version you are running against. On the final page ensure you are happy with your project file name and location and click on Finish.
2.2 Python Application
3 Project Setup
These are optional but make the experience better.
To enable better intellisense for Kodi components use Kodistubs. This can be downloaded @ https://github.com/romanvm/Kodistubs and all you need to do is add the location you downloaded the files from to the Search Paths. Add the Kodi addons directory to the search paths for the addons you are referencing. An example would be <KODI Root>\portable_data\addons\script.common.plugin.cache\lib to allow intellisense to work for StorageServer
Read the Kodistubs documentation for more detailed instructions.
Note: Intellisense will not be fully active until the DB is created, Press <Ctrl+K, `> to see its progress.
4 Running your project
Once you have a project up and running you have the magic of Visual Studio and the python tools at your disposal, along with any other adding to visual studio you like.
Right click on you python file that is the starting point for the plugin and ensure it is set as the startup file. If it is already bolded you do not have to worry about this.
5 Debugging your project
Work in Progress: Currently the attach process does not seem to be picking correctly for the breakpoints.
To debug your project you need to add a reference to ptvsd to your script and the project to enable intellisense.
- Install ptvsd via pip
pip install ptvsd
- Add the following lines to the top of your script. Remember to comment out or remove once completed.
import ptvsd ptvsd.enable_attach(secret = 'mysecret') ptvsd.wait_for_attach
- Set the breakpoint in your script that you want to check.
- Start KODI
- Start your plugin.
- In Visual Studio use Debug -> Attach to Process menu command, which opens the Attach to Process dialog. The first thing to do in it is to open the Transport combo box, and change selection to Python remote debugging
- For the qualifier add tcp://[email protected]/