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 04-13-2018, 01:18 PM   #1
gabox01
Junior Member
gabox01 began at the beginning.
 
Posts: 7
Karma: 10
Join Date: Mar 2018
Device: gabox01
Need help in setting up a Development environment

Hello,

Quote from the docs:

"The next step is to set the environment variable CALIBRE_DEVELOP_FROM to the absolute path of the src directory. So, following the example above, it would be /home/kovid/work/calibre/src. How to set environment variables depends on your Linux distribution and what shell you are using."

What's the reason behind this? I don't want to run any pre-made binaries, I'd like to run the whole thing from source, including the GUI. Any way to achieve that?

"That’s it! You are now ready to start hacking on the calibre code. For example, open the file src\calibre\__init__.py in your favorite editor and add the line:

print ("Hello, world!")
near the top of the file. Now run the command calibredb. The very first line of output should be Hello, world!"


I don't understand this.Why should I run calibredb after making changes to the source? Run what command with calibredb?

Sorry if I look dumb, but I would expect source files, libraries, and a main method to run. Nothing else.

Thanks
gabox01 is offline   Reply With Quote
Old 04-13-2018, 09:08 PM   #2
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 33,470
Karma: 10205098
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
You are running the whole thing from source including the GUI.

And using calibredb is simply an easy way to check that you have setup things correctly.
kovidgoyal is offline   Reply With Quote
Advert
Old 04-22-2018, 12:12 PM   #3
eschwartz
Ex-Helpdesk Junkie
eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.
 
eschwartz's Avatar
 
Posts: 19,247
Karma: 83049305
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
Quote:
Originally Posted by gabox01 View Post
Hello,

Quote from the docs:

"The next step is to set the environment variable CALIBRE_DEVELOP_FROM to the absolute path of the src directory. So, following the example above, it would be /home/kovid/work/calibre/src. How to set environment variables depends on your Linux distribution and what shell you are using."

What's the reason behind this? I don't want to run any pre-made binaries, I'd like to run the whole thing from source, including the GUI. Any way to achieve that?
The instructions explicitly state "You have two choices in setting up the development environment. You can install the calibre binary as normal and use that as a runtime environment to do your development."

You've chosen to look at the binary install development method, rather than setting up a Linux source build. If you didn't want to run someone else's premade binaries, then obviously you need to build them yourself...

But, are you trying to develop the C extension code? If not, what is wrong with using the pre-made binaries together with your modified python code?

Quote:
"That’s it! You are now ready to start hacking on the calibre code. For example, open the file src\calibre\__init__.py in your favorite editor and add the line:

print ("Hello, world!")
near the top of the file. Now run the command calibredb. The very first line of output should be Hello, world!"


I don't understand this.Why should I run calibredb after making changes to the source? Run what command with calibredb?

Sorry if I look dumb, but I would expect source files, libraries, and a main method to run. Nothing else.

Thanks
What makes you think you're not running a main() method? That command runs:

Code:
from calibre.db.cli.main import main
sys.exit(main())
Which is definitely a main() method. It just happens to first execute calibre/__init__.py before doing anything else interesting.
eschwartz is offline   Reply With Quote
Old 04-30-2018, 03:18 PM   #4
gabox01
Junior Member
gabox01 began at the beginning.
 
Posts: 7
Karma: 10
Join Date: Mar 2018
Device: gabox01
Quote:
Originally Posted by eschwartz View Post
The instructions explicitly state "You have two choices in setting up the development environment. You can install the calibre binary as normal and use that as a runtime environment to do your development."

You've chosen to look at the binary install development method, rather than setting up a Linux source build. If you didn't want to run someone else's premade binaries, then obviously you need to build them yourself...

But, are you trying to develop the C extension code? If not, what is wrong with using the pre-made binaries together with your modified python code?



What makes you think you're not running a main() method? That command runs:

Code:
from calibre.db.cli.main import main
sys.exit(main())
Which is definitely a main() method. It just happens to first execute calibre/__init__.py before doing anything else interesting.
I guess I just don't understand this whole 'use the binary as runtime' concept. Your explanation didn't make anything clearer to me in that regard.

