
在debian上編譯python3.9很簡單:
sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libsqlite3-dev libreadline-dev libffi-dev curl libbz2-dev
wget https://www.python.org/ftp/python/3.9.1/Python-3.9.1.tgz
tar -xf Python-3.9.1.tgz
cd Python-3.9.1
./configure --enable-optimizations
#nproc value is 4 in my pc platform
make -j 4
sudo make altinstall
如何編譯python3.9並安裝在openwrt上?
root@OpenWrt:~# cat /etc/banner
_______ ________ __
| |.-----.-----.-----.| | | |.----.| |_
| - || _ | -__| || | | || _|| _|
|_______|| __|_____|__|__||________||__| |____|
|__| W I R E L E S S F R E E D O M
-----------------------------------------------------
OpenWrt 19.07.7, r11306-c4a6851c72
-----------------------------------------------------
root@OpenWrt:~# uname -a
Linux OpenWrt 4.14.221 #0 SMP Mon Feb 15 15:22:37 2021 x86_64 GNU/Linux
root@OpenWrt:~# python3
Python 3.7.10 (default, May 28 2021, 13:26:31)
[GCC 7.5.0] on linux
有些軟體需要Python 3.8或更高版本,我想編譯python3.9。
答案1
下載您所針對的 OpenWRT 版本的 SDK,修改 Python 的 Makefile,並使用 SDK 編譯 Python。
您可以在此處查看一些設定說明:https://openwrt.org/docs/guide-developer/using_the_sdk
安裝 SDK 後,修改 python3 的 Makefile(以下是合併到將 python 更新到 3.9.5 的 PR 範例:https://github.com/openwrt/packages/pull/15586/commits/e312275dd9c25c4032b4d2d3623b042905c8bf16)
然後您應該能夠使用類似 的命令來編譯該包,這將在SDK 的資料夾make package/python3/compile V=sc
中產生可安裝的 IPK 。bin