compile cpython code from source in ubuntu 18.04 LTS
First open the github link and clone the code https://github.com/python/cpython
open the terminal and follow the steps
$ git clone https://github.com/python/cpython.git
$ cd cpython
Now install the packages
$ sudo apt-get update \
&& sudo apt-get install -y build-essential git libexpat1-dev libssl-dev zlib1g-dev \
libncurses5-dev libbz2-dev liblzma-dev \
libsqlite3-dev libffi-dev tcl-dev linux-headers-generic libgdbm-dev \
libreadline-dev tk tk-dev
Before running the below command change the final_output_path, i have set my path to the /home/ubuntu/desktop/compiledpython3.8/ and make sure that folder exist
$ ./configure --prefix=< final_output_path> \
--enable-loadable-sqlite-extensions \
--enable-shared \
--with-lto \
--enable-optimizations \
--with-system-expat \
--with-system-ffi \
--enable-ipv6 --with-threads --with-pydebug --disable-rpath
$ make
$ sudo make install
Now change directory to the final_output_path
Now in the final_output_path you will get 4 folders bin,include,lib,share, now export LD_LIBRARY_PATH
$ export LD_LIBRARY_PATH=< final_output_path> /lib/
Now change directory to the bin folder of your final_output_path and run your latest python3.8