ยง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.

  1. Get the 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:

  1. git clone
% pwd
/Users/alexlai/build
% git clone https://github.com/sousukerai/cpython.git
  1. Add an upstream remote, then configure git to pull main from upstream and always push to origin:
 % 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
  1. Verify that your setup is correct:
% 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
  1. Configure
./configure --with-pydebug
  1. make ir
$ 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+