[pygobject] Fix "distcheck" and tests with out-of-tree builds



commit 81de788a72b40acd2f857718d78bdeea01d12eb1
Author: Martin Pitt <martin pitt ubuntu com>
Date:   Mon Mar 26 17:45:08 2012 +0200

    Fix "distcheck" and tests with out-of-tree builds
    
    - Symlink *.py files from srcdir into builddir during build, as Python does not
      accept the extensions and modules in different paths.
    - "make clean" should remove *.pyc files
    - tests/runtests.py: Look for tests in srcdir, not in builddir

 Makefile.am               |    6 ++++--
 gi/Makefile.am            |   13 +++++++++++--
 gi/_glib/Makefile.am      |   12 ++++++++++--
 gi/_gobject/Makefile.am   |   12 ++++++++++--
 gi/overrides/Makefile.am  |   10 ++++++++++
 gi/repository/Makefile.am |   11 +++++++++++
 tests/runtests.py         |    6 ++++--
 7 files changed, 60 insertions(+), 10 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 17cfc71..4007768 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -5,7 +5,9 @@ SUBDIRS = examples gi tests
 
 PLATFORM_VERSION = 3.0
 
-CLEANFILES =
+CLEANFILES = \
+	`find "$(builddir)" -type f -name "*.pyc" -print`
+
 EXTRA_DIST = \
 	ChangeLog.pre-2.18 \
 	pygobject-$(PLATFORM_VERSION).pc.in \
@@ -40,7 +42,7 @@ MAINTAINERCLEANFILES = \
 	$(srcdir)/m4/ltversion.m4 \
 	$(srcdir)/m4/lt~obsolete.m4 \
 	`find "$(srcdir)" -type f -name Makefile.in -print` \
-	`find "$(srcdir)" -type f -name "*.pyc" -print`
+	`find "$(builddir)" -type f -name "*.pyc" -print`
 
 BUILT_EXTRA_DIST = 		\
 	ChangeLog
diff --git a/gi/Makefile.am b/gi/Makefile.am
index 2009d2c..0974b4f 100644
--- a/gi/Makefile.am
+++ b/gi/Makefile.am
@@ -117,8 +117,17 @@ _gi_cairo_la_LDFLAGS = \
 .la.so:
 	$(LN_S) .libs/$@ $@ || true
 
-all-local: $(LTLIBRARIES:.la=.so)
-check-local: $(LTLIBRARIES:.la=.so)
+# if we build in a separate tree, we need to symlink the *.py files from the
+# source tree; Python does not accept the extensions and modules in different
+# paths
+build_pylinks:
+	for f in $(pygi_PYTHON); do \
+	    [ -e $(builddir)/$$f ] || $(LN_S) $(srcdir)/$$f $(builddir)/$$f; \
+	done
+
+all-local: $(LTLIBRARIES:.la=.so) build_pylinks
+
+check-local: $(LTLIBRARIES:.la=.so) build_pylinks
 clean-local:
 	rm -f $(LTLIBRARIES:.la=.so)
 
diff --git a/gi/_glib/Makefile.am b/gi/_glib/Makefile.am
index 3cf2593..c152039 100644
--- a/gi/_glib/Makefile.am
+++ b/gi/_glib/Makefile.am
@@ -82,9 +82,17 @@ if PLATFORM_WIN32
 _glib_la_CFLAGS += -DPLATFORM_WIN32
 endif
 
+# if we build in a separate tree, we need to symlink the *.py files from the
+# source tree; Python does not accept the extensions and modules in different
+# paths
+build_pylinks:
+	for f in $(pyglib_PYTHON); do \
+	    [ -e $(builddir)/$$f ] || $(LN_S) $(srcdir)/$$f $(builddir)/$$f; \
+	done
 
-all: $(pyglib_LTLIBRARIES:.la=.so)
-check-local: $(pyglib_LTLIBRARIES:.la=.so)
+
+all: $(pyglib_LTLIBRARIES:.la=.so) build_pylinks
+check-local: $(pyglib_LTLIBRARIES:.la=.so) build_pylinks
 clean-local:
 	rm -f $(pyglib_LTLIBRARIES:.la=.so)
 .la.so:
