Quick reference¶
Here are the basic steps needed to get set up and open a pull request.
This is meant as a checklist and cheat-sheet, not a comprehensive guide. For complete instructions see the setup guide and the pull request guide.
Set up Git¶
Install and set up Git.
For detailed setup information, see “Install Git”. There is also a more detailed Git guide and cheat sheet.
Fork and clone the repo¶
Fork the CPython repository to your GitHub account and clone the repo using:
git clone https://github.com/<your_username>/cpython
cd cpython
For detailed information, see “Get the source code”.
Build Python¶
./configure --config-cache --with-pydebug && make -j $(nproc)
./configure --config-cache --with-pydebug && make -j$(sysctl -n hw.logicalcpu)
PCbuild\build.bat -e -d
See also more detailed instructions, how to install and build dependencies, and the platform-specific pages for Unix, macOS, and Windows.
Run the tests¶
./python -m test -j0
./python.exe -m test -j0
Note
Most macOS systems use
./python.exe in order to avoid filename conflicts with
the Python directory.
.\python.bat -m test -j0
See also how to write and run tests.
Create issues and pull requests¶
Create issues for nontrivial changes¶
For most changes, create an issue before submitting a pull request. Trivial changes like typo fixes do not need issues.
Create work branches¶
Work on a feature or fix in a new branch in Git from the main branch:
git checkout -b fix-issue-12345 main
Make changes, then commit and push to your fork.
Document your changes¶
Many changes deserve a NEWS entry which documents what changed. For more information on how and when to write news entries, see “Updating NEWS and What’s New in Python”.
A news entry can be created locally with the blurb tool
and its blurb add command or online after a pull request has
been opened with blurb-it.
For more information about how to create news entries, see “How to add a NEWS entry”.
Create pull requests¶
Create pull requests on GitHub from your branches, on your fork, and make sure
to put the relevant issue number in gh-NNNNNN format in the pull request title.
For example:
gh-12345: Fix some bug in spam module
See also, GitHub’s documentation on creating pull requests.
For more detailed guidance, follow the step-by-step pull request guide.
Note
First time contributors will need to sign the Contributor Licensing Agreement (CLA) as described in the Licensing section of this guide.
Work on your pull request¶
Make sure the continuous integration checks on your pull request are green (successful).
Read and respond to reviewer comments on your pull request.
See also, GitHub’s documentation on commenting on pull requests.
Don’t force-push¶
In order to keep the commit history intact, avoid squashing or amending history and then force-pushing to the PR. Reviewers often want to look at individual commits.
CPython uses squash merges, so PRs will end up as single commits when merged.
