Setting up a dev environment with Eclipse ad PyDev
#1
I'm a tad stuck following this: HOW-TO:Debug_Python_Scripts_with_Eclipse (wiki)

It's way dated. I work fluidly with Eclipse and PyDev all the time, i.e. already have that dev environment in regular use.

Now I'd like to apply it to a little Kodi Addon work but that tutorial is a maze of deprecated tips.

2.3.5 Setting up Predefined Completions (optional)

Optional so I won't fuss with it too much for now. Still flagging that  'PyDev Predefined Completions Creator' Addon cannot for love or money be found. I found a copy here:

https://kodi-addons.club/addon/script.pypredefcom/

which even claims to be Kodi 18 compatible, bu no. I tweaked it to install at all (shifting its xmbc.python import from 2.0 to 2.14.0 that Kodi 18.3 seems to use) . But when run it bombs with an error saying to check logs. Which I'll dwell on later (as when i turn on the debug log it's flooded fast as I happen to me importing a mass of media at same time so I will wait for that to die down, point here being that this addon is a mystery, and if it does live somewhere, we'd love to find it and update that wiki!)

3.4 Add Pydev Python source code (pysrc) to XBMC

Now this is a little more important. And it concludes with a little note:
Quote:In new Eclipse versions on Linux, the standard eclipse installation (/usr/share/eclipse/plugins) does not contain the pydev files any more. The easiest solution is to install the pydevd-addon.
To access this from your addon, your addon.xml has to contain 
<import addon="script.module.pydevd" version="3.4.1"/>
Which refers to this: Add-on:Pydevd (wiki)
But again, this addon I cannot find, for love or money. Where is it?

I would love to get this rolling, but it seems I need the pydevd addon and don't know where to look for it or how it install it.

Regards,

Bernd.
Reply
#2
If you need code completion for xbmc* modules, I'd recommend Kodistubs: https://github.com/romanvm/Kodistubs

As for debugging in general, you can pack PyDev debugger (a remote part) into Kodi module addon by yourself.
Raspberry PI 2 + LibreELEC 8 (Kodi 17)
Samsung Galaxy Tab A 10.1 + Kodi 17 for Android
Reply
#3
You can pack your own, you can used some else package.
Here is what I use

I use this one because I needed that version, you can look around github and you will find most version, or if you can match version you need just replace those files with yours.

edit: oh right, I use PyCharm btw and IDE
Proud developer for Shoko and Nakamori. Long time xbmc/kodi user. IT Freak at Monogatari.
Reply
#4
(2019-08-30, 13:20)Roman_V_M Wrote: If you need code completion for xbmc* modules, I'd recommend Kodistubs: https://github.com/romanvm/Kodistubs

As for debugging in general, you can pack PyDev debugger (a remote part) into Kodi module addon by yourself.

Thanks Roman. In summary:
  1. Kodistuds replaces that old "PyDev Predefined Completions Creator"
  2. Re: you can pack PyDev debugger (a remote part) into Kodi module addon by yourself. - Alas I don't know what you mean. Can you clarify?
In any case this wiki page:
HOW-TO:Debug_Python_Scripts_with_Eclipse (wiki)
desperately needs updating! I have requested Wiki access to contribute what I learn, but it would be awesome if somone more experienced updated that page.

On 2. above are you simply saying that adding this to addon.xml:
 <requires>
    <import addon="script.module.pydevd" version="10.4.4.0"/>
</requires>
will work? Which I have from: https://github.com/bigretromike/script.m...ree/master

which would imply, that your implying that script.module.pydevd is already preinstalled with a Kodi install?
Reply
#5
(2019-08-30, 20:39)bigretromike Wrote: You can pack your own, you can used some else package.
Here is what I use

I use this one because I needed that version, you can look around github and you will find most version, or if you can match version you need just replace those files with yours.

edit: oh right, I use PyCharm btw and IDE

Thanks Mike. I'm not keen to switch to Pycharm given I use Eclipse and Pydev for a pile of other work and am set up with it (and love it, and tried PyCharm and didn't fall in love, with its freemium model, I donate regularly to Fabio at PyDev instead ;-). I'll give some of this a whir soon, I have first to work out how to publish an addon to my Kodi server so it sees it. Another thread: 346801 (thread)
Reply
#6
Hi @ThumbOne 

I started work on my first add-on (which was also my first python project) recently and it took me a few months to find a workflow that worked for me. You're right that the wiki isn't up to date but I found a lot of resources here and there, mostly by looking looking at what other add-on devs were doing. I don't have much experience so some of these practices might not be recommended but it works for me so it might be a useful starting point - or at least a collection of links.

