diff options
author | Kaleb S. KEITHLEY <kkeithle@redhat.com> | 2018-03-28 10:14:39 -0400 |
---|---|---|
committer | Shyamsundar Ranganathan <srangana@redhat.com> | 2018-04-12 11:04:27 +0000 |
commit | 29024cfdd5f131c7e3085cbddf9bd1cf60359960 (patch) | |
tree | dde994fdd25f742ac335ed8e20c1823b0a843694 /configure.ac | |
parent | c4251edec654b4e0127577e004923d9729bc323d (diff) |
core/build/various: python3 compat, prepare for python2 -> python3
Note 1) we're not supposed to be using #!/usr/bin/env python, see
https://fedoraproject.org/wiki/Packaging:Guidelines?rd=Packaging/Guidelines#Shebang_lines
Note 2) we're also not supposed to be using "!/usr/bin/python,
see https://fedoraproject.org/wiki/Changes/Avoid_usr_bin_python_in_RPM_Build#Quick_Opt-Out
The previous patch (https://review.gluster.org/19767) tried to do too
much in one patch, so it was abandoned.
This patch does two things:
1) minor cleanup of configure(.ac) to explicitly use python2
2) change all the shebang lines to #!/usr/bin/python2 and add them
where they were missing based on warnings emitted during rpmbuild.
In a follow-up patch python2 will eventually be changed to python3.
Before that python2-isms (e.g. print, string.join(), etc.) need to be
converted to python3. Some of those can be rewritten in version agnostic
python. E.g. print statements become print() with "from __future_ import
print_function". The python 2to3 utility will be used for some of those.
Also Aravinda has given guidance in the comments to the first patch for
changes.
updates: #411
Change-Id: I471730962b2526022115a1fc33629fb078b74338
Signed-off-by: Kaleb S. KEITHLEY <kkeithle@redhat.com>
Diffstat (limited to 'configure.ac')
-rw-r--r-- | configure.ac | 91 |
1 files changed, 46 insertions, 45 deletions
diff --git a/configure.ac b/configure.ac index 81eca4976a1..190dc8f73fc 100644 --- a/configure.ac +++ b/configure.ac @@ -597,41 +597,46 @@ fi dnl Check Python Availability have_python=no -AM_PATH_PYTHON(,, [:]) -if test "$PYTHON" != ":"; then +case $host_os in + freebsd*) + PYTHON=/usr/local/bin/python2 + ;; + *) + PYTHON=/usr/bin/python2 + ;; +esac +AM_PATH_PYTHON([2.6],,[:]) +if test "x${PYTHON}" != "x:"; then have_python=yes fi +echo "python = ${PYTHON}" + dnl Check if version matches that we require PYTHONDEV_CPPFLAGS= PYTHONDEV_LDFLAGS= BUILD_PYTHON_SITE_PACKAGES= BUILD_PYTHON_INC= BUILD_PYTHON_LIB= -have_python2=no -have_Python_h=no +have_Python_h="no" -if echo $PYTHON_VERSION | grep -q ^2; then - have_python2=yes +dnl Use pkg-config to get runtime search patch missing from ${PYTHON}-config +dnl Just do "true" on failure so that configure does not bail out +PKG_CHECK_MODULES([PYTHON], "python-${PYTHON_VERSION}",,true) - dnl Use pkg-config to get runtime search patch missing from ${PYTHON}-config - dnl Just do "true" on failure so that configure does not bail out - PKG_CHECK_MODULES([PYTHON], "python-$PYTHON_VERSION",,true) +PYTHONDEV_CPPFLAGS="`${PYTHON}-config --cflags`" +dnl Edit out the flags that are not required or are conflicting +PYTHONDEV_CPPFLAGS=`echo ${PYTHONDEV_CPPFLAGS} | sed -e 's/-Wp,-D_FORTIFY_SOURCE=[[0-9]]//g'` - PYTHONDEV_CPPFLAGS="`${PYTHON}-config --cflags`" - dnl Edit out the flags that are not required or are conflicting - PYTHONDEV_CPPFLAGS=`echo ${PYTHONDEV_CPPFLAGS} | sed -e 's/-Wp,-D_FORTIFY_SOURCE=[[0-9]]//g'` +dnl Find python libs at user configured libdir and also "lib" under prefix +PYTHONDEV_LDFLAGS="${PYTHON_LIBS} -L`${PYTHON}-config --prefix`/lib -L`${PYTHON}-config --prefix`/$libdir `${PYTHON}-config --ldflags`" - dnl Find python libs at user configured libdir and also "lib" under prefix - PYTHONDEV_LDFLAGS="${PYTHON_LIBS} -L`${PYTHON}-config --prefix`/lib -L`${PYTHON}-config --prefix`/$libdir `${PYTHON}-config --ldflags`" +BUILD_PYTHON_SITE_PACKAGES=${pythondir} +BUILD_PYTHON_INC=`${PYTHON} -c "import sys; from distutils import sysconfig; sys.stdout.write(sysconfig.get_python_inc())" 2>/dev/null` +BUILD_PYTHON_LIB=python${PYTHON_VERSION} - BUILD_PYTHON_SITE_PACKAGES=${pythondir} - BUILD_PYTHON_INC=`$PYTHON -c "import sys; from distutils import sysconfig; sys.stdout.write(sysconfig.get_python_inc())" 2>/dev/null` - BUILD_PYTHON_LIB=python$PYTHON_VERSION - - dnl Now check for python header using the include path obtained above - AC_CHECK_HEADERS([${BUILD_PYTHON_INC}/Python.h],[have_Python_h=yes],[]) -fi +dnl Now check for python header using the include path obtained above +AC_CHECK_HEADERS([${BUILD_PYTHON_INC}/Python.h],[have_Python_h=yes],[]) AC_SUBST(PYTHONDEV_CPPFLAGS) AC_SUBST(PYTHONDEV_LDFLAGS) @@ -816,25 +821,20 @@ case $host_os in ;; esac SYNCDAEMON_COMPILE=0 -if test "x${with_server}" = "xyes" -a "x$enable_georeplication" != "xno"; then - SYNCDAEMON_SUBDIR=geo-replication - SYNCDAEMON_COMPILE=1 - - BUILD_SYNCDAEMON="yes" - AM_PATH_PYTHON([2.4]) - echo -n "checking if python is python 2.x... " - if echo $PYTHON_VERSION | grep ^2; then - : - else - echo no - AC_MSG_ERROR([only python 2.x is supported]) - fi - echo -n "checking if python has ctypes support... " - if "$PYTHON" -c 'import ctypes' 2>/dev/null; then - echo yes +if test "x${with_server}" = "xyes" -a "x${enable_georeplication}" != "xno"; then + if test "x${have_python}" = "xno" ; then + AC_MSG_ERROR([only python 2 and 3 are supported]) else - echo no - AC_MSG_ERROR([python does not have ctypes support]) + SYNCDAEMON_SUBDIR=geo-replication + SYNCDAEMON_COMPILE=1 + + BUILD_SYNCDAEMON="yes" + AC_MSG_CHECKING([if python has ctypes support...]) + if "${PYTHON}" -c 'import ctypes' 2>/dev/null; then + AC_MSG_RESULT("yes") + else + AC_MSG_ERROR([python does not have ctypes support]) + fi fi fi AC_SUBST(SYNCDAEMON_COMPILE) @@ -862,11 +862,11 @@ if test "x$enable_events" != "xno"; then BUILD_EVENTS="yes" - if test "x$have_python2" = "xno"; then - if test "x$enable_events" = "xyes"; then - AC_MSG_ERROR([python 2.x packages required. exiting..]) + if test "x${have_python}" = "xno"; then + if test "x${enable_events}" = "xyes"; then + AC_MSG_ERROR([python 2 or 3 required. exiting.]) fi - AC_MSG_WARN([python 2.x not found, disabling events]) + AC_MSG_WARN([python not found, disabling events]) EVENTS_SUBDIR= EVENTS_ENABLED=0 BUILD_EVENTS="no" @@ -876,7 +876,7 @@ if test "x$enable_events" != "xno"; then fi AC_SUBST(EVENTS_ENABLED) AC_SUBST(EVENTS_SUBDIR) -AM_CONDITIONAL([BUILD_EVENTS], [test x$BUILD_EVENTS = xyes]) +AM_CONDITIONAL([BUILD_EVENTS], [test "x${BUILD_EVENTS}" = "xyes"]) # end Events section # CDC xlator - check if libz is present if so enable HAVE_LIB_Z @@ -1409,7 +1409,7 @@ if test "x$enable_glupy" = "xyes"; then GLUPY_SUBDIR_MAKEFILE=xlators/features/glupy/Makefile GLUPY_SUBDIR_SRC_MAKEFILE=xlators/features/glupy/src/Makefile - if test "x$have_python2" = "xyes" -a "x$have_Python_h" = "xyes"; then + if test "x${have_python}" = "xyes" -a "x${have_Python_h}" = "xyes"; then case $host_os in darwin*) BUILD_GLUPY=no @@ -1698,4 +1698,5 @@ echo "Server components : $with_server" echo "Legacy gNFS server : $BUILD_GNFS" echo "IPV6 default : $with_ipv6_default" echo "Use TIRPC : $with_libtirpc" +echo "With Python : ${PYTHON_VERSION}" echo |