Movatterモバイル変換


[0]ホーム

URL:


ContentsMenuExpandLight modeDark modeAuto light/dark, in light modeAuto light/dark, in dark modeSkip to content
Python Developer's Guide
Logo
Python Developer's Guide
Back to top

Important

This is part of aDraft of the Python Contributor’s Guide.Text in square brackets are notes about content to fill in.Currently, the devguide and this new Contributor’s Guide co-exist in therepo. We are using Sphinx include directives to demonstrate the re-organization.The final Contributor’s Guide will replace the devguide with content in only oneplace.We welcome help with this!

The[Plan for the Contributor’s Guide] page has more details about the current state of this draftandhow you can help. See more info about the Contributor Guide in thediscussion forum:Refactoring the DevGuide.

Get the source code

Note

[This is theGet the source code section from the devguide. We might need to editit to clarify that some steps are only needed for code contribution.]

The CPython repo is hosted on GitHub. To get a copy of the source code you shouldfork the Python repository on GitHub,create a localclone of your personal fork, and configure the remotes.

You will only need to execute these steps once per machine:

  1. Go tohttps://github.com/python/cpython.

  2. PressFork on the top right.

  3. When asked where to fork the repository, choose to fork it to your username.

  4. Your fork will be created athttps://github.com/<username>/cpython.

  5. Clone your GitHub fork (replace<username> with your username):

    $ git clone git@github.com:<username>/cpython.git

    (You can use both SSH-based or HTTPS-based URLs.)

  1. Add anupstream remote, then configuregitto pullmain fromupstream and always push toorigin:

    $ 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:<your-username>/cpython.git
  2. Verify that your setup is correct:

    $ git remote -vorigin  git@github.com:<your-username>/cpython.git (fetch)origin  git@github.com:<your-username>/cpython.git (push)upstream        https://github.com/python/cpython (fetch)upstream        git@github.com:<your-username>/cpython.git (push)$ git config branch.main.remoteupstream

For more information about these commands seeGit Bootcamp and Cheat Sheet.

If you did everything correctly, you should now have a copy of the codein thecpython directory and two remotes that refer to your own GitHub fork(origin) and the official CPython repository (upstream).

If you want a working copy of an already-released version of Python,that is, a version inmaintenance mode, you can checkouta release branch. For instance, to checkout a working copy of Python 3.13,dogitswitch3.13.

You will need to re-compile CPython when you do such an update.

Do note that CPython will notice that it is being run from a working copy.This means that if you edit CPython’s source code in your working copy,changes to Python code will be picked up by the interpreter for immediateuse and testing. (If you change C code, you will need to recompile theaffected files as described below.)

Changes for the documentation can be made from the same repository; seeGetting started.

Install pre-commit as a Git hook

To make sure your code is linted correctly, we recommend setting uppre-commit as a Git hook:

$ pre-commit install --allow-missing-configpre-commit installed at .git/hooks/pre-commit

Now pre-commit will run automatically ongitcommit.

On this page

[8]ページ先頭

©2009-2025 Movatter.jp