diff --git a/configure.ac b/configure.ac index 0bc34aee..cf26bf72 100644 --- a/configure.ac +++ b/configure.ac @@ -236,6 +236,11 @@ if test "x$want_python" = "xyes"; then AC_SUBST(libev_CFLAGS) AC_SUBST(libev_LIBS, [-lev]), AC_MSG_ERROR([Python bindings require libev (try installing your 'libev-devel' or 'libev-dev' package)]))) + AC_SUBST(pyprefix, `./python-prefix.py ${PYTHON_PREFIX}`) + if test "${pyprefix}" != "${PYTHON_PREFIX}"; then + pythondir=`echo ${pythondir} | sed -e 's,[$][{]prefix[}],${pyprefix},g'` + pyexecdir=`echo ${pyexecdir} | sed -e 's,[$][{]exec_prefix[}],${pyprefix},g'` + fi else # Namespace support requires Python support want_linux_netns=no @@ -342,6 +347,7 @@ ${PACKAGE_STRING} Configuration: GUI config: ${CORE_GUI_CONF_DIR} Daemon path: ${SBINDIR} Daemon config: ${CORE_CONF_DIR} + Python install prefix: ${pyprefix} Python modules: ${pythondir} Logs: ${CORE_STATE_DIR}/log diff --git a/daemon/Makefile.am b/daemon/Makefile.am index 34449264..6a435a3f 100644 --- a/daemon/Makefile.am +++ b/daemon/Makefile.am @@ -18,7 +18,7 @@ build: # Python package install install-exec-hook: - CORE_CONF_DIR=${DESTDIR}/${CORE_CONF_DIR} $(PYTHON) setup.py install --prefix=${DESTDIR}/${prefix} --install-purelib=${DESTDIR}/${pythondir} --install-platlib=${DESTDIR}/${pyexecdir} --no-compile + CORE_CONF_DIR=${DESTDIR}/${CORE_CONF_DIR} $(PYTHON) setup.py install --prefix=${DESTDIR}/${pyprefix} --install-purelib=${DESTDIR}/${pythondir} --install-platlib=${DESTDIR}/${pyexecdir} --no-compile # Python package uninstall uninstall-hook: diff --git a/daemon/ns3/Makefile.am b/daemon/ns3/Makefile.am index fdf56cba..8cc1a031 100644 --- a/daemon/ns3/Makefile.am +++ b/daemon/ns3/Makefile.am @@ -14,7 +14,7 @@ build: # Python package install install-exec-hook: - CORE_CONF_DIR=${DESTDIR}/${CORE_CONF_DIR} $(PYTHON) setup.py install --prefix=${DESTDIR}/${prefix} --install-purelib=${DESTDIR}/${pythondir} --install-platlib=${DESTDIR}/${pyexecdir} --no-compile + CORE_CONF_DIR=${DESTDIR}/${CORE_CONF_DIR} $(PYTHON) setup.py install --prefix=${DESTDIR}/${pyprefix} --install-purelib=${DESTDIR}/${pythondir} --install-platlib=${DESTDIR}/${pyexecdir} --no-compile # Python package uninstall uninstall-hook: diff --git a/daemon/src/Makefile.am b/daemon/src/Makefile.am index 2ce9bb9c..93570150 100644 --- a/daemon/src/Makefile.am +++ b/daemon/src/Makefile.am @@ -38,7 +38,7 @@ install: install-exec-hook # Python libraries install install-exec-hook: - SBINDIR=${DESTDIR}/@SBINDIR@ $(PYTHON) setup.py install --prefix=${DESTDIR}/${prefix} --install-purelib=${DESTDIR}/${pythondir} --install-platlib=${DESTDIR}/${pyexecdir} --no-compile + SBINDIR=${DESTDIR}/@SBINDIR@ $(PYTHON) setup.py install --prefix=${DESTDIR}/${pyprefix} --install-purelib=${DESTDIR}/${pythondir} --install-platlib=${DESTDIR}/${pyexecdir} --no-compile #python setup.py install --prefix=${DESTDIR}${PYTHON_PREFIX} # Python libraries uninstall @@ -46,9 +46,9 @@ uninstall-hook: rm -f ${sbindir}/vnoded rm -f ${sbindir}/vcmd rm -f ${sbindir}/netns - rm -f ${pythondir}/netns-*.egg-info - rm -f ${pythondir}/netns.so - rm -f ${pythondir}/vcmd.so + rm -f ${pyexecdir}/core_python_netns-1.0-py${PYTHON_VERSION}.egg-info + rm -f ${pyexecdir}/netns.so + rm -f ${pyexecdir}/vcmd.so # Python libraries cleanup clean-local: clean-local-check diff --git a/python-prefix.py b/python-prefix.py new file mode 100755 index 00000000..55379561 --- /dev/null +++ b/python-prefix.py @@ -0,0 +1,24 @@ +#!/usr/bin/env python + +import sys +import os.path +import site + +def main(): + if len(sys.argv) != 2: + msg = 'usage: %s \n' % os.path.basename(sys.argv[0]) + sys.stderr.write(msg) + return 1 + python_prefix = sys.argv[1] + prefix = None + for p in sys.path: + if python_prefix in p: + prefix = python_prefix + break + if not prefix: + prefix = site.PREFIXES[-1] + print prefix + return 0 + +if __name__ == '__main__': + sys.exit(main())