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

Go Back   MobileRead Forums > E-Book Software > Calibre

Notices

Reply
 
Thread Tools Search this Thread
Old 01-09-2012, 02:25 AM   #1
Kevin McAleavey
Junior Member
Kevin McAleavey began at the beginning.
 
Posts: 6
Karma: 10
Join Date: Jan 2012
Location: Albany, NY
Device: none
Calibre in a Python 3.2 world, attn: Kovid

The unix world is rapidly getting dragged into Python 3.x and our OS is just another one in that situation. We're planning to provide calibre with our upcoming release, but with other Python 3.x code, it has hopelessly broken calibre. It was so much of a showstopper for us that we had to consider removing calibre as we really need the other stuff. Tried correcting some syntax errors vis-a-vis 3.x but saw that was hopeless.

I wanted to keep calibre so much, stumbled onto a solution that should be able to be integrated into the next calibre release. 3.x versions of python set themselves up in environment as "python" and when the calibre in /usr/(local/)bin calls calibre there, at the top is "#!/usr/bin/env python" which will call 3.x by default. We also ship PY27, and a simple edit of that top line in "calibre" to "#!/usr/bin/env python2.7" in our case solved it and has calibre calling the older Python.

Kovid ... might want to consider coding up your call to ensure that the older Python is called here rather than the default of whatever is set as "python" in the environment. In our KNOS (BSD-based) OS, just changing that one line fixed it all.

I can be contacted at knosproject.com if you need more ...
Kevin McAleavey is offline   Reply With Quote
Old 01-09-2012, 03:02 AM   #2
Kevin McAleavey
Junior Member
Kevin McAleavey began at the beginning.
 
Posts: 6
Karma: 10
Join Date: Jan 2012
Location: Albany, NY
Device: none
In further going through the various calls, looks like there's a bunch of them that need this treatment, but in each case, the solution described above makes them work again. Just wanted to note that all of the calls I've touched so far, this is bringing each of them back to life. All that's needed is substitution of that correct python call instead of the generic "python" and that should allow calibre to be compatible with newer python installations on other OS' ... I'm currently rummaging through the source file to identify how many others I need to fix. I'm also turning off the update feature for now to prevent this solution from getting sullied by updates that revert back to generic python calls.
Kevin McAleavey is offline   Reply With Quote
Advert
Old 01-09-2012, 03:10 AM   #3
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: 43,748
Karma: 22446736
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
calibre uses

#!/usr/bin/env python2

It has for a long time. How did you get a version that uses bare python?
kovidgoyal is offline   Reply With Quote
Old 01-09-2012, 03:14 AM   #4
Kevin McAleavey
Junior Member
Kevin McAleavey began at the beginning.
 
Posts: 6
Karma: 10
Join Date: Jan 2012
Location: Albany, NY
Device: none
Quote:
Originally Posted by kovidgoyal View Post
calibre uses

#!/usr/bin/env python2

It has for a long time. How did you get a version that uses bare python?
Hey guy!

FreeBSD package. There is no "python2" in BSD, it's "python2.7" ... used to be "python2.5" a while back. BSD allows multiple versions to run side by side *if* the version is specified, otherwise it defaults to whatever "wins." But the FreeBSD distro of the package for 9 version has your top script saying "#!/usr/bin/env python" ... have it here on my screen.

FYI: Maintainer of the port for FreeBSD is Rusty Nejdl <rnejdl@ringofsaturn.com>

Edit again: Just CONFIRMED that with "python2" up there, fails on BSD. It NEEDS 2.7 in order to match the existing versions available. Any chance of hunting for the version and slapping it in there for BSD? I have no problem doing it for our own stuff once I establish all of the modules that need the edit, but I think I know why they stripped the "2" off your source now.

Last edited by Kevin McAleavey; 01-09-2012 at 03:28 AM.
Kevin McAleavey is offline   Reply With Quote
Old 01-09-2012, 03:30 AM   #5
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: 43,748
Karma: 22446736
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
I'm afraid I don't maintain the BSD calibre packages, you should contact Rusty. I will say that having a python2 symlink pointing to the latest python2 binary is good practice and should be encouraged. See http://www.python.org/dev/peps/pep-0394/
kovidgoyal is offline   Reply With Quote
Advert
Old 01-09-2012, 03:51 AM   #6
Kevin McAleavey
Junior Member
Kevin McAleavey began at the beginning.
 
