diff options
author | Stefano Lattarini <stefano.lattarini@gmail.com> | 2012-11-22 12:03:07 +0100 |
---|---|---|
committer | Stefano Lattarini <stefano.lattarini@gmail.com> | 2012-11-24 12:28:20 +0100 |
commit | 1f113f6bc81edabbbda7e14d58b10ac02d7a1137 (patch) | |
tree | 9366bb848c5b9104284a9a1f901f622e84319a22 /m4 | |
parent | 411ada9995cb7d66ea2ede4334172fb9be39ae94 (diff) | |
download | automake-1f113f6bc81edabbbda7e14d58b10ac02d7a1137.tar.gz |
python: make installed modules find by default on Debian and Ubuntu
This change fixes automake bug#10227.
The code used to get the python package directory was wrong for Python 3,
at least on Debian and Ubuntu distributions. In the case the installation
was using the default prefix "/usr/local", python modules were incorrectly
installed in the directory
/usr/local/lib/python3/dist-packages
(which is *not* searched by default), rather than in a directory like
/usr/local/lib/python3.x/dist-packages
which is searched by default.
* m4/python.m4 (AM_PATH_PYTHON): Try to use the 'sysconfig' module if
possible, for better interactions with python 3.x.
Helped-by: Reuben Thomas <rrt@sc3d.org>
Helped-by: Roumen Petrov <bugtrack@roumenpetrov.info>
Signed-off-by: Stefano Lattarini <stefano.lattarini@gmail.com>
Diffstat (limited to 'm4')
-rw-r--r-- | m4/python.m4 | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/m4/python.m4 b/m4/python.m4 index 50213a9c9..5d9d0579e 100644 --- a/m4/python.m4 +++ b/m4/python.m4 @@ -106,6 +106,25 @@ AC_DEFUN([AM_PATH_PYTHON], [am_cv_python_platform=`$PYTHON -c "import sys; sys.stdout.write(sys.platform)"`]) AC_SUBST([PYTHON_PLATFORM], [$am_cv_python_platform]) + # Just factor out some code duplication. + am_python_setup_sysconfig="\ +import sys +# Prefer sysconfig over distutils.sysconfig, for better compatibility +# with python 3.x. See automake bug#10227. +try: + import sysconfig +except ImportError: + can_use_sysconfig = 0 +else: + can_use_sysconfig = 1 +# Can't use sysconfig in CPython 2.7, since it's broken in virtualenvs: +# <https://github.com/pypa/virtualenv/issues/118> +try: + from platform import python_implementation + if python_implementation() == 'CPython' and sys.version[[:3]] == '2.7': + can_use_sysconfig = 0 +except ImportError: + pass" dnl Set up 4 directories: @@ -122,7 +141,14 @@ AC_DEFUN([AM_PATH_PYTHON], else am_py_prefix=$prefix fi - am_cv_python_pythondir=`$PYTHON -c "import sys; from distutils import sysconfig; sys.stdout.write(sysconfig.get_python_lib(0,0,prefix='$am_py_prefix'))" 2>/dev/null` + am_cv_python_pythondir=`$PYTHON -c " +$am_python_setup_sysconfig +if can_use_sysconfig: + sitedir = sysconfig.get_path('purelib', vars={'base':'$am_py_prefix'}) +else: + from distutils import sysconfig + sitedir = sysconfig.get_python_lib(0, 0, prefix='$am_py_prefix') +sys.stdout.write(sitedir)"` case $am_cv_python_pythondir in $am_py_prefix*) am__strip_prefix=`echo "$am_py_prefix" | sed 's|.|.|g'` @@ -157,7 +183,14 @@ AC_DEFUN([AM_PATH_PYTHON], else am_py_exec_prefix=$exec_prefix fi - am_cv_python_pyexecdir=`$PYTHON -c "import sys; from distutils import sysconfig; sys.stdout.write(sysconfig.get_python_lib(1,0,prefix='$am_py_exec_prefix'))" 2>/dev/null` + am_cv_python_pyexecdir=`$PYTHON -c " +$am_python_setup_sysconfig +if can_use_sysconfig: + sitedir = sysconfig.get_path('platlib', vars={'platbase':'$am_py_prefix'}) +else: + from distutils import sysconfig + sitedir = sysconfig.get_python_lib(1, 0, prefix='$am_py_prefix') +sys.stdout.write(sitedir)"` case $am_cv_python_pyexecdir in $am_py_exec_prefix*) am__strip_prefix=`echo "$am_py_exec_prefix" | sed 's|.|.|g'` |