Python移植
版本:2.7.12
交叉编译器版本:arm-linux-gcc-4.6.2
1.先编译本地python和pgen,编译脚本如下(build.sh):
###先编译python和pgen--for python2.7.12
PYTHON_X86=./python_x86
PGEN_X86=./pgen_x86
./configure
make python Parser/pgen
mv python ${PYTHON_X86}
mv Parser/pgen ${PGEN_X86}
make clean
2.交叉编译python所需的常用库,如ncurses,openssl,sqlite,zlib等。
此步骤略,依各自项目所需进行移植。
3.修改setup.py,使能交叉编译开关:
cross_compiling = True
4.交叉编译
echo ac_cv_file__dev_ptmx=no > config.site
echo ac_cv_file__dev_ptc=no >> config.site
export CONFIG_SITE=config.site
./configure --host=arm-linux --prefix=/opt/python-2.7.12 --enable-shared --build=x86_64-unknown-linux-gnu --disable-ipv6 --without-ensureip
make HOSTPYTHON=${PYTHON_X86} HOSTPGEN=${PGEN_X86}
make install HOSTPYTHON=${PYTHON_X86}
5.部署到开发板上:
拷贝动态链接库到开发板/lib目录下:
cp /JCKF_SW/z10586/workspace-python/porting/Python-2.7.12/libpython2.7.so* /opt/python-2.7.12/lib/
cp -pR /JCKF_SW/z10586/workspace-python/porting/Python-2.7.12/build/lib.linux2-arm-2.7 /opt/python-2.7.12/lib/python2.7/lib-dynload
建立开发的python命令链接到/opt/python-2.7.12/bin/python2.7上:
ln -s /opt/python-2.7.12/bin/python2.7 /bin/python
部署完毕,尽情享受嵌入式Python吧!
在开发板运行python时,回车键出现^H字符的处理:使用组合键Ctrl+Backspace,或者用delete键删除输入。
附:
===================================================================================
make时的警告信息:
Python build finished, but the necessary bits to build these modules were not found:
_bsddb _ssl _tkinter
bsddb185 bz2 dbm
dl gdbm imageop
linuxaudiodev ossaudiodev readline
sunaudiodev zlib
To find the necessary bits, look in setup.py in detect_modules() for the module's name.
模块 依赖 说明
_bsddb bsddb Interface to Berkeley DB library。Berkeley数据库的接口
_curses ncurses Terminal handling for character-cell displays。
_curses_panel ncurses A panel stack extension for curses。
_sqlite3 sqlite DB-API 2.0 interface for SQLite databases。sqlite3.
_ssl openssl TLS/SSL wrapper for socket objects。
_tkinter N/A a thin object-oriented layer on top of Tcl/Tk。如果不使用桌面程序可以忽略TKinter
bsddb185 old bsddb module 老的bsddb模块,可忽略。
bz2 bzip2 Compression compatible with bzip2。bzip2-devel
dbm bsddb Simple “database” interface。
dl N/A Call C functions in shared objects.Python2.6开始,已经弃用。
gdbm gdbm GNU’s reinterpretation of dbm
imageop N/A Manipulate raw image data。已经弃用。
linuxaudiodev N/A linux音频接口
ossaudiodev N/A linux音频接口
readline readline-devel GNU readline interface
sunaudiodev N/A Access to Sun audio hardware。这个是针对Sun平台的,可以忽略
zlib zlib Compression compatible with gzip
阅读(2839) | 评论(0) | 转发(0) |