Blob Blame History Raw
From 398636c8bd8ac0829ca1ef6000821026f2e3c003 Mon Sep 17 00:00:00 2001
From: Aravinda VK <avishwan@redhat.com>
Date: Wed, 24 Aug 2016 14:02:08 +0530
Subject: [PATCH 40/86] packaging/eventsapi: Make Python site-packages variable global

Python site-packages path is assigned when glupy is enabled.
Eventsapi will not work as expected if glupy is disabled using
./configure --disable-glupy.

With this patch, all the Python variables are moved out of glupy
and used inside it.

systemd services will fail if we import gluster.cliutils python library
which is installed in /usr/local/lib/python.2.7/site-packages or some
other location. With this patch, Environment variable is added in
systemd service file.

> Reviewed-on: http://review.gluster.org/15305
> Smoke: Gluster Build System <jenkins@build.gluster.org>
> Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com>
> Tested-by: Atin Mukherjee <amukherj@redhat.com>
> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
> CentOS-regression: Gluster Build System <jenkins@build.gluster.org>

BUG: 1351589
Change-Id: I9416240f03889e3bbcb4cd375e27c784fa9ca277
Signed-off-by: Aravinda VK <avishwan@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/84744
Reviewed-by: Milind Changire <mchangir@redhat.com>
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
---
 configure.ac                             |   91 +++++++++++++++++------------
 extras/systemd/glustereventsd.service.in |    1 +
 2 files changed, 54 insertions(+), 38 deletions(-)

diff --git a/configure.ac b/configure.ac
index e18309d..d77f41f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -502,6 +502,51 @@ if test "x${have_umount2}" = "xyes"; then
    AC_DEFINE(HAVE_UMOUNT2, 1, [define if found umount2])
 fi
 
+dnl Check Python Availability
+have_python=no
+AM_PATH_PYTHON(,, [:])
+if test "$PYTHON" != ":"; then
+   have_python=yes
+fi
+
+dnl Check if version matches that we require
+PYTHONDEV_CPPFLAGS=
+PYTHONDEV_CPPFLAGS=
+BUILD_PYTHON_SITE_PACKAGES=
+BUILD_PYTHON_INC=
+BUILD_PYTHON_LIB=
+have_python2=no
+have_Python_h=no
+
+if echo $PYTHON_VERSION | grep ^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)
+
+   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`"
+
+   BUILD_PYTHON_SITE_PACKAGES=`$PYTHON -c 'from distutils.sysconfig import get_python_lib; print(get_python_lib(prefix="${exec_prefix}"))'`
+   BUILD_PYTHON_INC=`$PYTHON -c "from distutils import sysconfig; print sysconfig.get_python_inc()"`
+   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
+
+AC_SUBST(PYTHONDEV_CPPFLAGS)
+AC_SUBST(PYTHONDEV_LDFLAGS)
+AC_SUBST(BUILD_PYTHON_SITE_PACKAGES)
+AC_SUBST(BUILD_PYTHON_INC)
+AC_SUBST(BUILD_PYTHON_LIB)
+
+
 # FUSE section
 AC_ARG_ENABLE([fuse-client],
               AC_HELP_STRING([--disable-fuse-client],
@@ -713,17 +758,11 @@ AC_ARG_ENABLE([events],
 BUILD_EVENTS=no
 EVENTS_ENABLED=0
 EVENTS_SUBDIR=
-have_python2=no
 if test "x$enable_events" != "xno"; then
   EVENTS_SUBDIR=events
   EVENTS_ENABLED=1
 
   BUILD_EVENTS="yes"
-  AM_PATH_PYTHON()
-  dnl Check if version matches that we require
-  if echo $PYTHON_VERSION | grep ^2; then
-     have_python2=yes
-  fi
 
   if test "x$have_python2" = "xno"; then
      if test "x$enable_events" = "xyes"; then
@@ -1125,11 +1164,19 @@ sysconfdirtemp="${sysconfdir}"
 eval sysconfdirtemp=\"${sysconfdirtemp}\"
 SYSCONF_DIR=${sysconfdirtemp}
 
+# Eval two times to expand fully. First eval replaces $exec_prefix into $prefix
+# Second eval will expand $prefix
+build_python_site_packages_temp="${BUILD_PYTHON_SITE_PACKAGES}"
+eval build_python_site_packages_temp=\"${build_python_site_packages_temp}\"
+eval build_python_site_packages_temp=\"${build_python_site_packages_temp}\"
+BUILD_PYTHON_SITE_PACKAGES_EXPANDED=${build_python_site_packages_temp}
+
 prefix=$prefix_temp
 exec_prefix=$exec_prefix_temp
 
 AC_SUBST(SBIN_DIR)
 AC_SUBST(SYSCONF_DIR)
+AC_SUBST(BUILD_PYTHON_SITE_PACKAGES_EXPANDED)
 
 # lazy umount emulation
 UMOUNTD_SUBDIR=""
@@ -1184,42 +1231,15 @@ fi
 
 dnl glupy section
 BUILD_GLUPY=no
-have_python2=no
-have_Python_h=no
 
 AC_ARG_ENABLE([glupy], AS_HELP_STRING([--enable-glupy], [build glupy]))
 if test "x$enable_glupy" != "xno"; then enable_glupy=yes; fi
 
 if test "x$enable_glupy" = "xyes"; then
-    dnl Check if python exists
-    AM_PATH_PYTHON()
-    dnl Check if version matches that we require
-    if echo $PYTHON_VERSION | grep ^2; then
-        have_python2=yes
-    fi
-
-    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'`
-
-    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=`$PYTHON -c 'from distutils.sysconfig import get_python_lib; print(get_python_lib(prefix="${exec_prefix}"))'`
-    BUILD_PYTHON_INC=`$PYTHON -c "from distutils import sysconfig; print sysconfig.get_python_inc()"`
-    BUILD_PYTHON_LIB=python$PYTHON_VERSION
-
     GLUPY_SUBDIR=glupy
     GLUPY_SUBDIR_MAKEFILE=xlators/features/glupy/Makefile
     GLUPY_SUBDIR_SRC_MAKEFILE=xlators/features/glupy/src/Makefile
 
-    dnl Now check for python header using the include path obtained above
-    AC_CHECK_HEADERS([${BUILD_PYTHON_INC}/Python.h],[have_Python_h=yes],[])
-
     if test "x$have_python2" = "xyes" -a "x$have_Python_h" = "xyes"; then
         case $host_os in
             darwin*)
@@ -1240,11 +1260,6 @@ if test "x$enable_glupy" = "xyes"; then
 
         echo "building glupy with -isystem $BUILD_PYTHON_INC -l $BUILD_PYTHON_LIB"
 
-        AC_SUBST(PYTHONDEV_CPPFLAGS)
-        AC_SUBST(PYTHONDEV_LDFLAGS)
-        AC_SUBST(BUILD_PYTHON_SITE_PACKAGES)
-        AC_SUBST(BUILD_PYTHON_INC)
-        AC_SUBST(BUILD_PYTHON_LIB)
         AC_SUBST(GLUPY_SUBDIR)
         AC_SUBST(GLUPY_SUBDIR_MAKEFILE)
         AC_SUBST(GLUPY_SUBDIR_SRC_MAKEFILE)
diff --git a/extras/systemd/glustereventsd.service.in b/extras/systemd/glustereventsd.service.in
index 2be3f25..75cca16 100644
--- a/extras/systemd/glustereventsd.service.in
+++ b/extras/systemd/glustereventsd.service.in
@@ -3,6 +3,7 @@ Description=Gluster Events Notifier
 After=syslog.target network.target
 
 [Service]
+Environment=PYTHONPATH=@BUILD_PYTHON_SITE_PACKAGES_EXPANDED@:$PYTHONPATH
 Type=simple
 ExecStart=@SBIN_DIR@/glustereventsd
 ExecReload=/bin/kill -SIGUSR2 $MAINPID
-- 
1.7.1