最近在看一本python的书CPython Internals,打算研究一下CPython的代码,然后就在Linux(ubuntu)下编译了CPython源码,在此记录一下。
1. 使用git下载cpython源码
git clone --branch 3.9 https://github.com/python/cpython
cd cpython
2. 使用weget下载cpython3.9.7版本,使用这种是适用于没安装git或者访问github网络比较差的小伙伴
wget https://github.com/python/cpython/archive/refs/tags/v3.9.7.tar.gz
tar zxf v3.9.7.tar.gz
cd cpython-3.9.7
3. 下载完成之后,需要对cpython进行编译
# 编译工具安装
sudo apt install build-essential
# 依赖库安装
sudo apt install libssl-dev zlib1g-dev libncurses5-dev libncursesw5-dev libreadline-dev libsqlite3-dev libgdbm-dev libdb5.3-dev libbz2-dev libexpat1-dev liblzma-dev libffi-dev
4. 运行配置脚本&#x