-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Add Description-Content-Type field #258
Conversation
b9195d8
to
c4cb911
Compare
This allows specifying the content type of the distribution's description (e.g.: `text/plain`, `text/x-rst`, `text/markdown`).
c4cb911
to
fcd83ac
Compare
Bikeshedding: CommonMark? Can that be the default? |
Maybe. I've never used CommonMark; in fact, I hadn't heard of it until you mentioned it. Have a Python implementation that you like? https://pypi.python.org/pypi/CommonMark perhaps? |
How is CommonMark different than the original Markdown? Why do you prefer it? |
CommonMark (http://commonmark.org/) is rigidly defined unlike Markdown which has bits of ambiguity (true "original" Markdown.pl is properly broken in some nesting cases). It improves a bunch of quirks, like spaces around lists, and standardizes some of the more convenient parts of GFM like fenced code blocks. |
http://commonmark.org/ sounds interesting and has some big names behind it. I'm intrigued. I think I'll take a closer look and consider making CommonMark the default. |
BTW, the only reason that I made original Markdown the default is because it's listed as the initial variant in RFC 7763 at https://tools.ietf.org/html/rfc7763#section-6.1.4, but then CommonMark is referenced in RFC 7764 at https://tools.ietf.org/html/rfc7764#section-4.5 (which I hadn't noticed before), so I guess nothing prevents it from being the default. Part of me thinks that because there are so many competing Markdown variants and so much confusion around Markdown, that perhaps there should be no default and we should require the variant to be specified. Thoughts on that? |
The overall default on the server side needs to be UTF-8 ReST (as in the current PR) for compatibility with existing projects that already correctly use ReST formatting. However, when the media type is given as So using CommonMark as the default (including falling back to it if asked to process an unknown variant) makes sense to me. |
source/specifications.rst
Outdated
- ``text/markdown`` | ||
|
||
There is one required parameter called ``charset``, to specify whether the text | ||
is UTF-8, ASCII, etc. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd make charset
optional, defaulting to UTF-8
- that way text/markdown
is sufficient to get Markdown rendering.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My first instinct was to default to charset
to UTF-8
.
But then I saw this in RFC 7763 section 2:
charset: Per Section 4.2.1 of [RFC6838], charset is REQUIRED.
There is no default value because neither [MDSYNTAX] nor many
popular implementations at the time of this registration do
either.
That said, we can disagree with that RFC and do what we want, but I thought deferring to previous work would be a good start, since they probably had reasons and discussions around this.
Intuitively, it seems to me to be a good idea to simply default to UTF-8
. I'm not sure why the RFC didn't simply do that. I wonder if they've thought of something that we haven't?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I went ahead and made charset
optional and defaulted it to UTF-8.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the general case, I agree that there's no sensible universal default, but Python project descriptions aren't the general case - they're a specific use case. That lets us make assumptions in the name of ease-of-use that wouldn't be valid given a broader context.
+1 from me for the general idea, but what you have so far is missing guidance on expected behaviour for tools reading the field to render the description when:
Those additions would be SHOULD/MAY type guidelines rather than MUST requirements, but I think we still want to give some thought to how PyPI should handle those cases, and how those considerations can be turned into general recommendations. |
This is used to populate the newly proposed `Description-Content-Type` field, that is proposed in pypa/packaging.python.org#258.
This is used to populate the newly proposed `Description-Content-Type` field, that is proposed in pypa/packaging.python.org#258.
Added mentions of |
Made CommonMark the default variant for Markdown in 33dc8c5. |
Latest draft looks good to me, but I'll defer to @dstufft for actual sign-off. While I don't expect this idea to be controversial, we should also give folks a chance to discuss the idea on distutils-sig before committing to it. |
@ncoghlan: I'm still planning to add some info on expected behavior when things are omitted or invalid, as you suggested in #258 (comment). But certainly, I'd love to have @dstufft and anyone else's comments. |
source/specifications.rst
Outdated
One parameter is called ``charset``; it can be used to specify whether the | ||
character set in use is UTF-8, ASCII, etc. If ``charset`` is not provided, then | ||
it is recommended that the implementation (e.g.: PyPI) treat the content as | ||
UTF-8. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe move the sentence "If charset is not provided..." down below? (See next comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does e4b39db help?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with @pfmoore that this can be dropped in favour of the more concise specification below.
Overall, LGTM (one minor comment in the diff). |
for `Description-Content-Type` (and `charset` and `variant`) as suggested by @ncoghlan at pypa#258 (comment)
e4b39db: Clarified how to treat missing/invalid values for |
I imagine @dstufft is likely at pycon and will be a little slow to respond.
:)
…On Tue, May 16, 2017, 9:58 PM Marc Abramowitz ***@***.***> wrote:
@dstufft <https://github.com/dstufft>: Any more comments on this?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#258 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAPUcx46zf1GPwd7q8FHM2yNFg4416npks5r6n5zgaJpZM4JYgnk>
.
|
Sadly I'm not at PyCon, I just haven't gotten a chance to circle back around to this yet :( |
Yay, I see @dstufft merged this. Great news! So what do we need to do next? |
Probably implement support in setuptools, then wheel, then twine, then PyPI/Warehouse. |
Would it be better to have the server (PyPI/Warehouse) accepting it before the clients? Then newer clients wouldn't get errors if they support what the server doesn't |
I think there are a few aspects with a required order, then some that can happen in arbitrary order:
(We should probably document this somewhere on pypi.io as a standard practice, since it applies to any interoperability metadata changes we make) |
for `Description-Content-Type` (and `charset` and `variant`) as suggested by @ncoghlan at pypa#258 (comment)
The former subject to a little agreement by others: pypa#258 (review)
that was causing incorrect rendering pointed out by @ekohl in pypa#258 (comment)
as suggested by @dstufft in pypa#258 (comment)
This is used to populate the new `Description-Content-Type` field. `Description-Content-Type` is described at pypa/packaging.python.org#258.
Test that specifying a `long_description_content_type` keyword arg to the `setup` function results in writing a `Description-Content-Type` line to the `PKG-INFO` file in the `<distribution>.egg-info` directory. `Description-Content-Type` is described at pypa/packaging.python.org#258
This is used to populate the new `Description-Content-Type` field. `Description-Content-Type` is described at pypa/packaging.python.org#258
Test that specifying a `long_description_content_type` keyword arg to the `setup` function results in writing a `Description-Content-Type` line to the `PKG-INFO` file in the `<distribution>.egg-info` directory. `Description-Content-Type` is described at pypa/packaging.python.org#258
This is used to populate the new `Description-Content-Type` field. `Description-Content-Type` is described at pypa/packaging.python.org#258
Test that specifying a `long_description_content_type` keyword arg to the `setup` function results in writing a `Description-Content-Type` line to the `PKG-INFO` file in the `<distribution>.egg-info` directory. `Description-Content-Type` is described at pypa/packaging.python.org#258
This is used to populate the new `Description-Content-Type` field. `Description-Content-Type` is described at pypa/packaging.python.org#258
Test that specifying a `long_description_content_type` keyword arg to the `setup` function results in writing a `Description-Content-Type` line to the `PKG-INFO` file in the `<distribution>.egg-info` directory. `Description-Content-Type` is described at pypa/packaging.python.org#258
This is used to populate the new `Description-Content-Type` field. `Description-Content-Type` is described at pypa/packaging.python.org#258
Test that specifying a `long_description_content_type` keyword arg to the `setup` function results in writing a `Description-Content-Type` line to the `PKG-INFO` file in the `<distribution>.egg-info` directory. `Description-Content-Type` is described at pypa/packaging.python.org#258
This is used to populate the new `Description-Content-Type` field. `Description-Content-Type` is described at pypa/packaging.python.org#258
Test that specifying a `long_description_content_type` keyword arg to the `setup` function results in writing a `Description-Content-Type` line to the `PKG-INFO` file in the `<distribution>.egg-info` directory. `Description-Content-Type` is described at pypa/packaging.python.org#258
@ncoghlan or anyone else who knows about this, could you please explain how to get it working properly? I added in
This is syntax documented as supported in setuptools (here). But it doesn't seem to be respected or used for anything - the generated metadata in the distribution always just shows I use the version of setuptools v38.2.4, and I use "python setup.py bdist_wheel" to build the dist. |
Hi @wimglenn, there's an open PR to setuptools to fix this: pypa/setuptools#1207 |
@di ah, yes, that’s exactly the spot I ended up at in pdb when I was looking at it. Thanks! |
This allows specifying the content type of the distribution's description (e.g.:
text/plain
,text/x-rst
,text/markdown
).See https://github.com/msabramo/python-packaging-user-guide/blob/description-content-type/source/specifications.rst#description-content-type
Cc: @nicktimko, @ncoghlan, @dstufft, @jaraco, @xavfernandez
Related: