在arm上使用python-2.7.10

来源:转载

目标:在arm上使用python-2.7.10
1、首先解压python-2.7.10的源码,然后在同级目录下建立一个build.pc的目录,我们需要首先生成一个x86 linux下可用的python解释器:
../Python-2.7.10/configure
make
按照默认配置生成。
2、修改Python-2.7.10目录下的configure脚本,在开头加上两行:
ac_cv_file__dev_ptmx="yes"
ac_cv_file__dev_ptc="no"
3、建立一个build.arm的目录,进入此目录配置python:
../Python-2.7.10/configure --host=arm-arago-linux-gnueabi--prefix=/work/winshare/release --build=arm-arago-linux --disable-ipv6--enable-shared
make
编译的过程会产生这个错误:
arm-arago-linux-gnueabi-gcc -DNDEBUG -g -fwrapv -O3 -Wall-Wstrict-prototypes Parser/acceler.oParser/grammar1.o Parser/listnode.o Parser/node.o Parser/parser.oParser/parsetok.o Parser/bitset.o Parser/metagrammar.o Parser/firstsets.oParser/grammar.o Parser/pgen.o Objects/obmalloc.o Python/mysnprintf.oPython/pyctype.o Parser/tokenizer_pgen.o Parser/printgrammar.oParser/pgenmain.o -lpthread -ldl -lpthread -lutil -o Parser/pgen
make[1]: Leaving directory `/work/winshare/build.arm'
Parser/pgen ../Python-2.7.10/Grammar/Grammar Include/graminit.hPython/graminit.c
Parser/pgen: Parser/pgen: cannot execute binary file
make: *** [Include/graminit.h] Error 126
4、复制build.pc目录下的pgen文件:
cp ../build.pc/Parser/pgen ./Parser/
继续:
make
一切正常,生成结束,但在makeinstall时出问题了:
/usr/bin/install -c -m 644 ../Python-2.7.10/LICENSE/work/winshare/release/lib/python2.7/LICENSE.txt
if test -d /work/winshare/release/lib/python2.7/distutils/tests;then /
/usr/bin/install -c -m 644 ../Python-2.7.10/Modules/xxmodule.c /
/work/winshare/release/lib/python2.7/distutils/tests ; /
fi
PYTHONPATH=/work/winshare/release/lib/python2.7 /
_PYTHON_PROJECT_BASE=/work/winshare/build.arm _PYTHON_HOST_PLATFORM=linux2-armPYTHONPATH=/work/winshare/build.arm/build/lib.linux2-arm-2.7:../Python-2.7.10/Lib:../Python-2.7.10/Lib/plat-linux2python2.7 -Wi -tt /work/winshare/release/lib/python2.7/compileall.py /
-d/work/winshare/release/lib/python2.7 -f /
-x'bad_coding|badsyntax|site-packages|lib2to3/tests/data' /
/work/winshare/release/lib/python2.7
Traceback (most recent call last):
File"/work/winshare/release/lib/python2.7/compileall.py", line 16, in<module>
import struct
File"/work/winshare/release/lib/python2.7/struct.py", line 1, in<module>
from _struct import *
ImportError:/work/winshare/build.arm/build/lib.linux2-arm-2.7/_struct.so: cannot openshared object file: No such file or directory
make: *** [libinstall] Error 1
这个问题是由于安装时使用了python,但Makefile中指定了错误的库,使用了arm平台上的so,显然这是不能在我们的x86linux上运行的。
5、修改build.arm下的Makefile
在Makefile中查找PYTHONPATH,将build.pc目录下的库文件路径添加到PYTHONPATH中,如:
PYTHON_FOR_BUILD=_PYTHON_PROJECT_BASE=$(abs_builddir) _PYTHON_HOST_PLATFORM=$(_PYTHON_HOST_PLATFORM)PYTHONPATH=/work/winshare/build.pc/build/lib.linux-i686-2.7/:$(shelltest -f pybuilddir.txt && echo $(abs_builddir)/`catpybuilddir.txt`:)$(srcdir)/Lib:$(srcdir)/Lib/$(PLATDIR) python2.7
注意,所有的PYTHONPATH中都需要修改。
再次makeinstall,就在release目录下得到了完整的python文件。

参考:在arm上使用python-2.7.10
http://www.lai18.com/content/1370768.html



分享给朋友:
您可能感兴趣的文章:
随机阅读: