Skip to content

Latest commit

 

History

History
85 lines (66 loc) · 3.67 KB

File metadata and controls

85 lines (66 loc) · 3.67 KB

Setup

There is a very detailed guide to get started with CPython from the official documentation that can provide more context and details on each step.

To simplify the process, make sure you have the following dependencies in your computer:

  • Git (optional, but recommended)
  • A C-compiler:
    • gcc for Linux,
    • clang for macOS (via XCode),
    • cl for Windows (via MSVC)
  • Your favorite editor or IDE.

Tip

On a fresh machine, ./configure can fail if some development headers are missing. A quick preemptive install:

  • Debian/Ubuntu: sudo apt install build-essential gdb lcov pkg-config libbz2-dev libffi-dev libgdbm-dev liblzma-dev libncurses5-dev libreadline6-dev libsqlite3-dev libssl-dev lzma lzma-dev tk-dev uuid-dev zlib1g-dev
  • macOS (Homebrew): brew install openssl xz gdbm
  • Windows: dependencies are handled automatically by build.bat

Tip

Some exercises later in the tutorial need extra tools. Installing them now avoids waiting on slow downloads mid-session:

  • Rust + maturin (pip install maturin) — for the Rust exercises
  • Zig + Poetry — for the Zig exercise
  • pip install build setuptools — for packaging the C extension

It's recommended that you clone the cpython repository so you can access the code that we will use:

git clone https://github.com/python/cpython

in case your Internet is not so good, you can do a clone of the last commit from the repository (also called shallow clone) by using:

git clone --depth=1 https://github.com/python/cpython

Important

These commands clone the main branch by default, which is what the exercises assume. Some exercises (e.g. the argument clinic output in Exercise 04) rely on recent additions to CPython, so checking out an older release tag/branch instead of main may leave you with different code than what's shown in the exercises.

You are now prepared to start the tutorial!

What's next?

There are two main sections on this tutorial, each one will be followed by a couple of exercises, which you can find in the exercises directory.

You can access them directly from here:

Part 1: Navigating CPython

Part 2: Extending CPython

Further Reading