10-24-2013, 07:15 PM | #1 |
Addict
Posts: 265
Karma: 724240
Join Date: Aug 2013
Device: KyBook
|
How to setup Calibre for Aptana
No, it's not a mistake, I do exactly mean what I wrote in the subject.
I read the topic about setting up Aptana for Calibre, but have no clue whatsoever where Calibre itself fits in. I assume that going by the example paths in the above topic, if I create a calibre project and configure Aptana so that the project lives in \code\calibre and my plugin code in \code\plugin_name that I can point Calibre to its own src folder via the environment variable, but how then do I get Calibre to use the source code for the plugin? Or do I need to create the plugin project within the src folder in the calibre project which itself then is located in the actual calibre(dev) program folder? And I'm a total noob at this, I assume to have Aptana's debugger kick in when running Calibre, I need to put some trigger statement in my code? PS. The fact that there is an IDE out there that can debug your plugin code would be a nice idea to have this pinned in some type of resources topic. Being a first time novice in Python I've been aggravating myself with the constant "pspad edits/zip/relaunch in calibre-debug/re-edit/insert prints" cycle, and frankly I'm about to throw in the towel. Gawd no wonder they named the language after a strangler Last edited by At_Libitum; 10-24-2013 at 07:21 PM. |
10-24-2013, 10:38 PM | #2 |
creator of calibre
Posts: 43,866
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
http://manual.calibre-ebook.com/crea...ugging-plugins
In particular: You can quickly test changes to your plugin by using the following command line: calibre-debug -s; calibre-customize -b /path/to/your/plugin/directory; calibre This will shutdown a running calibre, wait for the shutdown to complete, then update your plugin in calibre and relaunch calibre. |
Advert | |
|
10-25-2013, 06:31 AM | #3 |
Addict
Posts: 265
Karma: 724240
Join Date: Aug 2013
Device: KyBook
|
did that, calibre starts up just fine, but Aptana never gets activated. And the plugin got nicely packed into a zip and installed.
This may be because I am new to Aptana, but I think it won't trigger because it needs the source code of the plugin to step through... |
10-25-2013, 06:37 AM | #4 |
creator of calibre
Posts: 43,866
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
I have no clue on how to get the debugger working. I developed all of calibre without ever using a debugger. python has excellent builtin object introspection capabilities, which means that print() is quite sufficient for debugging.
|
10-25-2013, 07:35 AM | #5 |
Addict
Posts: 265
Karma: 724240
Join Date: Aug 2013
Device: KyBook
|
I can imagine that if you wrote the code you know exactly what to expect and where. I on the other hand am trying to look in from the outside without knowing anything much yet from what's inside and need the benefits of visually stepping through code to see how it got there or to try find out which part of the for me totally unknown src is used when performing an action in the gui.
|
Advert | |
|
10-25-2013, 07:57 AM | #6 |
creator of calibre
Posts: 43,866
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
import traceback
traceback.print_stack() And writing calibre involved fully understanding/replacing lots and lots of very complex python codebases. In fact I am currently in the middle of doing that with html5lib, again, without a debugger. |
10-25-2013, 12:26 PM | #7 |
Addict
Posts: 265
Karma: 724240
Join Date: Aug 2013
Device: KyBook
|
Again, I know about traceback, I know about pdb, have tried both, neither of them gives me what I need. Plus that with inserting print at every possible location is a hit or miss if you don't know the code
You may not need a debugger, but those basic means do not provide me the information to understand what and why. I need to be able to step-thru for that. Anyone else here using Aptana/Eclipse on Windows and is able to step through their plugin code? My current setup is Aptana with PyDev, code analysis/undefined filled in as advised, Qt is installed, Python2.7 is installed, Calibre src pulled from git in a new Aptana project, everything up to here works. I can browse the code just fine without Aptana complaining about missing references, but I could do that already with grep and pspad According to info found here I need to add import pydevd pydevd.settrace() in my code, so did that but then Calibre just bombs the moment I start it. So I cannot even get it to go through calibre's python src, let alone my plugin attempt. Last edited by At_Libitum; 10-25-2013 at 12:29 PM. |
10-25-2013, 05:45 PM | #8 |
Grand Sorcerer
Posts: 11,742
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
I have used eclipse and pydev to do calibre development for some 3 years. A few times I have looked at what it would take to connect the debugger and have always given up. The many hours I would spend to probably in the end fail are better spent doing something else.
My take: calibre has a very complex startup structure, working through the OS and file systems it is running on, which host libraries are in use, whether or not it is running from source, loading its C helper libraries, and installing the zipfile module loader. As far as I can tell the debugger runtime can't handle all of that. Perhaps you can prove me wrong. |
10-26-2013, 04:03 AM | #9 |
Addict
Posts: 265
Karma: 724240
Join Date: Aug 2013
Device: KyBook
|
Weel, at least I'm in good company then if you didn't manage either.
But with remote debugging the startup process should not really matter as the debugger should only be waiting until it gets a signal from the pydev module. And yet, no success whatsoever. And I thought Xdbg for PHP was a pain. How wrong I was. |
08-20-2014, 01:54 PM | #10 |
Groupie
Posts: 199
Karma: 1071756
Join Date: Sep 2012
Location: Nova Scotia
Device: Kobo Aura, Nexus 5x
|
I really didn't think this could be too difficult.
The way I've done it is no doubt not the best way (I'm forgetting how to force python to pick up an additional library for PYTHONPATH [ETA: no I'm not, it's just that calibre ignores PYTHONPATH in your environment!]), but instead of just: Code:
import pydevd;pydevd.settrace() Code:
if '/opt/eclipse-4.3/plugins/org.python.pydev_2.7.0.2013032300/pysrc' not in sys.path: sys.path.append('/opt/eclipse-4.3/plugins/org.python.pydev_2.7.0.2013032300/pysrc') import pydevd;pydevd.settrace() Remember to start the external debugger in Eclipse before starting calibre. |
08-22-2014, 02:37 PM | #11 |
Groupie
Posts: 199
Karma: 1071756
Join Date: Sep 2012
Location: Nova Scotia
Device: Kobo Aura, Nexus 5x
|
I've added the attached build.xml to my Eclipse project for a calibre plugin I'm developing.
Now I can right click on the build.xml file, Debug as..., Ant build and Ant will shut down the running calibre, reinstall the plugin, and restart calibre in debug mode (the debug log going to the Ant console). |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to set up Aptana for Calibre? | kiwidude | Development | 14 | 08-22-2014 02:41 PM |
My current calibre setup | centuryx476 | Library Management | 3 | 07-20-2013 11:18 AM |
New machine, keep old calibre setup? | TdeV | Calibre | 2 | 12-06-2011 02:14 PM |
Query regarding Calibre setup | culpr1t | Calibre | 3 | 01-11-2011 03:02 PM |
Headless Calibre Server Setup | godzilla8nj | Related Tools | 4 | 03-10-2010 01:39 PM |