Repository navigation
Description
Hi,
Thank you for providing very useful resource.
NOTE: I am not raising issue of the license terms of this sampleproject like #17 since this is MIT licensed.
ISSUE
Issue is supportive technical information to adopt this example to the packaging of existing GPL programs.
If I simply replace LICENSE.txt content with the LICENSE file content of GPL license, the resulting wheel package failed to upload to testpypi.org.
$ twine upload --verbose --repository testpypi dist/*
...
ERROR HTTPError: 400 Bad Request from https://test.pypi.org/legacy/
The description failed to render in the default format of reStructuredText. See https://test.pypi.org/help/#description-content-type for more information.
The local test result of such package goes:
$ python3 -m build;twine check dist/*
...
Successfully built sampleproject_osamu_debian_org-3.2.0.tar.gz and sampleproject_osamu_debian_org-3.2.0-py3-none-any.whl
Checking dist/sampleproject_osamu_debian_org-3.2.0-py3-none-any.whl: FAILED
ERROR `long_description` has syntax errors in markup and would not be rendered on PyPI.
line 2: Warning: Block quote ends without a blank line; unexpected unindent.
WARNING `long_description_content_type` missing. defaulting to `text/x-rst`.
Checking dist/sampleproject_osamu_debian_org-3.2.0.tar.gz: PASSED
WORKAROUND
In order to avoid this ERROR to successfully transition to the new pyproject.toml, I need to do the followings on LICENSE.txt file
- Replace all back-tics with single-quote
- Remove all leading whitespaces
and live with WARNING or use the last option of commenting out license = { file = "LICENSE.txt"} in pyproject.toml to stop including LICENSE.txt into METADATA file in the wheel package.
I am not sure what is the best solution here.
Desired situation
At least some pointer to the best solution for resolving this situation needs to be easily available to the prospectus users.
I think the build tool should be smart enough to wrap/escape problematic character sequence in the LICENSE.txt to avoid causing issues. But that is not the case now. Requiring to edit LICENSE.txt manually to avoid ERROR seems to be bad idea.
Dropping license = "LICENSE.txt" in pyproject.toml seems to be most practical solution for now. You still get to include unmodified LICENSE into wheel package.
Maybe, it may be a good idea to add link to the root cause bug until it is fixed.
Additional note
As I checked https://github.com/pypa/build , its pyproject.toml has license.file = "LICENSE" but the resulting METADATA doesn't contain it. This build is built by flint-core while the sampleproject uses requires = ["setuptools>=43.0.0", "wheel"] as the build backend.
FYI: I post my packaging experience around this at: https://osamuaoki.github.io/en/2024/02/03/python-pypi/
Activity
abravalheri commentedon Feb 13, 2024
Hi @osamuaoki , have you tried setting thereadme.content-typetotext/plain?Sorry, wrong hint: this does not seem to solve the problem...
It is probably a "folding" issue with the syntax of the METADATA file. The effect of
license.fileis to embedded all the text from the file intoMETADATA. Omitting it relies on Setuptools using the standard rules to add the license file into the wheel as a separated file.osamuaoki commentedon Feb 13, 2024
Yah, I was thinking along the same line. Despite the upload ERROR message initially gave me an impression, the real issue seems to be inclusion of LICENCE and its data conversion to fit it into METADATA.
setuptoolseems to accept only ReST compatible file. (Just impression. No serious test is done yet.)flintseems to ignore thislicenseentry inpyproject.toml.According to my vague memory, I tried something along:
It didn't fix this issue.
I don't know if this is bug on build tool side or not. Important thing is to inform user for practical workaround for the moment and someone who understand situation to ask other packages to work with this situation etc.
jeanas commentedon Feb 13, 2024
I couldn't reproduce. After replacing the contents of
LICENSE.txtwith the GPL text, I still getabravalheri commentedon Feb 13, 2024
I cannot reproduce it either... This is what I did in detail:
Anyway, I think this repository is not the best place to be discussing this issue.
Once the author has a complete minimal reproducer, the following possibilities might be investigated:
pypa/setuptoolsproject (later, after the investigation is complete, it might also involvepypa/distutilsand/orpypa/wheel).pypi/warehouseproject.twine checkand the checks inpypi, to be discussed in thepypa/twineand/orpypi/warehouseprojects.However it is important to have a clear idea what item(s) in the list above is actually happening, before opening any new issue; and verify them with solid reproducers.
Please feel free to use the quick script in the example above, to check if the
METADATAfile is malformed... It is by no means an exhaustive check though but maybe when added totwine checkis enough?osamuaoki commentedon Feb 13, 2024
I should have been more explicit which LICENSE text I was using. I am using good old GPL2 text as https://github.com/osamuaoki/imediff/blob/main/LICENSE and renamed it to LICENSE.txt . This file is causing problem.
With your test case with GPL3 text, I also get no problem on Debian/stable:
So the problem is specific to the GPL2 text. Quotation styles are different.
FYI I am using Debian 12/ stable as the base. This means Python3.11. (I also used the latest PIP packages under venv to be current)
abravalheri commentedon Feb 13, 2024
Thank you for the reproducer.
This seems to be the same as pypa/setuptools#4033.
I would say the root of the problem is the
\x0ccharacters in the license text. Isn't it?Quoting Paul Moore in the thread I linked above:
The escaping goes wrong when
pypa/wheeltries to regenerated the metadata file by ingesting the file thatpypa/setuptoolsgenerates. Per se, the file generated inpypa/setuptoolsparses correctly, but after being re-generated bypypa/wheel, it does not.Recently I submitted a PR to
pypa/distutilsthat will make the life ofpypa/wheeleasier, and prevent this round-trip problem from happening all togheter. Howeverpypa/distutilshas not been merged intopypa/setuptoolsyet.If the problem is indeed
\x0c, I recommend closing this issue since the problem is already being tracked in pypa/setuptools#4033.As a workaround you can replace all the
\x0ccharacters in your license file with a\n, or simply remove out thelicence = ...in yourpyproject.tomlas you have previously suggested (the license file will still be included in the wheel as a standalone file, so you are still distributing the license).pfmoore commentedon Feb 13, 2024
I'm confused. The reported error is:
That's about the README, not the license, and it's saying that the README isn't valid Restructured text. It looks like whatever changes the OP made to the readme (or to the filename of the readme, because if it were still a
.mdfile it would be detected as Markdown) are the problem here.osamuaoki commentedon Feb 13, 2024
I can confirm the problematic content is in the LICENSE text not in README.
Good old FormFeed aka. FF (0x0c) in LICENSE was the real root cause. By removing them, I get clean result with no ERROR nor WARNING. So the problem is in setuptools.
As for the unhelpful ERROR message which seems to imply the problem reside in README.md or content-type setting... I don't know how exactly it happens to say this but this error report message has some room to be improved to lead people to the root cause.
abravalheri commentedon Feb 13, 2024
Hi @pfmoore, I am trying to summarise my thought process below. Hopefully it will improve the understanding 🤞.
When the stdlib's
emailfunctions are used to read theMETADATAfiles, they don't care if there is a\xc0character... It seems to deal with it very well1. So that is why thePKG-INFOinsidetar.gzsdist parses correctly.However, when
pypa/wheelregenerates theMETADATAfile fromPKG-INFOit replaces the\xc0character with a\n. If you happen to have in your license file a\n\xc0or\xc0\nsequence, this means thatpypa/wheelwill generate aMETADATAfile with\n\n.Now, in the email message format, the
\n\nsequence is used to mark the end of the headers section and the beginning of the body/payload. In the packaging standard, we use the body/payload of the email message for theREADME/long_description.So the error message is complaining about the
README/long_description, because part of theLICENSEfile is incorrectly being considered as the email message body/payload.This is the same error discussed in pypa/setuptools#4033, for which pypa/distutils#213 should provide a good workaround (we have to wait until it lands on setuptools).
Footnotes
And/or at least the functions used for parsing in
twine/PyPI. ↩[-]Sample build breaks if LICENSE.txt file contains GPL license text[/-][+]Sample build breaks if LICENSE.txt file contains GPL2 license text (containing 0x0c)[/+]pfmoore commentedon Feb 13, 2024
Ah, I see. Thanks - that's a lot more subtle than I realised.
osamuaoki commentedon Feb 13, 2024
Hi, looking at pypa/setuptools#4033 , problematic control codes are:
In other words
These needs to be removed from the original LICENSE file to make source code robust and portable to older platforms.
As for the following text in pyproject.toml:
I suggest updating this section with:
jeanas commentedon Feb 13, 2024
IMHO, we should just fix that bug and not document the workaround, because pip and build use build isolation by default and most people never change that setting, which should fix the problem without people needing to upgrade their toolchain as soon as a new release of wheel is out.
osamuaoki commentedon Feb 16, 2024
I see your point and agree.
Maybe leave this issue open until the new release of tool chain.