I also stuck with eclipse because I'm familiar with it and also the pydev remote debugger is free, whereas with pycharm it only seems to be available with the pro version. I had enough things to figure out anyways!

My main kodi setup runs on an intel nuc with Libreelec and my dev setup is on windows.

My basic workflow is this:
- Iterate quickly on a dev kodi setup on windows.
- Once I have a decent version, add something like ~dev1 to the version number & deploy to local repo & libreelec setup
- After I've been running it for a few days, drop ~devX from the version number, deploy to public repo & tag the version in github to update the releases page. 


Eclipse:
For quick iteration, I made a separate kodi install on my windows machine with a minimal setup that I use for dev only. I added a few test videos to the library and removed UI menus from the skin I didn't need but aside from that it's like a new install.  To avoid having to create a .zip and install it each time, I just made a symlink (mklink in windows) to the \kodi\addons directory. It's the location Kodi installs the .zip to and runs python source from and the generated pycs are located. I may have installed it manually at least once first for the addons.db to update. To make my life even easier I made an external tool shortcut in eclipse to run my dev kodi instance. This lets me just edit my code and restart kodi. My add-on runs as a service so in order to reload it kodi needs a restart, but disabling and re-enabling my addon seems to work as well. Because kodi is pointing directly at your source you don't even need to update the version number.

I use sublime text instead of notepad++ mentioned in the other thread but the idea is the same - any editor that tails or live updates your kodi.log works fine.

For debugging, I just cloned the pydevd addon module from here. I only updated the addon version and replaced everything in 'lib' with the version of pydevd I'm using. Just rezip, install to kodi. Just remember you need to add/remove the dependency your addon.xml when you need it (or not). If you want to step through or set breakpoints, you probably need to set the path translations in the 'source locator' section of the eclipse/pydev preferences because of the symlink or it won't be able to match up your project to the location kodi is running the source from. 

I've also installed kodistubs as Roman suggests above. 

Local repo
To easily deploy to my local setup, I use a lighthttpd server running in docker that I already had setup. Any kind of webserver should work fine. To generate a repo I use this script. I don't know if there's something more recent but this works fine. I made a .cmd to run it easily and it just grabs the source for my addon & pydevd from my projects dir and dumps the repo on my webserver. Once I installed this local repo to my libreelec setup, I just need to use the 'check for updates' option in Kodi and it will update from my local repo. In this case you will need to update the version in your addon.xml for kodi to download the update. 

You'll need to create a repo addon to add your repo to Kodi. My example is here

Public repo
I decided to make a public repo because why not. I use github hosting and you can see that here. I use the same python script as with the local repo but instead it pulls the source from github and pushes the updated repo back to github. Example cmd. I run that on my dev machine but it can probably be automated in travis if you wanted.

Github releases/Travis
To update my github releases page, I use @Roman_V_M's kodi-addon-submitter that I run via travis-ci. His documentation is better than what I could summarize here. Although I'm not submitting my add-on to the official repo, it's still a useful. That said you don't need to update the github releases page unless you really want to.

My travis setup is also running kodi-addon-checker. It's useful to catch common add-on errors.

Hope this helps!
Hue Service  Latest  Git • Repo
Reply
#7
(2019-09-01, 16:54)Snapcase Wrote: Hi @ThumbOne 

I started work on my first add-on (which was also my first python project) recently and it took me a few months to find a workflow that worked for me. You're right that the wiki isn't up to date but I found a lot of resources here and there, mostly by looking looking at what other add-on devs were doing. I don't have much experience so some of these practices might not be recommended but it works for me so it might be a useful starting point - or at least a collection of links.

I also stuck with eclipse because I'm familiar with it and also the pydev remote debugger is free, whereas with pycharm it only seems to be available with the pro version. I had enough things to figure out anyways!

My main kodi setup runs on an intel nuc with Libreelec and my dev setup is on windows.

My basic workflow is this:
- Iterate quickly on a dev kodi setup on windows.
- Once I have a decent version, add something like ~dev1 to the version number & deploy to local repo & libreelec setup
- After I've been running it for a few days, drop ~devX from the version number, deploy to public repo & tag the version in github to update the releases page. 


Eclipse:
For quick iteration, I made a separate kodi install on my windows machine with a minimal setup that I use for dev only. I added a few test videos to the library and removed UI menus from the skin I didn't need but aside from that it's like a new install.  To avoid having to create a .zip and install it each time, I just made a symlink (mklink in windows) to the \kodi\addons directory. It's the location Kodi installs the .zip to and runs python source from and the generated pycs are located. I may have installed it manually at least once first for the addons.db to update. To make my life even easier I made an external tool shortcut in eclipse to run my dev kodi instance. This lets me just edit my code and restart kodi. My add-on runs as a service so in order to reload it kodi needs a restart, but disabling and re-enabling my addon seems to work as well. Because kodi is pointing directly at your source you don't even need to update the version number.

