AM_PATH_PYTHON for python2 and python3

六眼飞鱼酱① 提交于 2021-01-27 06:59:25

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!