summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2009-07-17 14:10:21 +0200
committerJulian Andres Klode <jak@debian.org>2009-07-17 14:10:21 +0200
commitb63d93492cba1ffd11454ab37e751ef6f938ff96 (patch)
treee5eac907be9f33c4cb822a6cb9efb5aba0255e47
parent5dbe872723f375db9f5d371051f6a9756fdc4c60 (diff)
downloadpython-apt-b63d93492cba1ffd11454ab37e751ef6f938ff96.tar.gz
doc/source/conf.py: Ignore failures to import apt_pkg.
-rw-r--r--doc/source/conf.py21
1 files changed, 15 insertions, 6 deletions
diff --git a/doc/source/conf.py b/doc/source/conf.py
index 5a289f32..86e6868c 100644
--- a/doc/source/conf.py
+++ b/doc/source/conf.py
@@ -16,6 +16,7 @@
# All configuration values have a default; values that are commented out
# serve to show the default.
import os
+import glob
import sys
# If your extensions are in another directory, add it here. If the directory
@@ -27,13 +28,21 @@ sys.path.insert(0, os.path.abspath('../..'))
# Find the path to the built apt_pkg and apt_inst extensions
if os.path.exists("../../build"):
version = '.'.join(str(x) for x in sys.version_info[:2])
- for dirname in os.listdir('../../build'):
- if version in dirname:
- sys.path.insert(0, os.path.abspath('../../build/' + dirname))
+ for apt_pkg_path in glob.glob('../../build/lib*%s/apt_pkg.so' % version):
+ sys.path.insert(0, os.path.dirname(apt_pkg_path))
+ try:
+ import apt_pkg
+ except ImportError, exc:
+ # Not the correct version
+ sys.stderr.write('W: Ignoring error %s\n' % exc)
+ sys.path.pop(0)
+ else:
+ sys.stdout.write('I: Found apt_pkg.so in %s\n' % sys.path[0])
+ # Hack: Disable compatibility mode
+ apt_pkg._COMPAT_0_7 = 0
+ break
+
-# Hack: Disable compatibility mode
-import apt_pkg
-apt_pkg._COMPAT_0_7 = 0
# General configuration
# ---------------------