aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Carroll <thecarrolls@jiminger.com>2011-04-16 19:51:00 -0400
committerJim Carroll <thecarrolls@jiminger.com>2011-04-18 13:18:01 -0400
commit9c356e2944be07bb77a45c54745aca529fb0ff7f (patch)
tree6063fa9c72231ca791366a657c20b161f235fb31
parent7c4cb239b1601f1c9a10c8117b272a0e8c678454 (diff)
Added a backward compatibility stub for pysqlite2.
-rw-r--r--.gitignore3
-rw-r--r--addons/script.module.pysqlite/addon.xml4
-rw-r--r--addons/script.module.pysqlite/lib/pysqlite2/__init__.py29
-rw-r--r--lib/addons/script.module.pysqlite/Makefile41
4 files changed, 31 insertions, 46 deletions
diff --git a/.gitignore b/.gitignore
index 5415ae3400..2042846ade 100644
--- a/.gitignore
+++ b/.gitignore
@@ -107,7 +107,6 @@ config.log
/addons/visualization.waveform/Waveform_win32.vis
/addons/visualization.itunes/iTunes.mvis
/addons/script.module.pil/
-/addons/script.module.pysqlite/
# /xbmc/guilib/
/xbmc/guilib/Makefile
@@ -129,8 +128,6 @@ config.log
# /lib/addons/
/lib/addons/script.module.pil/
!/lib/addons/script.module.pil/Makefile
-/lib/addons/script.module.pysqlite/
-!/lib/addons/script.module.pysqlite/Makefile
# /lib/asap/
/lib/asap/Makefile
diff --git a/addons/script.module.pysqlite/addon.xml b/addons/script.module.pysqlite/addon.xml
index 6b17794989..fb90f31a44 100644
--- a/addons/script.module.pysqlite/addon.xml
+++ b/addons/script.module.pysqlite/addon.xml
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="script.module.pysqlite"
- name="Python SQLite library"
+ name="Python SQLite library hook"
version="2.5.6"
provider-name="Gerhard Haering">
<requires>
- <import addon="xbmc.python" version="1.0"/>
+ <import addon="xbmc.python" version="2.0"/>
</requires>
<extension point="xbmc.python.module"
library="lib" />
diff --git a/addons/script.module.pysqlite/lib/pysqlite2/__init__.py b/addons/script.module.pysqlite/lib/pysqlite2/__init__.py
new file mode 100644
index 0000000000..f8c66ec1fc
--- /dev/null
+++ b/addons/script.module.pysqlite/lib/pysqlite2/__init__.py
@@ -0,0 +1,29 @@
+
+# if we got here then someone tried to import pysqlite.dbapi2
+# this will only be allowed if the script is greater that version 1.0
+
+import warnings
+
+# Not sure why this might fail but ....
+try:
+ import __main__
+ xbmcapiversion = __main__.__xbmcapiversion__
+except:
+ xbmcapiversion = "1.0"
+ warnings.warn("For some reason the module'" + std(__name__) + "' couldn't get access to '__main__'. This may prevent certain backward compatility modes from operating correctly.")
+
+# if the xbmcapiversion is either not set (because trying to get it failed or
+# the script was invoked in an odd manner from xbmc) ...
+if (float(xbmcapiversion) <= 1.0):
+ # then import sqlite3 in place of dbapi2
+ try:
+ import sqlite3 as dbapi2
+ except Exception, e:
+ warnings.warn("Unable to import sqlite3. This probably means you're on a version of python prior to 2.5 and trying to run an old script.")
+ raise e
+
+ # whine like a sissy ...
+ warnings.warn("DeprecationWarning: the pysqlite2 module is deprecated; stop being lazy and change your script to use sqlite3.")
+else:
+ raise DeprecationWarning("You cannot use pysqlite2 while depending on version " + str(xbmcapiversion) + " of the xbmc.python api. Please use sqlite3 instead.")
+
diff --git a/lib/addons/script.module.pysqlite/Makefile b/lib/addons/script.module.pysqlite/Makefile
deleted file mode 100644
index 3ac4b783ef..0000000000
--- a/lib/addons/script.module.pysqlite/Makefile
+++ /dev/null
@@ -1,41 +0,0 @@
-
-OSTYPE=$(shell uname)
-VERSION=2.5.6
-BASE_URL=http://pysqlite.googlecode.com/files
-SOURCE=pysqlite-$(VERSION)
-ARCHIVE=$(SOURCE).tar.gz
-
-RETRIEVE_TOOL=curl
-RETRIEVE_TOOL_FLAGS=-Ls --output $(ARCHIVE)
-ARCHIVE_TOOL=tar
-ARCHIVE_TOOL_FLAGS=xf
-
-PYTHONDIR=$(abs_top_srcdir)/lib/python
-ifeq ($(OSTYPE),Darwin)
-PYTHON=$(PYTHONDIR)/python.exe
-else
-PYTHON=$(PYTHONDIR)/python
-endif
-
-DESTDIR=$(abs_top_srcdir)/addons/script.module.pysqlite/lib/
-
-CLEAN_FILES=$(ARCHIVE) $(SOURCE) $(DESTDIR)
-
-all: $(DESTDIR)
-
-$(ARCHIVE):
- $(RETRIEVE_TOOL) $(RETRIEVE_TOOL_FLAGS) $(BASE_URL)/$(ARCHIVE)
-
-$(SOURCE): $(ARCHIVE)
- -rm -rf $(SOURCE)
- $(ARCHIVE_TOOL) $(ARCHIVE_TOOL_FLAGS) $(ARCHIVE)
-
-$(DESTDIR): $(SOURCE) $(PYTHON)
- -rm -rf $(DESTDIR)
- pushd $(SOURCE) && LD_LIBRARY_PATH=$(PYTHONDIR) $(PYTHON) setup.py build --build-lib $(DESTDIR); popd
-
-$(PYTHON):
- $(MAKE) -C $(abs_top_srcdir) libpython
-
-include ../../../Makefile.include
-