pypa / gh-action-pypi-publish

The blessed :octocat: GitHub Action, for publishing your :package: distribution files to PyPI: https://github.com/marketplace/actions/pypi-publish
https://packaging.python.org/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/
BSD 3-Clause "New" or "Revised" License
920 stars 85 forks source link

Error: `long_description` has syntax errors in markup and would not be rendered on PyPI #162

Closed beucismis closed 1 year ago

beucismis commented 1 year ago

TOML file: https://github.com/beucismis/ozgursozluk/blob/main/pyproject.toml Failed job: https://github.com/beucismis/ozgursozluk/actions/runs/5272889540/jobs/9535689902

kabeor commented 1 year ago

@beucismis I solved this just now. You can try to follow this. it may work.

Add long_description_content_type='text/markdown' to your setup.py.

setup(
...
long_description=open('README.md').read(),
long_description_content_type='text/markdown',
...
)
beucismis commented 1 year ago

@kabeor How should it be for pyproject.toml file?

kabeor commented 1 year ago

@beucismis I'm not very sure, but from pep-0621

Format: String or table
Core metadata: Description (link)
Synonyms
  Flit: description-file (link)
  Poetry: readme (link)
  Setuptools: long_description (link)

I guess you can try to use description-file.

beucismis commented 1 year ago

@kabeor Thanks. I'm trying.

aecorn commented 1 year ago

@beucismis Having the same error here with poetry + pyproject.toml + readme.md + gh-action-pypi-publish This workflow is working on other repos, with pretty much the same settings, but Ive never pushed this particular repo to Pypi earlier.

Ive tried deleting the README.md file and recreating it from scratch, didnt work...

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

ERROR    `long_description` has syntax errors in markup and would not be        
         rendered on PyPI.                                                      
         No content rendered from RST source.                                   
WARNING  `long_description_content_type` missing. defaulting to `text/x-rst`.   
Checking dist/ssb_fagfunksjoner-0.0.4.tar.gz: PASSED with warnings
WARNING  `long_description_content_type` missing. defaulting to `text/x-rst`.   
WARNING  `long_description` missing.```
aecorn commented 1 year ago

After trying a bunch of steps, I did these two steps and it worked:

So probably follow the links according to tool, and be specific about readme-file: https://peps.python.org/pep-0621/#readme

If Im to guess what's going on here, something might have broken somewhere on how the readme is identified (using readme.md not readme.rst for example), or that the tool breaks on some weirdness with the markdown-file itself...

Btw Im using v1.5.1 pypa/gh-action-pypi-publish@v1.5.1

webknjaz commented 1 year ago

Btw Im using v1.5.1 pypa/gh-action-pypi-publish@v1.5.1

That's an old version, and you really should upgrade to the recent release. Though, it's not related. What fails is a twine check --strict call. It doesn't check your repo or any files in the source checkout, it checks the artifact you're going to upload. This means that you've built your artifact wrong, and it didn't end up having the correct metadata internally.

With https://github.com/marketplace/actions/pypi-publish#disabling-metadata-verification you can disable the check, of course, and it'll likely make the upload if the artifact is not fully broken. But you should really have that twine check --strict somewhere in your CI to catch such things earlier than the release publishing job.

Also, you need to fix your artifact generation. That'll depend on your PEP 517 build backend. setuptools/hatch/flit/poetry/whatever. You need to consult with those projects in order to fix your artifacts. This action takes artifacts you provide and publishes them, nothing else, it doesn't build them, you do. You can use that twine check --strict to check your artifact generation locally.

Once you have your artifacts generated correctly, the metadata check will stop failing. Closing as this is not an issue with the action project.

XXZhou25 commented 1 year ago

@beucismis I solved this just now. You can try to follow this. it may work.

Add long_description_content_type='text/markdown' to your setup.py.

setup(
...
    long_description=open('README.md').read(),
    long_description_content_type='text/markdown',
...
)

Thank you you are a genius. You saved my life.

paddyroddy commented 11 months ago

I'm also encountering this problem for https://github.com/astro-informatics/sleplet/blob/main/pyproject.toml. I have published before with this action (last time 2023-10-05) and now I'm blocked by the long_description error.

pkit commented 11 months ago

Just FYI, so people coming here from Google would know. This is a crappy python/twine way to notify you about: "you're missing a README file" So, to solve it:

  1. Create README.md file, write something into it, should not be empty.
  2. Add to your pyproject.toml under [project]
    [project]
    readme = "README.md"
  3. Rebuild the artifact/wheel.
paddyroddy commented 11 months ago

Thanks, @pkit, I actually already have one. I've tracked the bug down to python -m build; twine check dist/*. Something is wrong in my README.md and currently trying to work out what that is...

pkit commented 11 months ago

@paddyroddy there's no problem in your README.md I have downloaded it from wget https://raw.githubusercontent.com/astro-informatics/sleplet/main/README.md And then built my project with it (instead of my own README):

rm -fr dist && python -m build --wheel && twine check dist/*

it passes.

paddyroddy commented 11 months ago

Thanks for checking @pkit! I hadn't thought of trying that. Okay, must be a pyproject.toml problem. Will see if I can work it out.

paddyroddy commented 11 months ago

Sorry for the noise. I've solved my issue. I was trying to wrap the urls block of my pyproject.toml

urls = {Code = """
    https://github.com/astro-informatics/sleplet
    """, Documentation = """
    https://astro-informatics.github.io/sleplet
    """, Download = """
    https://pypi.org/project/sleplet
    """, Homepage = """
    https://github.com/astro-informatics/sleplet
    """, Issues = """
    https://github.com/astro-informatics/sleplet/issues
"""}

reverting back to (which was new since October)

urls = {Code = "https://github.com/astro-informatics/sleplet", Documentation = "https://astro-informatics.github.io/sleplet", Download = "https://pypi.org/project/sleplet", Homepage = "https://github.com/astro-informatics/sleplet", Issues = "https://github.com/astro-informatics/sleplet/issues"}

has fixed my issue.

Gouvernathor commented 6 months ago

I have the same issue on my repo. It took some time to figure out that "long_description" was the peculiar way to spell "readme", as the toml entry is "readme" and not "long_description". Besides this, it flags an error of "unexpected indentation" at line 25 of my readme, even though changing that line's indentation yields a very different result so it's not actually a mistake.

Gouvernathor commented 6 months ago

Not providing any readme (by commenting the toml line) also ends in failure for the wheel file, but not for the tar.gz file. But upload still failed because of that.

peterdudfield commented 5 months ago

I solved it with adding content-type = "text/markdown"

[project]
name="PVNet"
description = "PVNet"
authors = [{name="Peter Dudfield", email="info@openclimatefix.org"}]
dynamic = ["version", "readme"]
license={file="LICENCE"}

[tool.setuptools.dynamic]
version = {attr = "pvnet.__version__"}
readme = {file = "README.md", content-type = "text/markdown"}

https://github.com/openclimatefix/PVNet/pull/190