mirror of https://github.com/python/cpython
cleaned up setup.py code for sqlite3, based on patch from Gerhard Haering.
This commit is contained in:
parent
04ee87097c
commit
3dc6bb3c25
38
setup.py
38
setup.py
|
@ -692,8 +692,8 @@ class PyBuildExt(build_ext):
|
||||||
# The sqlite interface
|
# The sqlite interface
|
||||||
sqlite_setup_debug = True # verbose debug prints from this script?
|
sqlite_setup_debug = True # verbose debug prints from this script?
|
||||||
|
|
||||||
# We hunt for "#define SQLITE_VERSION_NUMBER nnnnn"
|
# We hunt for #define SQLITE_VERSION "n.n.n"
|
||||||
# We need to find a version >= 3002002 (> sqlite version 3.2.2)
|
# We need to find >= sqlite version 3.0.8
|
||||||
sqlite_incdir = sqlite_libdir = None
|
sqlite_incdir = sqlite_libdir = None
|
||||||
sqlite_inc_paths = [ '/usr/include',
|
sqlite_inc_paths = [ '/usr/include',
|
||||||
'/usr/include/sqlite',
|
'/usr/include/sqlite',
|
||||||
|
@ -702,39 +702,31 @@ class PyBuildExt(build_ext):
|
||||||
'/usr/local/include/sqlite',
|
'/usr/local/include/sqlite',
|
||||||
'/usr/local/include/sqlite3',
|
'/usr/local/include/sqlite3',
|
||||||
]
|
]
|
||||||
MIN_SQLITE_VERSION_NUMBER = 3000008
|
MIN_SQLITE_VERSION_NUMBER = (3, 0, 8)
|
||||||
MIN_SQLITE_VERSION = "3.0.8"
|
MIN_SQLITE_VERSION = ".".join([str(x)
|
||||||
|
for x in MIN_SQLITE_VERSION_NUMBER])
|
||||||
for d in sqlite_inc_paths + inc_dirs:
|
for d in sqlite_inc_paths + inc_dirs:
|
||||||
f = os.path.join(d, "sqlite3.h")
|
f = os.path.join(d, "sqlite3.h")
|
||||||
if os.path.exists(f):
|
if os.path.exists(f):
|
||||||
if sqlite_setup_debug: print "sqlite: found %s"%f
|
if sqlite_setup_debug: print "sqlite: found %s"%f
|
||||||
f = open(f).read()
|
incf = open(f).read()
|
||||||
m = re.search(r"#define\WSQLITE_VERSION_NUMBER\W(\d+)", f)
|
m = re.search(
|
||||||
if m:
|
r'\s*.*#\s*.*define\s.*SQLITE_VERSION\W*"(.*)"', incf)
|
||||||
sqlite_version = int(m.group(1))
|
|
||||||
if sqlite_version >= MIN_SQLITE_VERSION_NUMBER:
|
|
||||||
# we win!
|
|
||||||
print "%s/sqlite3.h: version %s"%(d, sqlite_version)
|
|
||||||
sqlite_incdir = d
|
|
||||||
break
|
|
||||||
elif sqlite_version == 3000000:
|
|
||||||
# Bug in a common version out there where
|
|
||||||
# SQLITE_VERSION_NUMBER was set incorrectly
|
|
||||||
if sqlite_setup_debug:
|
|
||||||
print "found buggy SQLITE_VERSION_NUMBER, checking"
|
|
||||||
m = re.search(r'#define\WSQLITE_VERSION\W+"([\.\d]+)"',
|
|
||||||
f)
|
|
||||||
if m:
|
if m:
|
||||||
sqlite_version = m.group(1)
|
sqlite_version = m.group(1)
|
||||||
if sqlite_version >= MIN_SQLITE_VERSION:
|
sqlite_version_tuple = tuple([int(x)
|
||||||
print "%s/sqlite3.h: version %s"%(d,
|
for x in sqlite_version.split(".")])
|
||||||
sqlite_version)
|
if sqlite_version_tuple >= MIN_SQLITE_VERSION_NUMBER:
|
||||||
|
# we win!
|
||||||
|
print "%s/sqlite3.h: version %s"%(d, sqlite_version)
|
||||||
sqlite_incdir = d
|
sqlite_incdir = d
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
if sqlite_setup_debug:
|
if sqlite_setup_debug:
|
||||||
print "%s: version %d is too old, need >= %s"%(d,
|
print "%s: version %d is too old, need >= %s"%(d,
|
||||||
sqlite_version, MIN_SQLITE_VERSION)
|
sqlite_version, MIN_SQLITE_VERSION)
|
||||||
|
elif sqlite_setup_debug:
|
||||||
|
print "sqlite: %s had no SQLITE_VERSION"%(f,)
|
||||||
|
|
||||||
if sqlite_incdir:
|
if sqlite_incdir:
|
||||||
sqlite_dirs_to_check = [
|
sqlite_dirs_to_check = [
|
||||||
|
|
Loading…
Reference in New Issue