Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Software > Calibre > Development

Notices

Reply
 
Thread Tools Search this Thread
Old 07-17-2011, 05:50 PM   #1
siebert
Developer
siebert has a complete set of Star Wars action figures.siebert has a complete set of Star Wars action figures.siebert has a complete set of Star Wars action figures.
 
Posts: 136
Karma: 280
Join Date: Nov 2010
Device: Kindle 3 (Keyboard) 3G / iPad 3 WiFi / Nexus 4 (Android)
HowTo: Debug calibre with Eclipse/PyDev

Hi,

using a debugger with calibre is rather difficult, but I've managed to get the PyDev debugger working via remote debugging.

Here are the necessary steps:

- Set up calibre development for your platform (I'm using Windows 7 64bit): http://manual.calibre-ebook.com/develop.html
- Set up PyDev remote debugging: http://pydev.org/manual_adv_remote_debugger.html. For step 3 "Make sure pydevd.py is in your pythonpath" I've copied the required files to the src directory of calibre.
- Locate the source code to debug and add the line
Code:
import pydevd;pydevd.settrace()
- Start the PyDev remote debugger server
- Start calibre with "calibre-debug -g"
- When the added line is reached, the debugger will stop. You can continue from there, set break points etc.

Please note that it doesn't work to add the debug line at the calibre startup code and single step from there through the whole application, as the calibre startup is rather tricky and different threads are running. So it's best to just add the line (even at multiple locations) where you would normally set your breakpoint.

Happy debugging,
Steffen
siebert is offline   Reply With Quote
Old 07-18-2011, 04:31 AM   #2
Naderstouhy
Enthusiast
Naderstouhy began at the beginning.
 
Posts: 32
Karma: 10
Join Date: Jul 2011
Device: none
i've done all the above, i need to know if i can trace the classes that calibre call whenever an action is made for exemple i want to know when i change the language and make an apply of the apply click what functions calibre call, how can i do that with pyDev ?
Naderstouhy is offline   Reply With Quote
Old 12-17-2011, 09:01 AM   #3
pbw
Member
pbw began at the beginning.
 
Posts: 19
Karma: 10
Join Date: Dec 2011
Device: Kindle
Do you have any hints for setting up calibre as a python project for PyDev in Eclipse?
pbw is offline   Reply With Quote
Old 12-17-2011, 04:29 PM   #4
pbw
Member
pbw began at the beginning.
 
Posts: 19
Karma: 10
Join Date: Dec 2011
Device: Kindle
I was able to set up two projects within the overall calibre directory, one based on calibre/setup, and one based on calibre/src. Each contains multiple packages.

Does setup have dependencies at the top level?

Does src have dependencies on setup?
pbw is offline   Reply With Quote
Old 12-18-2011, 06:00 AM   #5
siebert
Developer
siebert has a complete set of Star Wars action figures.siebert has a complete set of Star Wars action figures.siebert has a complete set of Star Wars action figures.
 
Posts: 136
Karma: 280
Join Date: Nov 2010
Device: Kindle 3 (Keyboard) 3G / iPad 3 WiFi / Nexus 4 (Android)
Unless you want to change/improve the calibre installer, you should need only one calibre project with pythonpath set to calibre/src. At least this is what I use

Ciao,
Steffen
siebert is offline   Reply With Quote
Old 12-18-2011, 09:47 PM   #6
pbw
Member
pbw began at the beginning.
 
Posts: 19
Karma: 10
Join Date: Dec 2011
Device: Kindle
Thanks Steffen.

I've removed the setup project. I'm running against 2.7 on OS X, installed from Mac Ports. I have included the org.python.pydev_2.3.0..../PySrc and the org.python.pydev.debug_2.3.0...../pysrc folders in PYTHONPATH within the Eclipse setup.

Eclipse is complaining about sys.extensions_location
Undefined variable from import: extensions_location

Any ideas?

Peter
pbw is offline   Reply With Quote
Old 12-18-2011, 11:18 PM   #7
pbw
Member
pbw began at the beginning.
 
Posts: 19
Karma: 10
Join Date: Dec 2011
Device: Kindle
I think I might have the wrong approach completely. Given that any changes I might make to the checked-out code are actually run from within the calibre.app (on OS X), making use of the environment variable CALIBRE_DEVELOP_FROM, it occurs to me that I cannot get a clean PyDev environment with just the checked-out code, but I need to set up a project based on the installed calibre.app, which will reference the checkout via CALIBRE_DEVELOP_FROM.

Is this right? If so, how do I define the Eclipse PyDev project?

Peter
pbw is offline   Reply With Quote
Old 12-19-2011, 04:57 AM   #8
kiwidude
calibre/Sigil Developer
kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.
 
Posts: 4,228
Karma: 1334002
Join Date: Oct 2010
Location: London, UK
Device: Kindle Paperwhite 3G, iPad 3, iPad Air
@pbw - it has been a long while since I setup my Eclipse environment, but from what I recall all I did was
- do a bazaar retrieval of the code into a directory,
- create a new empty Eclipse project in a different folder,
- right-click in the package explorer and add a new folder, click Advanced, and use the "Link to alternate location" to point to the "src" subfolder of the calibre code.
- the PYTHONPATH is set to the src/calibre folder. No external libraries etc.
- set your various other PyDev related defaults. Browse for the setting up Aptana thread in this forum for details of what they are

That is all there is to it from memory. You don't "run" calibre from eclipse - you just use it for editing/navigating the code. You set your CALIBRE_DEVELOP_FROM to point to the same src folder, and just run calibre as per normal, or calibre-debug -g if you want console output.

In my case for writing plugins I have a second folder I keep within src that contains them all, and as part of each plugin subfolder I keep a batch file that launches calibre after installing that plugin. So I can just double click on the batch file in the package explorer of Eclipse to see the new plugin in action.
kiwidude is offline   Reply With Quote
Old 12-19-2011, 05:42 AM   #9
chaley
"chaley", not "charley"
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 5,628
Karma: 857074
Join Date: Jan 2010
Location: France
Device: Many android devices
I use Eclipse Helios and PyDev. I have 4 different calibre projects such as calibre_base (trunk), calibre_dev (my main dev project), a play project, and a project for get_books work. My eclipse workspace is the folder containing these projects. Each project was populated using bzr branch, which I then import into eclipse. I use bzr pull to get trunk changes, then merge these changes into my other projects.

My project settings are:
- python 2.7
- pydev PYTHONPATH/source folders: calibre_project_name/src, for example calibre_base/src

I installed AnyEdit to deal with tab/space conversions (calibre uses spaces, not tabs), removing space at the end of lines, and to convert CR LF to just LF.

I changed (at least) the following Pydev workspace setting: Code analysis/undefined: _,tr,I,P,dynamic_property,lopen, icu_title, icu_lower, icu_upper,ngettext.

I installed Qt and lxml to stop pydev complaining about these being undefined. I am sure I have tweaked other settings, but I don't remember what they are.

Finally, I have a set of script files to choose the calibre code I want to run (sets CALIBRE_DEVELOP_FROM) and another set to choose the library I want to use then run calibre-debug -g.
chaley is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Development [HOWTO] Enable USD Debugging, and gain root with Debug password jcase enTourage Archive 69 04-30-2011 11:43 PM
HowTo: Use git under Windows to track calibre development siebert Development 0 02-26-2011 05:27 PM
Calibre debug file meme Calibre 7 02-01-2011 04:45 PM
Calibre: wie aktiviert man das Debug Verzeichnis? nalor78 Software 1 08-10-2010 09:38 AM
calibre-debug --update-module iain_benson Calibre 4 10-02-2009 07:00 PM


All times are GMT -4. The time now is 08:08 PM.


MobileRead.com is a privately owned, operated and funded community.