From 33287b163aa7d5b066be157d8c67c4f7bca2d618 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Thu, 16 Oct 2014 16:36:10 -0400 Subject: [PATCH] Detect Python packages directory on configure MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The Python interpreter on Debian is configurated to use ...lib/python.../dist-packages instead of .../lib/python.../site-packages to look for extra modules. python_modules.m4 performs a runtime python check of the sys.path variable to check wether the selected interpreter is configurated to use site-packages vs dist-packages. Signed-off-by: Jérémie Galarneau --- configure.ac | 5 +++++ m4/python_modules.m4 | 23 +++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 m4/python_modules.m4 diff --git a/configure.ac b/configure.ac index 632fe39c..ab882abb 100644 --- a/configure.ac +++ b/configure.ac @@ -122,6 +122,11 @@ if test "x${enable_python:-yes}" = xyes; then AX_PKG_SWIG($swig_version, [], [ AC_MSG_ERROR([SWIG $swig_version or newer is needed]) ]) AM_PATH_PYTHON + AM_PATH_PYTHON_MODULES([PYTHON]) + # pythondir is the path where extra modules are to be installed + pythondir=$PYTHON_PREFIX/$PYTHON_MODULES_PATH + # pyexecdir is the path that contains shared objects used by the extra modules + pyexecdir=$PYTHON_EXEC_PREFIX/$PYTHON_MODULES_PATH AC_ARG_VAR([PYTHON_INCLUDE], [Include flags for python, bypassing python-config]) AC_ARG_VAR([PYTHON_CONFIG], [Path to python-config]) AS_IF([test -z "$PYTHON_INCLUDE"], [ diff --git a/m4/python_modules.m4 b/m4/python_modules.m4 new file mode 100644 index 00000000..132c4c28 --- /dev/null +++ b/m4/python_modules.m4 @@ -0,0 +1,23 @@ +# python_modules.m4 -- Get the Python modules install path +# +# Copyright (C) 2014 - Jérémie Galarneau +# +# This file is free software; the Free Software Foundation gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. + +# While extra Python modules are generaly installed in the Python +# interpreter's "site-packages" directory, Debian prefers using the +# "dist-packages" nomenclature. This macro uses the interpreter +# designated by the PYTHON variable to check the interpreter's PATH +# and sets the PYTHON_MODULES_PATH by taking the prefix into account. + +# AM_PATH_PYTHON_MODULES(PYTHON) +# --------------------------------------------------------------------------- +AC_DEFUN([AM_PATH_PYTHON_MODULES], + [prog="import sys +for path in sys.path: + if path.endswith(\"-packages\"): + print(path[[path.find(\"/lib\"):]]) + break" + PYTHON_MODULES_PATH=`${$1} -c "$prog"`]) -- 2.34.1