Python 移植教程

下面是我自己摸索的python移植的方法,大家可以作参考使用,
其中下文中使用的源文件需要自行从网上下载。下面这些是我是我用电鱼电子SAIL-AM335X实现的步骤。
准备文件:Python-2.7.13.tgz

sqlite-autoconf-3200100.tar.gz

Python-2.7.13-xcompile.patch.tar.gz
————————————————

步骤1、准备环境
tar xvf Python-2.7.13.tgz
tar xvf sqlite-autoconf-3200100.tar.gz
mkdir python2_7_13_for_x86_32
mkdir python2_7_13_for_arm
mkdir INSTALL
mkdir sqlite3

————————————————

步骤2、安装sqlite
cd sqlite-autoconf-3200100
./configure --host=arm-arago-linux-gnueabi

–prefix=$PWD/…/sqlite3
make
make install
————————————————

步骤3、安装python2_7_13_for_x86_32
…/python2_7_13_for_x86_32/
sed -i
‘s/self.extensions.remove(ext)/print(ext.name)/g’ …/Python-2.7.13/setup.py
…/Python-2.7.13/configure --prefix=pwd
make
make install
————————————————

步骤4、打补丁
cd …
tar xvf Python-2.7.13-xcompile.patch.tar.gz
-C Python-2.7.13
cd Python-2.7.13/
patch -p1 < Python-2.7.13-xcompile.patch

————————————————
步骤5、配置python2_7_13_for_arm

cd …/python2_7_13_for_arm/
…/Python-2.7.13/configure --prefix=pwd
–host=arm-arago-linux-gnueabi
–build=i686-linux-gnu
–enable-ipv6
–enable-static
ac_cv_file__dev_ptmx=“yes”
ac_cv_file__dev_ptc=“no”
LDFLAGS="-LKaTeX parse error: Undefined control sequence: \ at position 21: …./sqlite3/lib" \̲ ̲CPPFLAGS="-IPWD/…/sqlite3/include"

————————————————

步骤6、编译python2_7_13_for_arm
make
HOSTPYTHON=…/python2_7_13_for_x86_64/python
HOSTPGEN=…/python2_7_13_for_x86_64/Parser/pgen
BLDSHARED=“arm-arago-linux-gnueabi-gcc -shared”
CROSS_COMPILE=arm-arago-linux-gnueabi-
CROSS_COMPILE_TARGET=yes
HOSTARCH=arm-arago-linux-gnueabi
BUILDARCH=i686-linux-gnu

————————————————

步骤7、安装python2_7_13_for_arm
make install
HOSTPYTHON=…/python2_7_13_for_x86_64/python
BLDSHARED=“arm-arago-linux-gnueabi-gcc -shared”
CROSS_COMPILE=arm-arago-linux-gnueabi-
CROSS_COMPILE_TARGET=yes
prefix=$PWD/…/INSTALL
————————————————

步骤8、移植到开发板之后的配置
export PATH=/INSTALL/bin:$PATH
python python2.7-config --prefix /INSTALL
python python2.7-config --includes
/INSTALL/include/
python python2.7-config --libs
/INSTALL/lib/
————————————————————————————————————————————

########################################################################################

————————————————————————————————————————————
接着为Python安装easy_install工具

————————————————

步骤1、下载setuptools-0.6c11-py2.7.egg

wget
https://pypi.python.org/packages/25/5d/cc55d39ac39383dd6e04ae80501b9af3cc455be64740ad68a4e12ec81b00/setuptools-0.6c11-py2.7.egg#md5=fe1f997bc722265116870bc7919059ea
————————————————

步骤2、安装easy_install
/bin/sh setuptools-0.6c11-py2.7.egg

————————————————————————————————————————————

########################################################################################

————————————————————————————————————————————

修改openssl.so库的版本

————————————————

步骤1、下载openssl-OpenSSL_1_0_1b.zip,并解压缩
tar xvf openssl-OpenSSL_1_0_1b.zip

—————————————
步骤2、

mkdir arm_install
CC=arm-arago-linux-gnueabi-gcc
./Configure linux-elf no-asm
–prefix= P W D / a r m i n s t a l l − − o p e n s s l d i r = PWD/arm_install --openssldir= PWD/arminstallopenssldir=PWD --cross-compile-prefix=arm-arago-linux-gnueabi-
shared
make
make install
tar cvf arm_install.tar arm_install/
mv arm_install.tar /media/BOOT/

————————————————

步骤3、在开发板上进行操作
mv /media/mmcblk1p1/arm_install.tar /
tar xvf arm_install.tar
cp -r /arm_install/lib/* /usr/lib
cp /arm_install/bin/* /usr/bin/

————————————————

步骤4、取消SSL全局验证并验证easy_install
vi /INSTALL/bin/easy_install
增加
import ssl
ssl._create_default_https_context =
ssl._create_unverified_context
easy_install web.py

————————————————

步骤5、安装pip工具
easy_install pip
//此时使用pip工具会报SSL 认证错误,需要安装ntp网络对时

————————————————————————————————————————————

########################################################################################

————————————————————————————————————————————

移植ntp网络对时 (335x已有不用移植)
wget
http://www.eecis.udel.edu/~ntp/ntp_spool/ntp4/ntp-4.2/ntp-4.2.8p10.tar.gz
tar xvf ntp-4.2.8p10.tar.gz
cd ntp-4.2.8p10/
mkdir arm_install
CC=arm-arago-linux-gnueabi-gcc
./configure --prefix=$PWD/arm_install
–host=arm-arago-linux-gnueabi --enable-static --with-yielding-select=yes
make

make install

./ntpdate time.buptnet.edu.cn
关于以上内容都是基于SAIL-AM335X所完成的。

你可能感兴趣的:(Python 移植教程)