python linux arm_python for ARM/LINUX

本文档详细记录了如何在ARM/Linux系统上编译和安装Python 2.5。首先从python.org下载源码,然后进行解压、配置、编辑Makefile、编译和安装。在构建过程中,遇到问题时,需要修改某些文件并使用特定的交叉编译器。最后,通过SMB协议将目标文件复制到设备,并设置环境变量以确保Python的正常运行。此过程对于在不同架构系统上构建Python非常有用。
摘要由CSDN通过智能技术生成

按照下面的方法,可以成功将python2.5 build到 ARM /linux , 我已经成功了:

Download latest from www.python.org Save into /home/user/python/ cd /home/user/python/

Extract python-.tar.gz: tar zxf python-2.5.tar.gz

mkdir target

cd Python-2.5/

./configure --target=arm-linux --prefix=/home/user/python/target

Edit the Makefile: CC = /usr/local/arm-linux/bin/arm-linux-gcc -lpthread

CXX = /usr/local/arm-linux/bin/arm-linux-g -lpthread

Compile Python: make

make install

Copy /home/user/python/target to Greenphone on /mnt/user_local/ using the SMB protocol via Konqueror. smb://10.10.10.20

and /home/user/python/target

Telnet to the Greenphone: telnet 10.10.10.20

cd /mnt/user_local/

mv target python

cd python/bin/

PYTHONPATH=/mnt/user_local/python/lib/python2.5 ./python2.5 -Wi -tt /mnt/user_local/python/lib/python2.5/compileall.py -d /mnt/user_local/python/lib/python2.5 -f -x 'bad_coding|badsyntax|site-packages' /mnt/user_local/python/lib/python2.5

Make a symlink from /usr/lib/python to /mnt/user_local/python/lib/python2.5/ cd /usr/lib

ln -s /mnt/user_local/python/lib/python2.5/ python

Edit /etc/profile to get proper paths for python vi /etc/profile

Insert the following in the /etc/profile export PYTHONPATH=/usr/lib/python/

export PYTHONHOME=/usr/lib/python/

Log out or restart your shell, so it updates its env variables. Enjoy python ;)

As Michael Lauer describes here: http://www.vanille-media.de/site/index.php/projects/python-for-arm-linux/ Python does not build on a system with a different arch than the target system. This is because Python uses the created executables for the build process. The settings above helped me alot but I did two more things to succeed:

After the first error with the first make run I renamed the executables python to python.arm and Parser/pgen to Parser/pgen.arm. Then I issued the command make again. After make install I moved the python.arm executable to the right place in the target directory.

make install checks if the shared libraries are loadable and renames them to something_failed.so. Because all those shared libs won't load (because they are arm-executables) all the native libs are renamed. I used a tool to rename all those files in lib/python2.5/lib-dynload back to their normal name: mmv -v '*_failed.so' '#1.so'

Because lack of space on the target I removed everything which is not needed: rm -rf include man bin/idle bin/smtpd.py lib/lib-tk lib/*/test lib/test

Last thing was the filesystem on the target which is vfat. vfat does neither allow hard nor soft links. I just removed the link in bin/ and renamed python2.5 to python.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值