[pygobject] Fix separate build tree and distcheck
- From: Martin Pitt <martinpitt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pygobject] Fix separate build tree and distcheck
- Date: Mon, 3 Sep 2012 09:07:53 +0000 (UTC)
commit dc2c6e6f60d2757462cbceef6176b0b3013904d3
Author: Martin Pitt <martinpitt gnome org>
Date: Mon Sep 3 10:18:45 2012 +0200
Fix separate build tree and distcheck
Fix regression from c7c95a79: We must set sys.path in runtests.py properly and
cannot rely on setting $PYTHONPATH from Makefile.am only. Python always
prepends the directory of the source file to sys.path, but that points to the
source dir, not the build dir. The build dir has to take precedence, otherwise
we fail to import the built libraries.
tests/runtests-windows.py | 10 +++++++---
tests/runtests.py | 13 ++++++++-----
2 files changed, 15 insertions(+), 8 deletions(-)
---
diff --git a/tests/runtests-windows.py b/tests/runtests-windows.py
index d004603..36ab9e1 100644
--- a/tests/runtests-windows.py
+++ b/tests/runtests-windows.py
@@ -8,9 +8,13 @@ import glob
import unittest
mydir = os.path.dirname(os.path.abspath(__file__))
-# The ordering of sys.path should be ['.../pyobject', '.../pygobject/tests']
-sys.path.insert(0, mydir)
-sys.path.insert(0, os.path.dirname(mydir))
+tests_builddir = os.path.abspath(os.environ.get('TESTS_BUILDDIR', os.path.dirname(__file__)))
+builddir = os.path.dirname(tests_builddir)
+
+# we have to do this here instead of Makefile.am so that the implicitly added
+# directory for the source file comes after the builddir
+sys.path.insert(0, tests_builddir)
+sys.path.insert(0, builddir)
os.environ['PYGTK_USE_GIL_STATE_API'] = ''
sys.argv.append('--g-fatal-warnings')
diff --git a/tests/runtests.py b/tests/runtests.py
index efc2e1c..c518fcc 100755
--- a/tests/runtests.py
+++ b/tests/runtests.py
@@ -39,9 +39,13 @@ if '--help' in sys.argv:
sys.exit(0)
mydir = os.path.dirname(os.path.abspath(__file__))
-# The ordering of sys.path should be ['.../pyobject', '.../pygobject/tests']
-sys.path.insert(0, mydir)
-sys.path.insert(0, os.path.dirname(mydir))
+tests_builddir = os.path.abspath(os.environ.get('TESTS_BUILDDIR', os.path.dirname(__file__)))
+builddir = os.path.dirname(tests_builddir)
+
+# we have to do this here instead of Makefile.am so that the implicitly added
+# directory for the source file comes after the builddir
+sys.path.insert(0, tests_builddir)
+sys.path.insert(0, builddir)
# force untranslated messages, as we check for them in some tests
os.environ['LC_MESSAGES'] = 'C'
@@ -51,8 +55,7 @@ os.environ['G_DEBUG'] = 'fatal-warnings fatal-criticals'
# before importing Gio. Support a separate build tree, so look in build dir
# first.
os.environ['GSETTINGS_BACKEND'] = 'memory'
-os.environ['GSETTINGS_SCHEMA_DIR'] = os.environ.get('TESTS_BUILDDIR',
- os.path.dirname(__file__))
+os.environ['GSETTINGS_SCHEMA_DIR'] = tests_builddir
# Load tests.
if 'TEST_NAMES' in os.environ:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]