Skip to main content
Before you can start contributing to CPython, you’ll need to set up your development environment. This guide will walk you through the process step by step.

Prerequisites

Before you begin, make sure you have:
  • A Unix-like operating system (Linux, macOS, BSD, or Cygwin on Windows)
  • Git for version control
  • A C compiler (GCC or Clang)
  • Basic development tools (make, etc.)
For Windows development, see PCbuild/readme.txt for platform-specific instructions.

Getting the Source Code

1

Fork the repository

Visit github.com/python/cpython and click the “Fork” button to create your own copy of the repository.
2

Clone your fork

git clone https://github.com/YOUR-USERNAME/cpython.git
cd cpython
3

Add upstream remote

git remote add upstream https://github.com/python/cpython.git
git fetch upstream

Installing Dependencies

CPython requires various third-party libraries depending on your platform and configuration. Not all standard library modules are buildable on all platforms.

Linux (Debian/Ubuntu)

sudo apt-get update
sudo apt-get install build-essential gdb lcov pkg-config \
      libbz2-dev libffi-dev libgdbm-dev libgdbm-compat-dev liblzma-dev \
      libncurses5-dev libreadline6-dev libsqlite3-dev libssl-dev \
      lzma lzma-dev tk-dev uuid-dev zlib1g-dev

Linux (Fedora/RHEL)

sudo dnf install yum-utils gcc-c++ \
      bzip2-devel expat-devel gdbm-devel ncurses-devel openssl-devel \
      readline-devel sqlite-devel tk-devel xz-devel zlib-devel

macOS

brew install openssl xz gdbm
macOS has additional configure and build options related to framework and universal builds. See Mac/README.rst for details.

Configuring Your Workspace

Editor Setup

CPython follows specific coding standards. Configure your editor to:
  • Use 4 spaces for indentation (not tabs)
  • Trim trailing whitespace
  • Use Unix-style line endings (LF)
  • Follow PEP 7 for C code and PEP 8 for Python code

Git Configuration

# Set your name and email
git config user.name "Your Name"
git config user.email "[email protected]"

# Optional: Set up commit template
git config commit.template .gitmessage

Verification

Verify your setup by running a quick configuration test:
./configure --help
This should display available configuration options. If it works, you’re ready to build CPython!

Troubleshooting

If ./configure doesn’t exist, you may need to generate it:
autoreconf -i
However, this is rarely needed as the configure script is committed to the repository.
macOS’s system OpenSSL may be outdated. Install via Homebrew and configure:
brew install openssl
./configure --with-openssl=$(brew --prefix openssl)
Ensure you have write permissions in the CPython directory. Avoid using sudo for build operations.

Next Steps

Now that your environment is set up, you’re ready to:

Additional Resources

Build docs developers (and LLMs) love