Posts: 6
Karma: 10
Join Date: Jan 2012
Location: Albany, NY
Device: none
Quote:
Originally Posted by kovidgoyal View Post
I'm afraid I don't maintain the BSD calibre packages, you should contact Rusty. I will say that having a python2 symlink pointing to the latest python2 binary is good practice and should be encouraged. See http://www.python.org/dev/peps/pep-0394/
Thanks! I'm filing a PR on it now, and will include that suggestion. But currently, the source WE get does not claim "python2" in there and "python" will point at python 3. Boy oh boy after looking over your code, and how SEVERELY limited the python 3 stuff is, I sure can understand why you don't want to step in it.

Was not aware of what you were doing for other OS' and so thought this might help. I'll beat up on my own then. Heh. Meanwhile, another tedious night on our end because we're kinda fond of things working properly here. Dunno why the python2 call you did disappeared, but I'll rub Rusty's nose in it for ya.
Kevin McAleavey is offline   Reply With Quote
Old 01-09-2012, 06:55 AM   #7
Kevin McAleavey
Junior Member
Kevin McAleavey began at the beginning.
 
Posts: 6
Karma: 10
Join Date: Jan 2012
Location: Albany, NY
Device: none
Pr filed with BSD:

http://www.freebsd.org/cgi/query-pr.cgi?pr=163948
Kevin McAleavey is offline   Reply With Quote
Old 01-09-2012, 09:57 AM   #8
Serpentine
Evangelist
Serpentine ought to be getting tired of karma fortunes by now.Serpentine ought to be getting tired of karma fortunes by now.Serpentine ought to be getting tired of karma fortunes by now.Serpentine ought to be getting tired of karma fortunes by now.Serpentine ought to be getting tired of karma fortunes by now.Serpentine ought to be getting tired of karma fortunes by now.Serpentine ought to be getting tired of karma fortunes by now.Serpentine ought to be getting tired of karma fortunes by now.Serpentine ought to be getting tired of karma fortunes by now.Serpentine ought to be getting tired of karma fortunes by now.Serpentine ought to be getting tired of karma fortunes by now.
 
Posts: 416
Karma: 1045911
Join Date: Sep 2011
Location: Cape Town, South Africa
Device: Kindle 3
The FreeBSD 'port' already has patches for the python2 -> python. You can just remove this for your local tree (/usr/local/ports/deskutils/calibre/files/ iirc), tho it would be fair to suggest that the correct python dependency is added if it is not there already - since python 2 is still the recommended version.
Serpentine is offline   Reply With Quote
Old 01-09-2012, 05:49 PM   #9
Kevin McAleavey
Junior Member
Kevin McAleavey began at the beginning.
 
Posts: 6
Karma: 10
Join Date: Jan 2012
Location: Albany, NY
Device: none
Quote:
Originally Posted by Serpentine View Post
The FreeBSD 'port' already has patches for the python2 -> python. You can just remove this for your local tree (/usr/local/ports/deskutils/calibre/files/ iirc), tho it would be fair to suggest that the correct python dependency is added if it is not there already - since python 2 is still the recommended version.
In our case, we installed from "packages" rather than compiling from ports, and it appears that wasn't done in the packages. Not uncommon in BSD world for packages to take defaults you don't want them to, everything was smooth sailing until a Python3-based app was added later. It seems to have replaced "python" in /usr/local/bin with a 3 version and that's when the 'fun" started.

Still waiting to hear back from the maintainer ...
Kevin McAleavey 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
Thank You Kovid & the Entire Calibre Team pghaworth Calibre 17 01-31-2011 12:16 PM
Help Kovid 7.31 still getting python error sadievan Calibre 10 11-28-2010 06:27 PM
Thank you Kovid and Calibre crew! pshrynk Calibre 16 04-13-2009 08:56 PM
calibre: most desired feature, pony up for Kovid astrodad Calibre 96 07-17-2008 06:53 PM


All times are GMT -4. The time now is 07:12 AM.


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