From e0891e8ecdcd66b3537095d5b26a846cf90af47d Mon Sep 17 00:00:00 2001 From: Jürgen Knödlseder Date: Wed, 22 Aug 2012 18:06:39 +0200 Subject: [PATCH] Introduce Python compatibility brackets. --- configure.ac | 13 ++++++++++++- pyext/setup.py.in | 10 +++++----- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/configure.ac b/configure.ac index 9800ad8..6ce6452 100644 --- a/configure.ac +++ b/configure.ac @@ -533,6 +533,17 @@ AM_PATH_PYTHON([2.2], [AC_MSG_WARN([Python >= 2.2 not found. Python >= 2.2 is required to build python binding. Python can be obtained from http://www.python.org])]) if test "x$has_python" = "xyes"; then + # Set opening and closing symbols to make setup.py compatible for versions 2 and 3 + if test ${PYTHON_VERSION} '<' 3; then + PYTHON_OPEN=" " + PYTHON_CLOSE="" + else + PYTHON_OPEN="(" + PYTHON_CLOSE=")" + fi + AC_SUBST(PYTHON_OPEN) + AC_SUBST(PYTHON_CLOSE) + # Do we have distutils? AC_MSG_CHECKING([for the distutils Python package]) ac_distutils_result=`$PYTHON -c "import distutils" 2>&1` @@ -558,7 +569,7 @@ if test "x$has_python" = "xyes"; then fi PYTHON_CPPFLAGS=$python_path CPPFLAGS="${CPPFLAGS} ${python_path}" - AC_SUBST([PYTHON_CPPFLAGS]) + AC_SUBST([PYTHON_CPPFLAGS]) # ... otherwise check for includes relative to exectuable (obsolete?) else diff --git a/pyext/setup.py.in b/pyext/setup.py.in index 0c43fee..aba9b56 100644 --- a/pyext/setup.py.in +++ b/pyext/setup.py.in @@ -29,7 +29,7 @@ import sys is_unit_test = False if (len(sys.argv) >= 3): if (sys.argv[2] == '--inplace'): - print "This build is for unit testing." + print@PYTHON_OPEN@"This build is for unit testing."@PYTHON_CLOSE@ is_unit_test = True # Darwin MacPorts kluge: Remove -L/opt/local/lib path from LDSHARED as this @@ -50,7 +50,7 @@ if sys.platform.lower().startswith("darwin"): else: ldshared_rm += option + ' ' if (len(ldshared_rm) > 0): - print 'Removed following option(s) from LDSHARED: '+ldshared_rm + print@PYTHON_OPEN@"Removed following option(s) from LDSHARED: "+ldshared_rm@PYTHON_CLOSE@ # Set LDSHARED cvars['LDSHARED'] = ldshared_new @@ -68,7 +68,7 @@ if sys.platform.lower().startswith("darwin") and is_unit_test: # an already existing link. try: os.remove('../src/.libs/libctools_python.a') - print 'Removed ../src/.libs/libctools_python.a' + print@PYTHON_OPEN@"Removed ../src/.libs/libctools_python.a"@PYTHON_CLOSE@ except: pass @@ -76,10 +76,10 @@ if sys.platform.lower().startswith("darwin") and is_unit_test: # symbolic link try: os.symlink('libctools.a', '../src/.libs/libctools_python.a') - print 'Created ../src/.libs/libctools_python.a' + print@PYTHON_OPEN@"Created ../src/.libs/libctools_python.a"@PYTHON_CLOSE@ libcta='ctools_python' except: - print 'WARNING: Failed to create symbolic link to static library. Link dynamically.' + print@PYTHON_OPEN@"WARNING: Failed to create symbolic link to static library. Link dynamically."@PYTHON_CLOSE@ # Set default include directories and data files include_dirs = ['@prefix@/include/gammalib'] -- libgit2 0.21.4