Patchwork [bitbake-devel,2/2] prserv: fix import of sqlite3

login
register
mail settings
Submitter Martin Jansa
Date Jan. 15, 2012, 9:03 p.m.
Message ID <1326661433-26379-2-git-send-email-Martin.Jansa@gmail.com>
Download mbox | patch
Permalink /patch/19403/
State Accepted
Commit 9a57ec705cf5c932d8c2a35852db7a4627c57937
Headers show

Comments

Martin Jansa - Jan. 15, 2012, 9:03 p.m.
* this is used in all other bitbake parts where sqlite3 is used, don't
  know why it wasn't used here, but it fails e.g. on Gentoo
  Traceback (most recent call last):
    File "bin/bitbake", line 39, in <module>
      from bb import cooker
    File "lib/bb/cooker.py", line 39, in <module>
      import prserv.serv
    File "lib/prserv/serv.py", line 4, in <module>
      import xmlrpclib,sqlite3
  ImportError: No module named sqlite3

Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
---
 lib/prserv/serv.py |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)
Richard Purdie - Jan. 20, 2012, 4:44 p.m.
On Sun, 2012-01-15 at 22:03 +0100, Martin Jansa wrote:
> * this is used in all other bitbake parts where sqlite3 is used, don't
>   know why it wasn't used here, but it fails e.g. on Gentoo
>   Traceback (most recent call last):
>     File "bin/bitbake", line 39, in <module>
>       from bb import cooker
>     File "lib/bb/cooker.py", line 39, in <module>
>       import prserv.serv
>     File "lib/prserv/serv.py", line 4, in <module>
>       import xmlrpclib,sqlite3
>   ImportError: No module named sqlite3
> 
> Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
> ---
>  lib/prserv/serv.py |    7 ++++++-
>  1 files changed, 6 insertions(+), 1 deletions(-)

Merged to master along with 1/2.

Why this is needed I'm not sure since I thought sqlite3 was included in
python 2.6 onwards. Since you're running into it and it doesn't hurt
anything I've merged it though.

Cheers,

Richard
Martin Jansa - Jan. 20, 2012, 5:01 p.m.
On Fri, Jan 20, 2012 at 04:44:47PM +0000, Richard Purdie wrote:
> On Sun, 2012-01-15 at 22:03 +0100, Martin Jansa wrote:
> > * this is used in all other bitbake parts where sqlite3 is used, don't
> >   know why it wasn't used here, but it fails e.g. on Gentoo
> >   Traceback (most recent call last):
> >     File "bin/bitbake", line 39, in <module>
> >       from bb import cooker
> >     File "lib/bb/cooker.py", line 39, in <module>
> >       import prserv.serv
> >     File "lib/prserv/serv.py", line 4, in <module>
> >       import xmlrpclib,sqlite3
> >   ImportError: No module named sqlite3
> > 
> > Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
> > ---
> >  lib/prserv/serv.py |    7 ++++++-
> >  1 files changed, 6 insertions(+), 1 deletions(-)
> 
> Merged to master along with 1/2.
> 
> Why this is needed I'm not sure since I thought sqlite3 was included in
> python 2.6 onwards. Since you're running into it and it doesn't hurt
> anything I've merged it though.

In gentoo there is USE flag for sqlite support which is off by default,
so it's easy to get even newer python like 2.7 or 3* without sqlite
enabled by default and extra package dev-python/pysqlite providing
alternative.

I guess correct fix would be to change bitbake .ebuild to depend on
python with sqlite USE flag enabled, but as it was catched and fixed in
other places in bitbake code I've added it here too.

Cheers,

> 
> Cheers,
> 
> Richard
>

Patch

diff --git a/lib/prserv/serv.py b/lib/prserv/serv.py
index a759fa7..fa437f9 100644
--- a/lib/prserv/serv.py
+++ b/lib/prserv/serv.py
@@ -1,7 +1,12 @@ 
 import os,sys,logging
 import signal, time, atexit, threading
 from SimpleXMLRPCServer import SimpleXMLRPCServer, SimpleXMLRPCRequestHandler
-import xmlrpclib,sqlite3
+import xmlrpclib
+
+try:
+    import sqlite3
+except ImportError:
+    from pysqlite2 import dbapi2 as sqlite3
 
 import bb.server.xmlrpc
 import prserv