我正在尝试为python2.7编译pypoker-eval-138.0库(默认在mint linux上):
因此,当通过./configure
运行configure脚本时,我得到有关python解释器版本的错误:
...snip...
checking for a Python interpreter with version =2.3... done
checking for a Python interpreter with version =2.4... done
checking for a Python interpreter with version =2.5... done
checking for a Python interpreter with version =2.6... done
configure: error: No python development environments found
我安装的python版本:
ls /usr/bin/python*
/usr/bin/python (/usr/bin/python -> python2.7)
/usr/bin/python2-dbg-config
/usr/bin/python2 /usr/bin/python3
/usr/bin/python2.7 /usr/bin/python3.3
/usr/bin/python2.7-config /usr/bin/python3.3m
/usr/bin/python2.7-dbg /usr/bin/python3m
/usr/bin/python2.7-dbg-config /usr/bin/python-config
/usr/bin/python2-config /usr/bin/python-dbg
/usr/bin/python2-dbg /usr/bin/python-dbg-config
我也尝试了./configure PYTHON="/usr/bin/python2.7"
和类似但在上述问题上遇到了变体:
...snip..
checking whether to enable maintainer-specific portions of Makefiles... no
checking whether /usr/bin/python2.7 version =2.3... configure: error: too old
为了解决这个问题,我花了很多时间尝试更改aclocal / autoconf设置,但我不太熟悉应该做什么。我有以下.m4文件,我尝试编辑到不同程度的失败:
ls ./aclocal.m4 ./config/*
./aclocal.m4 ./config/install-sh ./config/ltsugar.m4
./config/ccpython.m4 ./config/libtool.m4 ./config/ltversion.m4
./config/config.guess ./config/ltmain.sh ./config/missing
./config/config.sub ./config/lt~obsolete.m4 ./config/py-compile
./config/depcomp ./config/ltoptions.m4 ./config/python.m4
例如,./config/ccpython.m4
:
...snip..
AC_DEFUN([ALL_CC_PYTHON],
[
m4_define([_AM_PYTHON_INTERPRETER_LIST], [python2.6 python2.5 python2.4 python2.3])
PYTHONS=''
found_one=''
_ONE_CC_PYTHON([=2.3], [2_3])
if test -f "$PYTHON" ; then found_one=$PYTHON ; PYTHONS="$PYTHON $PYTHONS" ; fi
unset PYTHON
...snip..
我的问题是,具体来说:如何为2.7编译一个python模块,该模块的配置脚本最多只支持2.6?我是否必须重新生成配置脚本,或者我可以将一些标志或变量传递给配置脚本以强制构建2.7?
非常感谢!
答案 0 :(得分:2)
好的,这是一个挑战(可以为声誉做些什么?:)。
提示在Changelog
中 * config/python.m4 (AM_PATH_PYTHON): Added python2.6 support.
* config/ccpython.m4 (ALL_CC_PYTHON): Added python2.6 support.
所以它应该只修复这些文件以支持新的python版本。我刚刚用python 2.7替换了python 2.5,用autoreconf
重新配置并且它工作正常。请参阅下面的完整补丁。
要使其正常运行,请确保已安装这些软件包:
$ apt-get install python-dev autoconf pkg-config
应用下面的补丁并运行
$ autoreconf
$ ./configure
$ make
这是补丁(好吧,我也必须更改Makefile.am):
diff --git a/Makefile.am b/Makefile.am
index c16df82..7d66971 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -40,12 +40,12 @@ _pokereval_2_6_la_LIBADD = ${PYTHON2_6_LIBS} ${POKER_EVAL_LIBS}
_pokereval_2_6_la_CFLAGS = ${PYTHON2_6_CFLAGS} ${POKER_EVAL_CFLAGS} -DPYTHON_VERSION=\"2_6\" -D'VERSION_NAME(w)=w\#\#2_
endif
-if PYTHON_2_5
-py2_5exec_LTLIBRARIES = _pokereval_2_5.la
-_pokereval_2_5_la_SOURCES = pypokereval.c
-_pokereval_2_5_la_LDFLAGS = -module -no-undefined -version-info 1:0:0
-_pokereval_2_5_la_LIBADD = ${PYTHON2_5_LIBS} ${POKER_EVAL_LIBS}
-_pokereval_2_5_la_CFLAGS = ${PYTHON2_5_CFLAGS} ${POKER_EVAL_CFLAGS} -DPYTHON_VERSION=\"2_5\" -D'VERSION_NAME(w)=w\#\#2_
+if PYTHON_2_7
+py2_7exec_LTLIBRARIES = _pokereval_2_7.la
+_pokereval_2_7_la_SOURCES = pypokereval.c
+_pokereval_2_7_la_LDFLAGS = -module -no-undefined -version-info 1:0:0
+_pokereval_2_7_la_LIBADD = ${PYTHON2_7_LIBS} ${POKER_EVAL_LIBS}
+_pokereval_2_7_la_CFLAGS = ${PYTHON2_7_CFLAGS} ${POKER_EVAL_CFLAGS} -DPYTHON_VERSION=\"2_7\" -D'VERSION_NAME(w)=w\#\#2_
endif
if PYTHON_2_4
diff --git a/config/ccpython.m4 b/config/ccpython.m4
index c94cbb6..46de0db 100644
--- a/config/ccpython.m4
+++ b/config/ccpython.m4
@@ -110,7 +110,7 @@ AM_CONDITIONAL([PYTHON_]$2, [test "$have_python" != "no"])
AC_DEFUN([ALL_CC_PYTHON],
[
-m4_define([_AM_PYTHON_INTERPRETER_LIST], [python2.6 python2.5 python2.4 python2.3])
+m4_define([_AM_PYTHON_INTERPRETER_LIST], [python2.6 python2.7 python2.4 python2.3])
PYTHONS=''
found_one=''
_ONE_CC_PYTHON([=2.3], [2_3])
@@ -119,7 +119,7 @@ unset PYTHON
_ONE_CC_PYTHON([=2.4], [2_4])
if test -f "$PYTHON" ; then found_one=$PYTHON ; PYTHONS="$PYTHON $PYTHONS" ; fi
unset PYTHON
-_ONE_CC_PYTHON([=2.5], [2_5])
+_ONE_CC_PYTHON([=2.7], [2_7])
if test -f "$PYTHON" ; then found_one=$PYTHON ; PYTHONS="$PYTHON $PYTHONS" ; fi
unset PYTHON
_ONE_CC_PYTHON([=2.6], [2_6])
diff --git a/config/python.m4 b/config/python.m4
index c8c5e30..4d0366e 100644
--- a/config/python.m4
+++ b/config/python.m4
@@ -42,7 +42,7 @@ AC_DEFUN([AM_PATH_PYTHON],
dnl $prefix/lib/site-python in 1.4 to $prefix/lib/python1.5/site-packages
dnl in 1.5.
m4_define_default([_AM_PYTHON_INTERPRETER_LIST],
- [python python2 python2.5 python2.6 python2.4 python2.3 python2.2 dnl
+ [python python2 python2.7 python2.6 python2.4 python2.3 python2.2 dnl
python2.1 python2.0 python1.6 python1.5])
m4_if([$1],[],[
答案 1 :(得分:1)
您可以尝试从源http://www.python.org/download/releases/2.6.9/
安装python2.6或试用pyenv https://github.com/yyuu/pyenv