§2023-07-20
These instructions cover how to get a working copy of the source code and a compiled version of the CPython interpreter (CPython is the version of Python available from https://www.python.org/). It also gives an overview of the directory structure of the CPython source code.
The CPython repo is hosted on GitHub. To get a copy of the source code you should fork the Python repository on GitHub, create a local clone of your personal fork, and configure the remotes.
You will only need to execute these steps once per machine:
% pwd
/Users/alexlai/build
% git clone https://github.com/sousukerai/cpython.git
% cd cpython
% git remote add upstream https://github.com/python/cpython
% git config --local branch.main.remote upstream
% git remote set-url --push upstream git@github.com:sousukerai/cpython.git
% git remote -v
origin https://github.com/sousukerai/cpython.git (fetch)
origin https://github.com/sousukerai/cpython.git (push)
upstream https://github.com/python/cpython (fetch)
upstream git@github.com:sousukerai/cpython.git (push)
% git config branch.main.remote
upstream
./configure --with-pydebug
$ time make -j 10
real 0m46.584s
user 3m53.111s
sys 0m19.067s
$ ./python --version
Python 3.12.0a2+
$ ./python -m venv ~/PYTHON-3.12.0a2+
Return to Top