I use sublime text instead of notepad++ mentioned in the other thread but the idea is the same - any editor that tails or live updates your kodi.log works fine.

For debugging, I just cloned the pydevd addon module from here. I only updated the addon version and replaced everything in 'lib' with the version of pydevd I'm using. Just rezip, install to kodi. Just remember you need to add/remove the dependency your addon.xml when you need it (or not). If you want to step through or set breakpoints, you probably need to set the path translations in the 'source locator' section of the eclipse/pydev preferences because of the symlink or it won't be able to match up your project to the location kodi is running the source from. 

I've also installed kodistubs as Roman suggests above. 

Local repo
To easily deploy to my local setup, I use a lighthttpd server running in docker that I already had setup. Any kind of webserver should work fine. To generate a repo I use this script. I don't know if there's something more recent but this works fine. I made a .cmd to run it easily and it just grabs the source for my addon & pydevd from my projects dir and dumps the repo on my webserver. Once I installed this local repo to my libreelec setup, I just need to use the 'check for updates' option in Kodi and it will update from my local repo. In this case you will need to update the version in your addon.xml for kodi to download the update. 

You'll need to create a repo addon to add your repo to Kodi. My example is here

Public repo
I decided to make a public repo because why not. I use github hosting and you can see that here. I use the same python script as with the local repo but instead it pulls the source from github and pushes the updated repo back to github. Example cmd. I run that on my dev machine but it can probably be automated in travis if you wanted.

Github releases/Travis
To update my github releases page, I use @Roman_V_M's kodi-addon-submitter that I run via travis-ci. His documentation is better than what I could summarize here. Although I'm not submitting my add-on to the official repo, it's still a useful. That said you don't need to update the github releases page unless you really want to.

My travis setup is also running kodi-addon-checker. It's useful to catch common add-on errors.

Hope this helps!

Wow, thanks so so much for such a details response. I'm a bit slow in responding and it'll take me some while to digest all that! Wow.

Some cursory comments for now (don't let them distract us, I'm sure I'll be back with more questions once I digest all this properly):
  1. Ironically I was using an Intel NUC as well which now sits idle beside me as I replaced with a MintBox.  I have had the NUC for years and have grown to hate it with such passion I've almost tossed it out the window a few times ;-).  I was running Win 7 on it first, and flakey as hell and blue screening, regularly, so I moved to Linux and it was stable ever since. But even when stable it has this BIOS issue that has not been fixed update after update after update and with Intel support calls. Essentially I have a projector and a TV attached to the HTPC. The project is turned on and off as needed. And this coming and going on the HDMI throws the NUC into fits ... whatever OS is running it causes endless problems with the interfaces demanding reboots, and then it would often fail to boot and I had no access to the BIOS menu short of opening the beast up and shorting two jumpers to force it or doing the power button trick that takes equisite timing and countdown to achieve a result. Huge digression but I'll find a use of this brick some time, that doesn't rely on a coming/going HDMI connection perhaps a headless server. Mild waste for it's graphic power, but hey.

  2. Will try the Eclipse/Pydev things soon some time. I'm happy to wait until Kodi 19 appears before I do anything in earnest as I'm not into Python 2 anymore nor really interested in that, given my addiction to far too many Python 3 features. So I'm super pleased to hear Kodi 19 will be Python 3 and is loosely due out in October, which on my time frames is as good as tomorrow ;-).

  3. In the mean time I'm tweaking addons on the fly anyhow, which is cool.

Anyhow, will keep this alive and be back to try much of this out in detail. Really enjoying Kodi as a music player, and look forward to tweaking the skin too.
Reply
#8
My intel nuc has been glitchy but never anything so bad.  I have to reboot it about once a month but it's not annoying enough to replace it. Though I don't think I would replace it with another if it finally dies.  

I'm not enough of a Python expert to know the differences that well, but I also planned to abandon 2 with Kodi 19 instead of trying to support both so I haven't tried doing anything too exotic until I can switch over. No point in investing too much time now.
Hue Service  Latest  Git • Repo
Reply
 
Thread Rating:
  • 0 Vote(s) - 0 Average



Logout Mark Read Team Forum Stats Members Help
Setting up a dev environment with Eclipse ad PyDev00