诸暨城市广场:[Python]python for ARM/LINUX
来源:百度文库 编辑:九乡新闻网 时间:2024/04/29 10:54:00
按照下面的方法,可以成功将python2.5 build到 ARM /linux , 我已经成功了:
Download latest from www.python.org Save into /home/user/python/
cd /home/user/python/
Extract python-
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
.