From: Zooko O'Whielacronx Date: Thu, 4 Jun 2009 15:37:28 +0000 (-0700) Subject: setup: add pysqlite and sqlite to get_package_versions() X-Git-Tag: trac-3900~2 X-Git-Url: https://git.rkrishnan.org/%5B/frontends//%22%22?a=commitdiff_plain;h=2841d6a266715f633622b6c6f274cfba3524ac48;p=tahoe-lafs%2Ftahoe-lafs.git setup: add pysqlite and sqlite to get_package_versions() --- diff --git a/src/allmydata/__init__.py b/src/allmydata/__init__.py index 2e2d8b1d..deebb080 100644 --- a/src/allmydata/__init__.py +++ b/src/allmydata/__init__.py @@ -133,10 +133,29 @@ def get_platform(): return platform.platform() def get_package_versions_and_locations(): - # because there are a few dependencies that are outside setuptools's ken (Python and - # platform), and because setuptools might fail to find something even though import finds - # it: + # because there are a few dependencies that are outside setuptools's ken + # (Python and platform, and sqlite3 if you are on Python >= 2.5), and + # because setuptools might fail to find something even though import + # finds it: import OpenSSL, allmydata, foolscap.api, nevow, platform, pycryptopp, setuptools, simplejson, twisted, zfec, zope.interface + pysqlitever = None + pysqlitefile = None + sqlitever = None + try: + import sqlite3 + except ImportError: + try: + from pysqlite2 import dbapi2 + except ImportError: + pass + else: + pysqlitever = dbapi2.version + pysqlitefile = os.path.dirname(dbapi2.__file__) + sqlitever = dbapi2.sqlite_version + else: + pysqlitever = sqlite3.version + pysqlitefile = os.path.dirname(sqlite3.__file__) + sqlitever = sqlite3.sqlite_version d1 = { 'pyOpenSSL': (OpenSSL.__version__, os.path.dirname(OpenSSL.__file__)), @@ -146,6 +165,8 @@ def get_package_versions_and_locations(): 'pycryptopp': (pycryptopp.__version__, os.path.dirname(pycryptopp.__file__)), 'setuptools': (setuptools.__version__, os.path.dirname(setuptools.__file__)), 'simplejson': (simplejson.__version__, os.path.dirname(simplejson.__file__)), + 'pysqlite': (pysqlitever, pysqlitefile), + 'sqlite': (sqlitever, 'unknown'), 'zope.interface': ('unknown', os.path.dirname(zope.interface.__file__)), 'Twisted': (twisted.__version__, os.path.dirname(twisted.__file__)), 'zfec': (zfec.__version__, os.path.dirname(zfec.__file__)), diff --git a/src/allmydata/scripts/backupdb.py b/src/allmydata/scripts/backupdb.py index e04e0ea7..8ab41d15 100644 --- a/src/allmydata/scripts/backupdb.py +++ b/src/allmydata/scripts/backupdb.py @@ -1,8 +1,9 @@ # the backupdb is only available if sqlite3 is available. Python-2.5.x and # beyond include sqlite3 in the standard library. For python-2.4, the -# "pysqlite2" package (which, despite the confusing name, uses sqlite3) must -# be installed. On debian, install python-pysqlite2 +# "pysqlite2" "package" (or "module") (which, despite the confusing name, uses +# sqlite3, and which, confusingly, comes in the "pysqlite" "distribution" (or +# "package")) must be installed. On debian, install python-pysqlite2 import os.path, sys, time, random, stat