|
| 1 | +.. _quick-reference: |
| 2 | + |
| 3 | +=============== |
| 4 | +Quick reference |
| 5 | +=============== |
| 6 | + |
| 7 | +.. include:: /include/activate-tab.rst |
| 8 | + |
| 9 | +Here are the basic steps needed to get set up and open a pull request. |
| 10 | + |
| 11 | +This is meant as a checklist and cheat-sheet, not a comprehensive guide. |
| 12 | +For complete instructions see the :ref:`setup guide <setup>` and the |
| 13 | +:ref:`pull request guide <pullrequest>`. |
| 14 | + |
| 15 | + |
| 16 | +Set up Git |
| 17 | +========== |
| 18 | + |
| 19 | +Install and set up ``Git``. |
| 20 | + |
| 21 | +For detailed setup information, see :ref:`"Install Git" <vcsetup>`. |
| 22 | +There is also a more detailed :ref:`Git guide and cheat sheet <gitbootcamp>`. |
| 23 | + |
| 24 | +Fork and clone the repo |
| 25 | +----------------------- |
| 26 | + |
| 27 | +Fork `the CPython repository <https://github.com/python/cpython>`__ |
| 28 | +to your GitHub account and clone the repo using:: |
| 29 | + |
| 30 | + git clone https://github.com/<your_username>/cpython |
| 31 | + cd cpython |
| 32 | + |
| 33 | +For detailed information, see :ref:`"Get the source code" <checkout>`. |
| 34 | + |
| 35 | + |
| 36 | +Build Python |
| 37 | +============ |
| 38 | + |
| 39 | +.. tab:: Unix |
| 40 | + |
| 41 | + .. code-block:: shell |
| 42 | +
|
| 43 | + ./configure --config-cache --with-pydebug && make -j $(nproc) |
| 44 | +
|
| 45 | +.. tab:: macOS |
| 46 | + |
| 47 | + .. code-block:: shell |
| 48 | +
|
| 49 | + ./configure --config-cache --with-pydebug && make -j$(sysctl -n hw.logicalcpu) |
| 50 | +
|
| 51 | +.. tab:: Windows |
| 52 | + |
| 53 | + .. code-block:: dosbatch |
| 54 | +
|
| 55 | + PCbuild\build.bat -e -d |
| 56 | +
|
| 57 | +See also :ref:`more detailed instructions <compiling>`, |
| 58 | +:ref:`how to install and build dependencies <build-dependencies>`, |
| 59 | +and the platform-specific pages for :ref:`Unix <unix-compiling>`, |
| 60 | +:ref:`macOS <macOS>`, and :ref:`Windows <windows-compiling>`. |
| 61 | + |
| 62 | + |
| 63 | +Run the tests |
| 64 | +============= |
| 65 | + |
| 66 | +.. tab:: Unix |
| 67 | + |
| 68 | + .. code-block:: shell |
| 69 | +
|
| 70 | + ./python -m test -j0 |
| 71 | +
|
| 72 | +.. tab:: macOS |
| 73 | + |
| 74 | + .. code-block:: shell |
| 75 | +
|
| 76 | + ./python.exe -m test -j0 |
| 77 | +
|
| 78 | + .. note:: |
| 79 | + :ref:`Most <mac-python.exe>` macOS systems use |
| 80 | + :file:`./python.exe` in order to avoid filename conflicts with |
| 81 | + the ``Python`` directory. |
| 82 | + |
| 83 | +.. tab:: Windows |
| 84 | + |
| 85 | + .. code-block:: dosbatch |
| 86 | +
|
| 87 | + .\python.bat -m test -j0 |
| 88 | +
|
| 89 | +
|
| 90 | +See also :ref:`how to write and run tests <run-write-tests>`. |
| 91 | + |
| 92 | + |
| 93 | +.. _pullrequest-quickguide: |
| 94 | + |
| 95 | +Create issues and pull requests |
| 96 | +=============================== |
| 97 | + |
| 98 | +Create issues for nontrivial changes |
| 99 | +------------------------------------ |
| 100 | + |
| 101 | +For most changes, `create an issue <https://github.com/python/cpython/issues>`__ |
| 102 | +before submitting a pull request. |
| 103 | +Trivial changes like typo fixes do not need issues. |
| 104 | + |
| 105 | +Create work branches |
| 106 | +-------------------- |
| 107 | + |
| 108 | +Work on a feature or fix in a new branch in Git from the ``main`` branch:: |
| 109 | + |
| 110 | + git checkout -b fix-issue-12345 main |
| 111 | + |
| 112 | +Make changes, then :ref:`commit <commit-changes>` and |
| 113 | +:ref:`push to your fork <push-changes>`. |
| 114 | + |
| 115 | +Document your changes |
| 116 | +--------------------- |
| 117 | + |
| 118 | +Many changes deserve a NEWS entry which documents what changed. |
| 119 | +For more information on how and when to write news entries, |
| 120 | +see :ref:`"Updating NEWS and What's New in Python" <news-entry>`. |
| 121 | + |
| 122 | +A news entry can be created locally with the :pypi:`blurb` tool |
| 123 | +and its ``blurb add`` command or online after a pull request has |
| 124 | +been opened with `blurb-it <https://blurb-it.herokuapp.com/>`__. |
| 125 | + |
| 126 | +For more information about how to create news entries, see |
| 127 | +:ref:`"How to add a NEWS entry" <news-entry-howto>`. |
| 128 | + |
| 129 | +Create pull requests |
| 130 | +-------------------- |
| 131 | + |
| 132 | +Create pull requests on GitHub from your branches, on your fork, and make sure |
| 133 | +to put the relevant issue number in ``gh-NNNNNN`` format in the pull request title. |
| 134 | +For example: |
| 135 | + |
| 136 | +.. code-block:: text |
| 137 | +
|
| 138 | + gh-12345: Fix some bug in spam module |
| 139 | +
|
| 140 | +See also, GitHub's documentation on `creating pull requests`_. |
| 141 | + |
| 142 | +For more detailed guidance, follow the :ref:`step-by-step pull request guide <pullrequest-steps>`. |
| 143 | + |
| 144 | +.. note:: |
| 145 | + |
| 146 | + First time contributors will need to sign the Contributor Licensing |
| 147 | + Agreement (CLA) as described in the :ref:`Licensing <cla>` section of |
| 148 | + this guide. |
| 149 | + |
| 150 | +.. _creating pull requests: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request |
| 151 | + |
| 152 | +Work on your pull request |
| 153 | +------------------------- |
| 154 | + |
| 155 | +Make sure the :ref:`continuous integration checks on your pull |
| 156 | +request are green <keeping-ci-green>` (successful). |
| 157 | + |
| 158 | +Read and respond to reviewer comments on your pull request. |
| 159 | + |
| 160 | +See also, GitHub's documentation on `commenting on pull requests`_. |
| 161 | + |
| 162 | +.. _commenting on pull requests: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/commenting-on-a-pull-request |
| 163 | + |
| 164 | +Don't force-push |
| 165 | +---------------- |
| 166 | + |
| 167 | +In order to keep the commit history intact, avoid squashing or amending |
| 168 | +history and then force-pushing to the PR. |
| 169 | +Reviewers often want to look at individual commits. |
| 170 | + |
| 171 | +CPython uses squash merges, so PRs will end up as single commits when merged. |
0 commit comments