Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add a section 'Extensions' #246

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 5, 2018
Merged

Conversation

matrixise
Copy link
Member

No description provided.

Copy link
Contributor

@ncoghlan ncoghlan left a comment

Choose a reason for hiding this comment

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

Thanks for getting this started! Some more detailed recommendations in line, but I think this will be a useful addition.

extensions.rst Outdated
@@ -0,0 +1,13 @@
.. _extensions:

Write a CPython extension
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd suggest "Updating standard library extension modules"

extensions.rst Outdated
Write a CPython extension
=========================

In this section, we could explain how to write a CPython extension with the C language, but the topic can take a complete book.
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the goal of this section should be to equip folks with the tools they need to work on the existing extension modules in the reference implementation, and to add new ones if necessary.

Essential pointers:

extensions.rst Outdated

Read the following references:

* https://docs.python.org/3.7/extending/
Copy link
Contributor

Choose a reason for hiding this comment

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

For easier maintenance, use the dev link rather than the specific version: https://docs.python.org/dev/extending/

@willingc
Copy link
Collaborator

Hi @matrixise, Do you wish to finish up this PR or would you like me to do so? Thanks!

@Mariatta Mariatta added the status-stale The PR hasn't been updated in a while, and pending removal label Jul 21, 2018
@matrixise
Copy link
Member Author

@willingc I will finish this PR, really sorry, I will work on it on this evening.

@Mariatta Mariatta removed the status-stale The PR hasn't been updated in a while, and pending removal label Jul 31, 2018
@matrixise
Copy link
Member Author

Hi all, @ncoghlan @willingc and @Mariatta I have fixed this PR with the recommendations of @ncoghlan

Please, when you have time, review.

I am so sorry for this late reply.

Copy link
Contributor

@ncoghlan ncoghlan left a comment

Choose a reason for hiding this comment

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

Minor suggested wording adjustment inline, but I think is a useful addition as is.


In this section, we could explain how to write a CPython extension with the C language, but the topic can take a complete book.

For this reason, we prefer to give you some links where you can read a very good documentation.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested wording/grammar tweak:

For this reason, we instead prefer to provide some links to existing documentation that we recommend.

(Perhaps it would also be worth mentioning core-mentorship here, and linking to the section on communications?)

@berkerpeksag
Copy link
Member

Do we really need to create a separate document just for four links? I think the most up-to-date and detailed resource is https://pythonextensionpatterns.readthedocs.io/en/latest/ and it was already linked in the Devguide in #279.

@ncoghlan
Copy link
Contributor

ncoghlan commented Aug 4, 2018

We really should have more than just the 4 links - referencing the C style guide, pointers to test_embed and test_capi, etc, start building out some extra docs for internal helper functions, etc.

It would make sense to mention that as a ReST comment though, otherwise it isn't clear why we're adding such a bare bones page in the first place.

@berkerpeksag
Copy link
Member

It would make sense to mention that as a ReST comment though, otherwise it isn't clear why we're adding such a bare bones page in the first place.

I don't think "we'll finish this later" is a good argument for merging this PR. A TODO comment can easily be forgotten in a short time. And after two years or so, someone is going to submit a PR to remove extensions.rst because it doesn't contain any useful information.

Please don't make the Devguide a place for unfinished and half baked documents.

@matrixise
Copy link
Member Author

@berkerpeksag ok, but where will you put these links?

@berkerpeksag
Copy link
Member

PEP 399 can be mentioned at https://devguide.python.org/runtests/#writing (test.support is already mentioned) https://pythonextensionpatterns.readthedocs.io/en/latest/ is the hardest resource to find on Google and it's already mentioned in the Devguide. The rest can be found with a simple Google search such as "python c extension".

@ncoghlan
Copy link
Contributor

"You can find this information via Google if you already know what to look for, and how to interpret the results" isn't a particularly helpful attitude for us to adopt when writing documentation aimed primarily at new CPython contributors.

If starting the section out with just a few links really bothers you, then rather than saying "This doesn't have enough content, so reject it", I'd prefer to see this new section extended a bit to also cover:

  • how to add a new extension module via Modules/Setup.dist
  • how to add a new extension via the Makefile and the MSVS build process
  • how to convert an extension module into a builtin module instead

@berkerpeksag
Copy link
Member

"You can find this information via Google if you already know what to look for, and how to interpret the results" isn't a particularly helpful attitude for us to adopt when writing documentation aimed primarily at new CPython contributors.

Most of these links are from our own documentation and don't have anything to do with contributing to CPython (except PEP 399) People can read them to learn how to write Python extensions for their own projects. We don't explain how to use unittest or how to write unit tests in the devguide. We only give information specific to CPython (how to use regrtest, how to find memory leaks by using regrtest, how to make coveragepy work with extension modules, test.support etc.)

If starting the section out with just a few links really bothers you, then rather than saying "This doesn't have enough content, so reject it", I'd prefer to see this new section extended a bit to also cover:

Your suggestions sound good to me. I'd like to see a action about how to test a C API function (by using Modules/__testcapimodule.c and Lib/test_capi.py) I'm volunteering to write it or I can help Stéphane if he'd like to do it himself.

@matrixise matrixise merged commit 441f54d into python:master Sep 5, 2018
AA-Turner pushed a commit to AA-Turner/devguide that referenced this pull request Jun 17, 2022
* Add a section 'Extensions'

* Update with the recommendations of Nick Coghlan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants