问题
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
回答1:
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.
来源:https://stackoverflow.com/questions/17541207/am-path-python-for-python2-and-python3