Twine is defaulting "long_description_content_type" to text/x-rst
Asked Answered
M

2

9

Heres is my setup

setup(
    name="`...",
    version="...",
    description=...,
    long_description_content_type="text/markdown",
    long_description=README,
    author="...",

    classifiers=[...],

    packages=["..."],
    include_package_data=True,
)

I used the following command to package my project

python setup.py sdist bdist_wheel 

but when I run

twine check dist/*

I get the following error

Checking dist\Futshane_TBG-1.0.0-py3-none-any.whl: FAILED
  `long_description` has syntax errors in markup and would not be rendered on PyPI.
    line 9: Error: Unexpected indentation.
  warning: `long_description_content_type` missing. defaulting to `text/x-rst`.
Checking dist\Futshane_TBG-1.0.0.tar.gz: FAILED
  `long_description` has syntax errors in markup and would not be rendered on PyPI.
    line 9: Error: Unexpected indentation.
  warning: `long_description_content_type` missing. defaulting to `text/x-rst`.

Why is it failing to identify the type provided, when I've obviously provided one?

Mellette answered 14/8, 2020 at 16:23 Comment(4)
You might want to delete the build and dist directories and retry.Spermicide
Can you include the version of setuptools, twine and wheel you're using? Also, can you include the import statement for setup?Cellulosic
My version of twine is 3.2.0Mellette
I ended up finding this answer useful: https://mcmap.net/q/261671/-how-to-make-pypi-description-markdown-workAustralorp
M
12

I attempted to switch the order of the "long_description_content_type" and the "long_description" arguments and instead of assigning the description argument to a variable containing the description, I assigned it directly to the description. Doing so has resolved my issue

setup(
    name="Futshane_TBG",

    version="1.0.0",

    description=""" The description of the package   """,

    long_description_content_type="text/markdown",

    long_description=README,

    url="https://github.com/ElLoko233/Text-Based-Game-Package",

    author="Lelethu Futshane",

    classifiers=["License :: OSI Approved :: MIT License",
                 "Programming Language :: Python :: 3",
                 "Programming Language :: Python :: 3.8"],

    packages=["TBG"],

    include_package_data=True,
)

Mellette answered 16/8, 2020 at 3:59 Comment(0)
H
1

Use Pandoc and PyPandoc to convert your Markdown(md) files into RestructuredText(rst) before uploading them into PyPi. To accomplish this, add the following to your setup.py file: pip install pypandoc

try:
   import pypandoc
   long_description = pypandoc.convert_file('README.md', 'rst')
except(IOError, ImportError):
   long_description = open('README.md').read()

setup(
name='blah',
version=find_version('blah.py'),
description='Short description',
long_description=long_description,
)
Hankhanke answered 16/10, 2022 at 11:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.