[pygobject] add checks so we can compile under python 3 by setting PYTHON=python3



commit 4ed100f3183c6325dd04461484e877bb7d4131b1
Author: John (J5) Palmieri <johnp redhat com>
Date:   Fri Sep 17 12:08:09 2010 -0400

    add checks so we can compile under python 3 by setting PYTHON=python3
    
    * compile for python 3
    * disables gio if compiling under python 3.x
    * runs only pertinant tests
    
    https://bugzilla.gnome.org/show_bug.cgi?id=615872

 configure.ac      |   32 +++++++++++++++++++++++++++++---
 tests/Makefile.am |   35 ++++++++++++++++++++---------------
 tests/runtests.py |    4 ++++
 3 files changed, 53 insertions(+), 18 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 41e694b..b88dde9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,6 +1,14 @@
 -*- mode: m4 -*-
 AC_PREREQ(2.52)
 
+# The version of python used is determined by the executable pointed to by
+# the PYTHON environment variable.  For instance if your system installs
+# Python 3 as python3 to configure to compile pygobject under Python 3
+# you would do this:
+# $> PYTHON=python3 ./configure
+m4_define(python_min_ver, 2.5.2)
+m4_define(python3_min_ver, 3.1)
+
 dnl the pygobject version number
 m4_define(pygobject_major_version, 2)
 m4_define(pygobject_minor_version, 21)
@@ -77,7 +85,21 @@ AC_PROG_CC
 AM_PROG_CC_STDC
 AM_PROG_CC_C_O
 
-JD_PATH_PYTHON(2.5.2)
+# check that we have the minimum version of python necisary to build
+JD_PATH_PYTHON(python_min_ver)
+
+# check if we are building for python 3
+JD_PYTHON_CHECK_VERSION([$PYTHON], [3.0],
+			 build_py3k=true,
+			 build_py3k=false)
+
+# if building for python 3 make sure we have the minimum version supported
+if test $build_py3k = true ; then
+  AC_MSG_CHECKING([for $PYTHON >=] python3_min_ver)
+  JD_PYTHON_CHECK_VERSION([$PYTHON], python3_min_ver,
+			  [AC_MSG_RESULT(yes)],
+			  [AC_MSG_ERROR(too old)])
+fi
 
 JD_CHECK_PYTHON_HEADERS(,[AC_MSG_ERROR(could not find Python headers)])
 
@@ -189,7 +211,11 @@ PKG_CHECK_MODULES(GIO, gio-2.0 >= gio_required_version,
 	have_gio=true, have_gio=false)
 AC_SUBST(GIO_CFLAGS)
 AC_SUBST(GIO_LIBS)
-AM_CONDITIONAL(BUILD_GIO, $have_gio)
+
+# Do not build GIO if the python version >= 3.0
+# We use GI to access GIO in python 3
+AM_CONDITIONAL(BUILD_GIO, test $have_gio = true -a $build_py3k = false)
+
 if test -n "$export_dynamic"; then
   GIO_LIBS=`echo $GIO_LIBS | sed -e "s/$export_dynamic//"`
 fi
@@ -199,7 +225,7 @@ PKG_CHECK_MODULES(GIOUNIX, gio-unix-2.0 >= giounix_required_version,
 	have_giounix=true, have_giounix=false)
 AC_SUBST(GIOUNIX_CFLAGS)
 AC_SUBST(GIOUNIX_LIBS)
-AM_CONDITIONAL(BUILD_GIOUNIX, $have_giounix)
+AM_CONDITIONAL(BUILD_GIOUNIX, test $have_giounix = true -a $build_py3k = false)
 if test -n "$export_dynamic"; then
   GIOUNIX_LIBS=`echo $GIOUNIX_LIBS | sed -e "s/$export_dynamic//"`
 fi
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 0ca5bb5..42a2642 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -59,20 +59,8 @@ testhelper.la: $(testhelper_la_OBJECTS) $(testhelper_la_DEPENDENCIES)
 
 all: $(LTLIBRARIES:.la=.so)
 
-
-EXTRA_DIST = \
-	runtests.py \
-	testmodule.py \
-	test-floating.h \
-	test-thread.h \
-	test-unknown.h \
-	\
-	test_gcancellable.py \
-	test_gicon.py \
-	test_gio.py \
+TEST_FILES = \
 	test_gobject.py \
-	test_gresolver.py \
-	test_gsocket.py \
 	test_interface.py \
 	test_mainloop.py \
 	test_option.py \
@@ -82,20 +70,37 @@ EXTRA_DIST = \
 	test_subprocess.py \
 	test_thread.py
 
+if BUILD_GIO
+TEST_FILES += \
+	test_gio.py \
+	test_gresolver.py \
+	test_gsocket.py \
+	test_gicon.py \
+	test_gcancellable.py
+endif 
+
 if ENABLE_INTROSPECTION
-EXTRA_DIST += \
+TEST_FILES += \
 	test_everything.py \
 	test_gi.py \
 	test_overrides.py
 endif
 
+EXTRA_DIST = \
+	runtests.py \
+	testmodule.py \
+	test-floating.h \
+	test-thread.h \
+	test-unknown.h 
+
+EXTRA_DIST += $(TEST_FILES)
 
 clean-local:
 	rm -f $(LTLIBRARIES:.la=.so)
 
 
 check-local: $(LTLIBRARIES:.la=.so) Regress-1.0.typelib GIMarshallingTests-1.0.typelib
-	PYTHONPATH=$(top_builddir):$(top_builddir)/tests:$${PYTHONPATH:+:$$PYTHONPATH} LD_LIBRARY_PATH=$(builddir)/.libs:$$LD_LIBRARY_PATH GI_TYPELIB_PATH=$(builddir) $(EXEC_NAME) $(PYTHON) $(srcdir)/runtests.py
+	TEST_FILES="$(TEST_FILES)" PYTHONPATH=$(top_builddir):$(top_builddir)/tests:$${PYTHONPATH:+:$$PYTHONPATH} LD_LIBRARY_PATH=$(builddir)/.libs:$$LD_LIBRARY_PATH GI_TYPELIB_PATH=$(builddir) $(EXEC_NAME) $(PYTHON) $(srcdir)/runtests.py
 
 check.gdb:
 	EXEC_NAME="gdb --args" $(MAKE) check
diff --git a/tests/runtests.py b/tests/runtests.py
index eae684c..d99f0cc 100644
--- a/tests/runtests.py
+++ b/tests/runtests.py
@@ -9,6 +9,10 @@ import unittest
 # Load tests.
 if 'TEST_NAMES' in os.environ:
 	names = os.environ['TEST_NAMES'].split()
+elif 'TEST_FILES' in os.environ:
+	names = []
+	for filename in os.environ['TEST_FILES'].split():
+		names.append(filename[:-3])
 else:
 	names = []
 	for filename in glob.iglob("test_*.py"):



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