§2023-06-22
§Compile Python from Source
When you are using ubuntu, sometime you have to wait for the most recent stable release of Pyton. We might as well do it by own own.
Prerequisites
$ sudo dnf install wget yum-utils make gcc openssl-devel bzip2-devel libffi-devel zlib-devel
get source
https://www.python.org/ftp/python/3.11.4/Python-3.11.4.tar.xz
wget https://www.python.org/ftp/python/3.11.4/Python-3.11.4.tar.xz
$ tar xvf src/Python-3.11.4.tar.xz
Configure
$ cd Python-3.11.4
$ ./configure --with-system-ffi --with-computed-gotos --enable-loadable-sqlite-extensions
....
....
configure: creating ./config.status
config.status: creating Makefile.pre
config.status: creating Misc/python.pc
config.status: creating Misc/python-embed.pc
config.status: creating Misc/python-config.sh
config.status: creating Modules/Setup.bootstrap
config.status: creating Modules/Setup.stdlib
config.status: creating Modules/ld_so_aix
config.status: creating pyconfig.h
configure: creating Modules/Setup.local
configure: creating Makefile
configure:
If you want a release build with all stable optimizations active (PGO, etc),
please run ./configure --enable-optimizations
$ ./configure --enable-optimizations
$ time make -j 6
real 26m59.085s
user 68m30.229s
sys 2m14.682s
- OrangePi5 Plus 8G 256G PCIeSSD running Deabin Bookworm
- python 3.11.14 can not fulfill mongo compiling requirements
```bash
$ time make -j 10
real 5m24.631s
user 20m17.941s
sys 0m50.202s
$ wget https://www.python.org/ftp/python/3.10.12/Python-3.10.12.tar.xz
- 2023-07-11
- orangepi5plus, 8GMB. deabin bookworm
```bash
time make -j 10
real 5m24.675s
user 21m51.101s
sys 0m53.446s
real 3m35.163s
user 11m44.453s
sys 0m39.757s
$ time make -j 10 // ${nproc} + 2
real 5m55.265s
user 23m30.905s
sys 0m56.811s
$ time make -j 6 // ${nproc} + 2
$ time make -j 4
real 32m47.064s
user 67m16.575s
sys 2m3.888s
$ time make -j 8
real 14m39.211s
user 37m3.568s
sys 1m53.524s
$ time make -j 8
real 14m27.417s
user 48m8.730s
sys 1m49.545s
$ time make -j 6
real 15m50.643s
user 48m0.766s
sy- -1m53.677s
real 3m49.309s
user 9m43.429s
sys 0m24.006s
$ time make -j 10 // ${nproc} + 2
real 7m26.704s
user 28m10.589s
sys 1m3.465s
$ time make -j 8
real 7m0.917s
user 25m53.621s
sys 0m59.353s
$ time make -j 6 --> compiling verion 3.10.12
real 7m9.152s
user 24m29.228s
sys 0m53.549s
$ time make -j 6 // ${nproc} + 2
real 7m11.677s
user 16m16.056s
sys 0m55.503s
¶ Eviroment Control
$ ./python -m venv ~/PYTHON-3.11.4
alexlai@orangepi5plus:~/build/Python-3.11.4$ $ pwd
/opt/xfs/home/alexlai/build/Python-3.11.4
$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
alexlai@orangepi5plus:~/build/Python-3.11.4$ source ~/PYTHON-3.11.4/bin/activate
(PYTHON-3.11.4) alexlai@orangepi5plus:~/build/Python-3.11.4$ echo $PATH
/opt/xfs/home/alexlai/PYTHON-3.11.4/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
(PYTHON-3.11.4) alexlai@orangepi5plus:~/build/Python-3.11.4$ which python
/opt/xfs/home/alexlai/PYTHON-3.11.4/bin/python
(PYTHON-3.11.4) alexlai@orangepi5plus:~/build/Python-3.11.4$ which python3
/opt/xfs/home/alexlai/PYTHON-3.11.4/bin/python3
(PYTHON-3.11.4) alexlai@orangepi5plus:~/build/Python-3.11.4$ which pip
/opt/xfs/home/alexlai/PYTHON-3.11.4/bin/pip
(PYTHON-3.11.4) alexlai@orangepi5plus:~/build/Python-3.11.4$ which pip3
/opt/xfs/home/alexlai/PYTHON-3.11.4/bin/pip3
Return to Top