This guide is a comprehensive resource for :ref:`contributing <contributing>` to Python -- for both new and experienced contributors. It is :ref:`maintained <devguide>` by the same community that maintains Python. We welcome your contributions to Python!
Here are the basic steps needed to get set up and contribute a pull request. This is meant as a checklist, once you know the basics. For complete instructions please see the :ref:`setup guide <setup>`.
Install and set up :ref:`Git <vcsetup>` and other dependencies (see the :ref:`Git Setup <setup>` page for detailed information).
Fork the CPython repository to your GitHub account and :ref:`get the source code <checkout>` using:
git clone https://github.com/<your_username>/cpython cd cpython
Build Python:
.. tab:: Unix .. code-block:: shell ./configure --with-pydebug && make -j
.. tab:: macOS .. code-block:: shell ./configure --with-pydebug && make -j
.. tab:: Windows .. code-block:: dosbatch PCbuild\build.bat -e -d
See also :ref:`more detailed instructions <compiling>`, :ref:`how to install and build dependencies <build-dependencies>`, and the platform-specific pages for :ref:`Unix <unix-compiling>`, :ref:`macOS <macOS>`, and :ref:`Windows <windows-compiling>`.
:ref:`Run the tests <runtests>`:
.. tab:: Unix .. code-block:: shell ./python -m test -j3
.. tab:: macOS .. code-block:: shell ./python.exe -m test -j3 Note: :ref:`Most <mac-python.exe>` macOS systems use :file:`./python.exe` in order to avoid filename conflicts with the ``Python`` directory.
.. tab:: Windows .. code-block:: dosbatch .\python.bat -m test -j3
Create a new branch where your work for the issue will go, for example:
git checkout -b fix-issue-12345 main
If an issue does not already exist, please create it. Trivial issues (for example, typo fixes) do not require any issue to be created.
Once you fixed the issue, run the tests, and the patchcheck:
.. tab:: Unix .. code-block:: shell make patchcheck
.. tab:: macOS .. code-block:: shell make patchcheck
.. tab:: Windows .. code-block:: dosbatch .\python.bat Tools\patchcheck\patchcheck.py
If everything is ok, commit.
Push the branch on your fork on GitHub and :ref:`create a pull request <pullrequest>`. Include the issue number using
gh-NNNN
in the pull request description. For example:gh-12345: Fix some bug in spam module
Add a News entry into the
Misc/NEWS.d
directory as individual file. The news entry can be created by using blurb-it, or the :pypi:`blurb` tool and itsblurb add
command. Please read more aboutblurb
in its repository.
Note
First time contributors will need to sign the Contributor Licensing Agreement (CLA) as described in the :ref:`Licensing <cla>` section of this guide.
Here are some links that you probably will reference frequently while contributing to Python:
- Issue tracker
- Buildbot status
- :ref:`help`
- PEPs (Python Enhancement Proposals)
- :ref:`gitbootcamp`
We encourage everyone to contribute to Python and that's why we have put up this developer's guide. If you still have questions after reviewing the material in this guide, then the Core Python Mentorship group is available to help guide new contributors through the process.
A number of individuals from the Python community have contributed to a series of excellent guides at Open Source Guides.
Core developers and contributors alike will find the following guides useful:
Guide for contributing to Python:
We recommend that the documents in this guide be read as needed. You can stop where you feel comfortable and begin contributing immediately without reading and understanding these documents all at once. If you do choose to skip around within the documentation, be aware that it is written assuming preceding documentation has been read so you may find it necessary to backtrack to fill in missing concepts and terminology.
Improving Python's code, documentation and tests are ongoing tasks that are never going to be "finished", as Python operates as part of an ever-evolving system of technology. An even more challenging ongoing task than these necessary maintenance activities is finding ways to make Python, in the form of the standard library and the language definition, an even better tool in a developer's toolkit.
While these kinds of change are much rarer than those described above, they do happen and that process is also described as part of this guide:
This guide is specifically for contributing to the Python reference interpreter, also known as CPython (while most of the standard library is written in Python, the interpreter core is written in C and integrates most easily with the C and C++ ecosystems).
There are other Python implementations, each with a different focus. Like CPython, they always have more things they would like to do than they have developers to work on them. Some major examples that may be of interest are:
- PyPy: A Python interpreter focused on high speed (JIT-compiled) operation on major platforms
- Jython: A Python interpreter focused on good integration with the Java Virtual Machine (JVM) environment
- IronPython: A Python interpreter focused on good integration with the Common Language Runtime (CLR) provided by .NET and Mono
- Stackless: A Python interpreter focused on providing lightweight microthreads while remaining largely compatible with CPython specific extension modules
- MicroPython: A tiny Python interpreter with small subset of the Python standard library that is optimised to run on microcontrollers and in constrained environments.
- CircuitPython: A fork of MicroPython designed to simplify experimenting and learning to code on low-cost microcontroller boards.
- Coding style guides
- Issue tracker
- Buildbot status
- Source code
- PEPs (Python Enhancement Proposals)
- :ref:`help`
- :ref:`developers`
- Anyone can clone the sources for this guide. See :ref:`devguide`.
- Help with ...
- Tool support
- :ref:`gdb`
- :ref:`clang`
- Various tools with configuration files as found in the Misc directory
- Information about editors and their configurations can be found in the wiki
- python.org maintenance
- :ref:`Search this guide <search>`
Please note that all interactions on Python Software Foundation-supported infrastructure is covered by the PSF Code of Conduct, which includes all infrastructure used in the development of Python itself (for example, mailing lists, issue trackers, GitHub, etc.). In general this means everyone is expected to be open, considerate, and respectful of others no matter what their position is within the project.
Moved to :ref:`versions`
.. toctree::
:maxdepth: 3
getting-started/index
developer-workflow/index
triage/index
documentation/index
testing/index
development-tools/index
core-developers/index
internals/index
versions
contrib/index