Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 83 additions & 0 deletions pullrequest.rst
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,89 @@ command (after any successful build of Python)::
python.bat Tools/scripts/patchcheck.py


Quick Guide
'''''''''''

`Clear communication`_ is key to contributing to any project, especially an
`Open Source`_ project like Python.

Here is a quick overview of you can contribute to CPython on Github:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Substitute GitHub for all instances of Github 👍


1. `Create an Issue`_ that describes your change, if it doesn't exist and you're explicitly working on something

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if...something

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If an issue doesn't already exist, `create one <https://bugs.python.org/>`_?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clearer. Thanks @ezio-melotti and @willingc


2. `Get started`_ and set up your system

3. Fork `CPython on Github`_ (using the Fork button in the upper-right on Github)

4. `Compile Python`_ on your system

5. `Run tests`_ after you have built Python

6. `Add an "upstream" Remote in Git`_ on your system

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: Add an "upstream" Git remote


7. `Create a Branch in Git`_ where you can work on changes

8. Commit changes and `resolve conflicts in Git`_

9. `Run tests`_ again

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be between 7 and 8: after creating the branch, the user should fix the issue and run the tests to make sure the fix works. If it works, the changes can be committed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. I meant to do just that


10. `Push commits`_ to your Github repo

11. `Create Pull Request`_ in Github to merge a branch from your Fork

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to merge ... Fork -> to ask for your changes to be merged into CPython.


12. Celebrate! You just contributed to Python. :)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps before celebrating the user should address the review comments and update the PR until it gets merged.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're telling me! Haha


.. _Clear communication: https://opensource.guide/how-to-contribute/#how-to-submit-a-contribution
.. _Open Source: https://opensource.guide/
.. _Create an Issue: https://bugs.python.org/
.. _Get started: https://cpython-devguide.readthedocs.io/setup.html#getting-started
.. _CPython on Github: https://github.com/python/cpython
.. _Compile Python: https://cpython-devguide.readthedocs.io/setup.html#compiling-for-debugging
.. _Run tests: https://cpython-devguide.readthedocs.io/runtests.html#running-writing-tests
.. _Add an "upstream" Remote in Git: https://cpython-devguide.readthedocs.io/committing.html#remotes-setup
.. _Create a Branch in Git: https://cpython-devguide.readthedocs.io/committing.html#active-branches
.. _resolve conflicts in Git: https://cpython-devguide.readthedocs.io/committing.html#squashing-commits
.. _Run tests: https://cpython-devguide.readthedocs.io/runtests.html#running-writing-tests
.. _Push commits: https://cpython-devguide.readthedocs.io/committing.html#pushing-changes

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For all the internal links you should be able to use :ref:`...`.
For short urls (like the one to bpo, or opensource.guide), sometimes it's more readable to add them inline, using `text displayed <url>`_.
For longer urls or urls that are repeated, it's ok using a label like you did.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you elaborate on ""For all the internal links you should be able to use :ref:...."" ? I scanned the rST documentation and couldn't quite understand when what got used where

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See for example the quick start in index.rst -- it links to other sections using this syntax.
See also https://cpython-devguide.readthedocs.io/documenting.html#cross-linking-markup for more info.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I follow. This appears to be internal linking within a page whereas I'm linking within the same site, but to different pages. Perhaps I don't understand the full scope of what :ref: is doing for devguide.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay. I think I've got it... but where can I find an index of each of these unique IDs across devguide? Is there one, or can Sphinx create it for me? I want to avoid name collision.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Plus, I'm finding it difficult to do "ACTIVE VERB" -- GET, DO, RUN, versus the current titles which are like Getting, Doing, Running. They work fine as headers, but are tough for step-by-step instructions that say, "Do step 1."; "Run step 2" and so on

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for continued complaints, as this might be a known issue. I've updated the devguide with internal :ref: links, but what it's gained in engineering clarity I think has degraded the readability of steps and hyperlinks -- I'm open to thoughts on that.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that when the auto-generated text for a link target doesn't make sense in the context of the particular link, you can instead use:

:ref:`link text <link-target>`

The description at https://cpython-devguide.readthedocs.io/documenting.html#cross-linking-markup mentions using that syntax for linking to labels that don't refer to section headings, but doesn't point out that it can also be used to link to section headings with text other than the section heading name.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as name collisions are concerned, I don't know of an easy way to get a complete listing, but Sphinx itself will complain about any duplicates (and tell you which files contain the conflicting labels) as part of the build process.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, @ncoghlan That is super-helpful.

.. _Create Pull Request: https://help.github.com/articles/creating-a-pull-request/


Quick Guide Step-by-step
''''''''''''''''''''''''

Set up your system::

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will only work if the user has an ssh key setup for GitHub. Otherwise, the user will need to use https.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm re-reading this part. How often to contributors not have an SSH / RSA key? To me, that seems standard.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@louisrawlins It's worth mentioning the SSH key since my experience at sprints and hackathons is that many new contributors do not have an SSH key configured for GitHub.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aha. Gotcha. Hadn't considered hackathons and that environment.


git clone git@github.com:YOUR_GITHUB_ID/cpython.git

Replace **YOUR_GITHUB_ID** with your Github account name above, then add upstream::

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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be the https url since a contributor would need core dev privileges, as well as an ssh key, to use the git url.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, but I would also add a short note to explain the difference, otherwise users might be wondering why two different types of urls are used.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. I'm struggling to figure out a way to say that concisely. It's like, you're cloning SSH, then fetching HTTPS -- I suppose?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#130 has a discussion about it that clarifies the differences.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not so much curious about the difference, as I'm trying to figure out how to tell potentially contributors when they might need to worry about the difference.

For me, I treat HTTPS as something I use when I just need to download something as a ZIP, I'm not at my machine, etc. It's not something I'd be using if I'm branching something on my repo and preparing for a Pull Request. For that, I'd use SSH. But perhaps I'm missing a nuance here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about "Add an “upstream” Git remote on your system (for SSH, or you can use HTTPS)"?


Work on new features or fixes::

git checkout -b MY_NEW_FEATURE upstream/master

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would use something more generic, such as MY_BRANCH_NAME, or issue-NNNNN


As you work, please create a separate commit for each bug fix or feature change::

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be a bit misleading, since each PR should either fix a bug or add a new feature.


git commit

Then fetch upstream to see if anything conflicts with your changes::

git fetch upstream

Use rebase -i to verify what you commit and squish small commits::

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/s/squish/squash


git rebase -i upstream/master

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this step necessary?
IIUC as long as there are not conflicts, both the rebase and the squash are not necessary, since the committer will do it.
If squashing prevents reviewers to see the individual commits, it should also be avoided by contributors.

@louisrawlins louisrawlins Mar 5, 2017 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think? I'm not sure. This came from a workflow where many devs were contributing to a single remote branch, then the dev lead would merge that branch to production periodically. Since I'm not contributing to the CPython codebase day-to-day, it's hard for me to judge

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The squash seems unnecessary, especially if it "hides" the intermediate commits.
The rebase shouldn't hurt, but I think it would be necessary only in case of conflicts, otherwise it's just an extra step that might be avoided.
Someone more familiar with Git than me could comment.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

git rebase was always useful if I was committing to a file that I knew was likely to be touched by other devs. It's a relatively explicit "walkthrough" process that is built into Git. Pt another way, if you're familiar enough to programming to contribute to CPython, it's likely you can figure out rebase. I can go either way on squashing commits -- it makes things clear in the case content and cosmetic changes, but for logic I don't generally find it helpful

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tend to lean toward @ezio-melotti's approach to not rebase since the core dev will take care of it. @louisrawlins, In my experience contributors vary widely in their understanding of rebase, so let's keep things easiest and not recommend. Thanks.


Then push your work to your clone on Github::

git push origin MY_NEW_FEATURE

When you're ready, make a Pull Request on Github and refer to your branch named **MY_NEW_FEATURE**.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The contributors should be ready as soon as they pushed their branch :)
I'm also not sure what you mean with "refer to your branch named ..." -- isn't it enough to click on the "create PR" button?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I know, there is that extra step where I have to go to [CPython on GitHub] (https://github.com/python/cpython), click "New pull request", find and click on the link "compare across forks", select my repository, THEN select my branch -- I find the entire process burdensome (because I'm doing everything else on the CLI) and a bit confusing because it's its own process -- how much detail should we have in the docs?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I did so far was:

  1. push the new branch to my fork
  2. go to my fork on github
  3. a button saying something like "you pushed branch X [create PR]" appears
  4. click on the button

IOW, I create the PR from my fork, not from the upstream CPython.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you go to your fork, the GitHub UI should pop up the option to submit a PR as @ezio-melotti recommends.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay. Clearer. It's the "New pull request" button next to the "branch selection" menu in my repo, correct? Glad I asked! (To be clear, I wasn't creating the PR from the upstream, but rather going TO CPython because I had a Pull Request FOR CPython -- it didn't make sense to fiddle with a PR from my own repo.)


*Though submitting a Pull Request on Github is the preferred method of contribution, you can alternatively upload a patch to bugs.python.org*

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line (and perhaps the previous one) is too long. Add http:// in front of b.p.o so it becomes a clickable link.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having emphasis * and the link on the same line caused issues. I've made it a "Note:"



Licensing
---------

Expand Down