I'm not familiar with python, but in the Java world, when I want to run any app from source, I compile the sources, look for the main class, and just run the thing. No precompiled binaries needed. Please explain to me at a kindergarten level why this is even an option because i don't get it.
gabox01 is offline   Reply With Quote
Old 04-30-2018, 04:12 PM   #5
itimpi
Wizard
itimpi ought to be getting tired of karma fortunes by now.itimpi ought to be getting tired of karma fortunes by now.itimpi ought to be getting tired of karma fortunes by now.itimpi ought to be getting tired of karma fortunes by now.itimpi ought to be getting tired of karma fortunes by now.itimpi ought to be getting tired of karma fortunes by now.itimpi ought to be getting tired of karma fortunes by now.itimpi ought to be getting tired of karma fortunes by now.itimpi ought to be getting tired of karma fortunes by now.itimpi ought to be getting tired of karma fortunes by now.itimpi ought to be getting tired of karma fortunes by now.
 
Posts: 4,457
Karma: 949999
Join Date: Nov 2008
Device: Sony PRS-950, iphone/ipad (Marvin/iBooks/QuickReader)
It is worth reading up on how Python works. Python does not have a traditional compile phase and uses a “Just-in-time” technique for the python source code. By starting with the compiled binaries you make certain that all dependencies (C modules, libraries etc) are installed. If now install the source as well then any modules that have been changed will use the updated Python source.

Going right back to basics and building non-Python components is a much bigger task and not one that is required if you are only making alterations at the Python level.
itimpi is offline   Reply With Quote
Advert
Old 05-01-2018, 03:18 AM   #6
gabox01
Junior Member
gabox01 began at the beginning.
 
Posts: 7
Karma: 10
Join Date: Mar 2018
Device: gabox01
Quote:
Originally Posted by itimpi View Post
It is worth reading up on how Python works. Python does not have a traditional compile phase and uses a “Just-in-time” technique for the python source code. By starting with the compiled binaries you make certain that all dependencies (C modules, libraries etc) are installed. If now install the source as well then any modules that have been changed will use the updated Python source.

Going right back to basics and building non-Python components is a much bigger task and not one that is required if you are only making alterations at the Python level.
Thanks, it is much clearer now.
Would it be technically possible to put those C modules, libraries etc.. in a directory in binary form, and make them available to your python code, so you don't have to use a binary at all? In Java, you can use the classpath to achieve that.
gabox01 is offline   Reply With Quote
Old 05-01-2018, 06:35 AM   #7
itimpi
Wizard
itimpi ought to be getting tired of karma fortunes by now.itimpi ought to be getting tired of karma fortunes by now.itimpi ought to be getting tired of karma fortunes by now.itimpi ought to be getting tired of karma fortunes by now.itimpi ought to be getting tired of karma fortunes by now.itimpi ought to be getting tired of karma fortunes by now.itimpi ought to be getting tired of karma fortunes by now.itimpi ought to be getting tired of karma fortunes by now.itimpi ought to be getting tired of karma fortunes by now.itimpi ought to be getting tired of karma fortunes by now.itimpi ought to be getting tired of karma fortunes by now.
 
Posts: 4,457
Karma: 949999
Join Date: Nov 2008
Device: Sony PRS-950, iphone/ipad (Marvin/iBooks/QuickReader)
Quote:
Originally Posted by gabox01 View Post
Thanks, it is much clearer now.
Would it be technically possible to put those C modules, libraries etc.. in a directory in binary form, and make them available to your python code, so you don't have to use a binary at all? In Java, you can use the classpath to achieve that.
that is effectively what you are doing when you use the suggested method for setting up a development environment! The Calibre binary install location becomes the place where the python interpreter looks for required modules when running from Calibre python source.
itimpi 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
Setting up Calibre development environment EngelEatos Development 3 04-22-2018 12:20 PM
Setting up a development environment ... BWinmill Kobo Developer's Corner 27 06-16-2014 08:21 AM
"Setting up a calibre development environment" documentation suggestion trying Development 1 03-30-2014 10:25 PM
Setting up Mac Calibre development environment? pdurrant Calibre 2 01-06-2009 07:10 AM
Setting up development environment tompe OpenInkpot 9 08-27-2008 02:26 PM


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


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