作者:手机用户2502860763 | 来源:互联网 | 2023-09-06 17:18
移植python2.7到arm-linuxpython基础库编译
- 设置交叉编译环境
- 修改Makefile相关配置文件 参考地址1 参考地址2
生成语法解析器
$ mkddir build.pc
$ cd build.pc
$ ../configure
$ make
设置交叉编译环境
$ mkdir build.arm
$ cat build4arm-linux.sh
#!/bin/sh
export CC="/opt/codesourcery/bin/arm-linux-gcc"
export CFLAGS=""
export LDFLAGS="-lc"
export LIBS="-L/opt/codesourcery/arm-none-linue-guneabi/libc/usr/lib \
-L./"
../configure \
--prefix=/opt/python_install \
--host=arm-linux \
--enable-shared \
--disable-ipv6
修改Makefile相关配置文件
根据交叉编译环境生成Makefile等配置文件 $ ./build4arm-linux.sh
修改python扩展库编译配置文件
$ sudo sed -i 's/\(add_dir_to_list(self\.compiler\.library_dirs, '"'"'\/usr\/local\/lib'"'"')\)/#&/; s/\(add_dir_
to_list(self\.compiler\.include_dirs, '"'"'\/usr\/local\/include'"'"')\)/#&/' ../setup.py
修改Makefile `$ sed -i 'OPT=/ { /-g/ d; s/-O3/-O2/ }' Makefile
python扩展库编译
#!/bin/sh
# delete the '\n'
sed -n '
/^\/opt\/codesourcery\// b end
/^ccl: warning:/ b end
/^\*\*\* WARNING:/ b end
/^building '.*' extension/ b end
/\(\/opt\/codesourcery\/\|cc1: warning:\|\*\*\* WARNING:\|building '.*' extension\)/ !H
$ b end
:end
x
s/\n//g
p
' copy.sh | sudo tee output.sh
# delete warning information and replace the header file path, lib path
sed -i '1 d' output.sh
sed -i '
/^ccl: warning:/ d
/warning:/d
/^\*\*\* WARNING:/ d
/^building '.*' extension/ d
s/-I\/usr\/local\/include/-I\/opt\/codesourcery\/arm-none-linux-gnueabi\/libc\/usr\/include/g
s/-I\/usr\/include/-I\/opt\/codesourcery\/arm-none-linux-gnueabi\/libc\/usr\/include/g
s/-L\/usr\/local\/lib/-L\/opt\/codesourcery\/arm-none-linux-gnueabi\/libc\/usr\/lib/g
' output.sh
python移植
fail2ban安装
修改文件安装文件 setup.py
sed -i 's/\/var/\/data&/g; s/\/etc/\/data&/g; s/\/usr/\/data&/g' setup.py