Improve determining an appropriate python install prefix.

This commit is contained in:
tgoff0 2015-02-19 02:00:11 +00:00
parent 59c35e8927
commit 99ab22c78c
5 changed files with 36 additions and 6 deletions

View file

@ -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

View file

@ -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:

View file

@ -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:

View file

@ -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

24
python-prefix.py Executable file
View file

@ -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 <prefix>\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())