diff --git a/gi/_gobject/Makefile.am b/gi/_gobject/Makefile.am
index 3263889..36fd662 100644
--- a/gi/_gobject/Makefile.am
+++ b/gi/_gobject/Makefile.am
@@ -69,9 +69,17 @@ _gobject_la_LDFLAGS = \
 	$(extension_ldflags) \
 	-export-symbols-regex "_gobject|PyInit__gobject"
 
+# if we build in a separate tree, we need to symlink the *.py files from the
+# source tree; Python does not accept the extensions and modules in different
+# paths
+build_pylinks:
+	for f in $(pygobject_PYTHON); do \
+	    [ -e $(builddir)/$$f ] || $(LN_S) $(srcdir)/$$f $(builddir)/$$f; \
+	done
 
-all: $(pygobject_LTLIBRARIES:.la=.so)
-check-local: $(pygobject_LTLIBRARIES:.la=.so)
+
+all: $(pygobject_LTLIBRARIES:.la=.so) build_pylinks
+check-local: $(pygobject_LTLIBRARIES:.la=.so) build_pylinks
 clean-local:
 	rm -f $(pygobject_LTLIBRARIES:.la=.so)
 .la.so:
diff --git a/gi/overrides/Makefile.am b/gi/overrides/Makefile.am
index 2657eb3..5d9ddd6 100644
--- a/gi/overrides/Makefile.am
+++ b/gi/overrides/Makefile.am
@@ -10,5 +10,15 @@ pygioverrides_PYTHON = \
 	keysyms.py \
 	__init__.py
 
+# if we build in a separate tree, we need to symlink the *.py files from the
+# source tree; Python does not accept the extensions and modules in different
+# paths
+build_pylinks:
+	for f in $(pygioverrides_PYTHON); do \
+	    [ -e $(builddir)/$$f ] || $(LN_S) $(srcdir)/$$f $(builddir)/$$f; \
+	done
+
+all-local: build_pylinks
+check-local: build_pylinks
 
 -include $(top_srcdir)/git.mk
diff --git a/gi/repository/Makefile.am b/gi/repository/Makefile.am
index 9326dc3..27d5e81 100644
--- a/gi/repository/Makefile.am
+++ b/gi/repository/Makefile.am
@@ -4,4 +4,15 @@ pygirepository_PYTHON = \
 	__init__.py
 
 
+# if we build in a separate tree, we need to symlink the *.py files from the
+# source tree; Python does not accept the extensions and modules in different
+# paths
+build_pylinks:
+	for f in $(pygirepository_PYTHON); do \
+	    [ -e $(builddir)/$$f ] || $(LN_S) $(srcdir)/$$f $(builddir)/$$f; \
+	done
+
+all-local: build_pylinks
+check-local: build_pylinks
+
 -include $(top_srcdir)/git.mk
diff --git a/tests/runtests.py b/tests/runtests.py
index baacb89..4dddc72 100755
--- a/tests/runtests.py
+++ b/tests/runtests.py
@@ -11,6 +11,8 @@ if '--help' in sys.argv:
     print("Usage: ./runtests.py <testfiles>")
     sys.exit(0)
 
+mydir = os.path.dirname(os.path.abspath(__file__))
+
 # force untranslated messages, as we check for them in some tests
 os.environ['LC_MESSAGES'] = 'C'
 os.environ['G_DEBUG'] = 'fatal-warnings fatal-criticals'
@@ -35,8 +37,8 @@ elif len(sys.argv) > 1:
         names.append(filename.replace('.py', ''))
 else:
     names = []
-    for filename in glob.iglob("test_*.py"):
-        names.append(filename[:-3])
+    for filename in glob.iglob(os.path.join(mydir, 'test_*.py')):
+        names.append(os.path.basename(filename)[:-3])
 
 loader = unittest.TestLoader()
 suite = loader.loadTestsFromNames(names)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]