python-poetry / poetry

Python packaging and dependency management made easy
https://python-poetry.org
MIT License
31.61k stars 2.26k forks source link

Poetry build sets python core metadata summary equals description, failing to upload to pypi and pypitest #8593

Open broeder-j opened 1 year ago

broeder-j commented 1 year ago

Issue

The python package build successfully by poetry gets rejected from PYPI and PYPI test for having a too long summary (512 chars), a package core metadata property.

From my understanding this occurs because:

  1. poetry sets per default the summary key for core package metadata equals the projects description or empty. (I have not found any way to provide this metadata key additionally to poetry.)
  2. The summary metadata string is limited to 512 chars on pypi. (I have not found this specification length detail in the specifications https://packaging.python.org/en/latest/specifications/core-metadata/#summary by python beyond that it should be 'one line'.)
  3. the 'summary' core metadata key is not part of project metadata, so it cannot be set in the pyproject.toml file.

So currently I am forced by poetry to shorten my projects description, that it also fits into the core metadata summary content for PYPI, or I cannot publish the build package there, or I would have to hack the metadata afterwards.

How this might be solved to my understanding by poetry:

Output

$ poetry config virtualenvs.in-project true
$ poetry install
Installing dependencies from lock file
No dependencies to install or update
Installing the current project: test-poetry-issue (1.0.0)
$ poetry build
Building test-poetry-issue (1.0.0)
  - Building sdist
  - Built test-poetry-issue-1.0.0.tar.gz
  - Building wheel
  - Built test-poetry-issue-1.0.0-py3-none-any.whl
$ poetry config repositories.testpypi "https://test.pypi.org/legacy/"
$ poetry publish -r testpypi -u "__token__" -p "${testpypi_api_token}"
Publishing test-poetry-issue (1.1.0) to testpypi
 - Uploading test-poetry-issue-1.0.0-py3-none-any.whl 0%
 - Uploading test-poetry-issue-1.0.0-py3-none-any.whl 10%
 - Uploading test-poetry-issue-1.0.0-py3-none-any.whl 100%
HTTP Error 400: 'Long description...long description.' is an invalid value for Summary. Error: Field cannot be longer than 512 characters. See https://packaging.python.org/specifications/core-metadata for more information. | b"<html>\n <head>\n  <title>400 'Long description...long description.' is an invalid value for Summary. Error: Field cannot be longer than 512 characters. See https://packaging.python.org/specifications/core-metadata for more information.\n \n <body>\n  <h1>400 'Long description...long description.' is an invalid value for Summary. Error: Field cannot be longer than 512 characters. See https://packaging.python.org/specifications/core-metadata for more information.\n  The server could not comply with the request since it is either malformed or otherwise incorrect.

The same goes for

poetry publish -u "__token__" -p "${pypi_api_token}"
dimbleby commented 1 year ago

yeah, you should make your description shorter.

While poetry is currently stuck in its own poetry-specific section of pyproject.toml, the correspondence between "description" and "summary" is kept in the python standard pyproject.toml too - see https://packaging.python.org/en/latest/specifications/declaring-project-metadata/#description

broeder-j commented 1 year ago

Thx. I missed that and the core metadata description is set by the message body since version 2.1 and does not correspond to description in the project metadata. (https://packaging.python.org/en/latest/specifications/core-metadata/#description) So a rich description for the upload is still possible, but not within the pyproject.toml file.... to bad.

If a raised warning about the description length prior upload somewhere is not something wanted by poetry this issue can be closed. (also not a bug, but a feature request then)