4

I am using automake's macro AM_PATH_PYTHON to find the pythondir variable.

Till now I have been calling it without arguments which defaults to python 2.7 on Ubuntu. Now I also want to build it for python3.x (3.3 specifically).

Is there a way where I can call AM_PATH_PYTHON([3]) to get python3.3, store all the generated variables using AC_SUBST in a python3 specific variable and then call AM_PATH_PYTHON([2]) for python2.

I am doing this

AM_PATH_PYTHON([3])
AC_SUBST(PYTHON3,$PYTHON)
AC_SUBST(HAVE_PYTHON3,$HAVE_PYTHON)
AC_SUBST(PYTHON3_VERSION,$PYTHON_VERSION)
AC_SUBST(PYTHON3_PREFIX,$PYTHON_PREFIX)
AC_SUBST(PYTHON3_EXEC_PREFIX,$PYTHON_EXEC_PREFIX)
AC_SUBST(PYTHON3_PLATFORM,$PYTHON_PLATFORM)
AC_SUBST(python3dir,$pythondir)
AC_SUBST(pkgpython3dir,$pkgpythondir)
AC_SUBST(py3execdir,$pyexecdir)
AC_SUBST(pkgpy3execdir,$pkgpyexecdir)

unset PYTHON
unset HAVE_PYTHON
unset PYTHON_VERSION
unset PYTHON_PREFIX
unset PYTHON_EXEC_PREFIX
unset PYTHON_PLATFORM
unset pythondir
unset pkgpythondir
unset pyexecdir
unset pkgpyexecdir
AM_PATH_PYTHON([2])

Even after doing all these the second AM_PATH_PYTHON is not rewriting the variables. I know these are macros, but there should be a way to do this. The Makefile shows

py3execdir = ${exec_prefix}/lib/python3.3/site-packages
pyexecdir = ${exec_prefix}/lib/python3.3/site-packages
python3dir = ${prefix}/lib/python3.3/site-packages
pythondir = ${prefix}/lib/python3.3/site-packages
Manish Sinha
  • 2,092
  • 2
  • 22
  • 33

2 Answers2

3

If you end up going the rewrite-the-macro route, you might want to make use of the variable _AM_PYTHON_INTERPRETER_LIST to write wrapper macros AM_PATH_PYTHON2 and AM_PATH_PYTHON3 that just set _AM_PYTHON_INTERPRETER_LIST and call AM_PATH_PYTHON with an extra suffix argument.

Community
  • 1
  • 1
0

It seems that this has been fixed in a recent release of automake. If, like me, you are on an older version that is not fixed, you can plug in

unset am_cv_pathless_PYTHON
unset PYTHON

between runs to make it work.

scafir
  • 1
  • 1