On 2021-3-3 10:54 , Karl Berry wrote:
I wonder if it might also make sense to offer a configure option to set
PYTHON_PREFIX?
I think that would be great (--pythondir, --pythonexecdir or some
such). Would you mind looking into that? I've never played around with
the options Automake adds and have unfortunately limited time to
research the code. But I will eventually if needed.
OK, here's a patch to add --with-python_prefix and
--with-python_exec_prefix options. It applies on top of my previous patch.
Note that the paths given to these options aren't edited to use the
${prefix} and ${exec_prefix} variables when they are subdirs thereof,
since I figure if you set a specific value with these options you really
mean it. Note also that if --with-python_prefix is given but
--with-python_exec_prefix is not, PYTHON_EXEC_PREFIX takes the value
that was given to --with-python_prefix. I think this is more convenient
on the whole, since setting a custom PYTHON_PREFIX but wanting to keep
the automatically determined value of PYTHON_EXEC_PREFIX seems like it
would be a pretty rare scenario.
- Josh
diff --git a/m4/python.m4 b/m4/python.m4
index 294095a3e..54adca3bc 100644
--- a/m4/python.m4
+++ b/m4/python.m4
@@ -100,18 +100,28 @@ AC_DEFUN([AM_PATH_PYTHON],
dnl values of PYTHON_PREFIX and PYTHON_EXEC_PREFIX. These are made
dnl distinct variables so they can be overridden if need be. However,
dnl general consensus is that you shouldn't need this ability.
+ dnl Also allow directly setting the prefixes via configure args.
- AC_CACHE_CHECK([for $am_display_PYTHON prefix], [am_cv_python_prefix],
- [am_cv_python_prefix=`$PYTHON -c "import sys;
sys.stdout.write(sys.prefix)"`])
-
- dnl If sys.prefix is a subdir of $prefix, replace the literal value of
$prefix
- dnl with a variable reference so it can be overridden.
if test "x$prefix" = xNONE
then
am__usable_prefix=$ac_default_prefix
else
am__usable_prefix=$prefix
fi
+
+ AC_ARG_WITH([python_prefix],
+ [AS_HELP_STRING([--with-python_prefix],
+ [override the default PYTHON_PREFIX])],
+ [ am_python_prefix_subst="$withval"
+ am_cv_python_prefix="$withval"
+ AC_MSG_CHECKING([for $am_display_PYTHON prefix])
+ AC_MSG_RESULT([$am_cv_python_prefix])],
+ [
+ AC_CACHE_CHECK([for $am_display_PYTHON prefix], [am_cv_python_prefix],
+ [am_cv_python_prefix=`$PYTHON -c "import sys;
sys.stdout.write(sys.prefix)"`])
+
+ dnl If sys.prefix is a subdir of $prefix, replace the literal value of
$prefix
+ dnl with a variable reference so it can be overridden.
case $am_cv_python_prefix in
$am__usable_prefix*)
am__strip_prefix=`echo "$am__usable_prefix" | sed 's|.|.|g'`
@@ -121,8 +131,23 @@ AC_DEFUN([AM_PATH_PYTHON],
am_python_prefix_subst=$am_cv_python_prefix
;;
esac
+ ])
AC_SUBST([PYTHON_PREFIX], [$am_python_prefix_subst])
+ AC_ARG_WITH([python_exec_prefix],
+ [AS_HELP_STRING([--with-python_exec_prefix],
+ [override the default PYTHON_EXEC_PREFIX])],
+ [ am_python_exec_prefix_subst="$withval"
+ am_cv_python_exec_prefix="$withval"
+ AC_MSG_CHECKING([for $am_display_PYTHON exec_prefix])
+ AC_MSG_RESULT([$am_cv_python_exec_prefix])],
+ [
+ dnl --with-python_prefix was given - use its value for python_exec_prefix too
+ AS_IF([test -n "$with_python_prefix"],
[am_python_exec_prefix_subst="$with_python_prefix"
+ am_cv_python_exec_prefix="$with_python_prefix"
+ AC_MSG_CHECKING([for $am_display_PYTHON exec_prefix])
+ AC_MSG_RESULT([$am_cv_python_exec_prefix])],
+ [
AC_CACHE_CHECK([for $am_display_PYTHON exec_prefix],
[am_cv_python_exec_prefix],
[am_cv_python_exec_prefix=`$PYTHON -c "import sys;
sys.stdout.write(sys.exec_prefix)"`])
dnl If sys.exec_prefix is a subdir of $exec_prefix, replace the
@@ -143,6 +168,7 @@ AC_DEFUN([AM_PATH_PYTHON],
am_python_exec_prefix_subst=$am_cv_python_exec_prefix
;;
esac
+ ])])
AC_SUBST([PYTHON_EXEC_PREFIX], [$am_python_exec_prefix_subst])
dnl At times (like when building shared libraries) you may want