I was addicted to not being able to use Markdown on pypi's long_description

Conclusion

--When I try to register my own library (mong) in pypi, the package description (README.md) ) Was angry with a format error --long_description_content_type is recognized as reStructuredText even though it is specified --In setup.py, use setuptools.setup instead of distutils.core.setup

When I noticed, the solution was instant. I don't have much chance to create setup.py from scratch, so I will record it for future use. (I am another person after 3 days)

Background

I've always been worried that the description of pypi in mong is broken. It wasn't recognized as Markdown, and I thought it was a typo even though I specified long_description_content_type =" text / markdown " in the argument of setup (). Since a new name was added by the head family, we decided to upgrade and tackled this problem that had been postponed.

image.png

Investigation

Let's use twine check

At first I was testing with test.pypi, but along the way I realized that I could use twine check to verify it at hand. This speeds up the verification cycle.

The check result in twine is as follows, and it also appears if long_description_content_type is not specified.

% twine check dist/mong-0.0.1.tar.gz
Checking dist/mong-0.0.1.tar.gz: FAILED
  `long_description` has syntax errors in markup and would not be rendered on PyPI.
    line 13: Warning: Inline literal start-string without end-string.
  warning: `long_description_content_type` missing.  defaulting to `text/x-rst`.

Survey item

I checked the following items one by one. After all, it didn't matter at all, but I got a better understanding of PyPI and packages. The description seems to have been generated by looking at mong-00.1 / PKG-INFO.

--typo: Example of official Python documentation didn't work, so it looks different -Format violation of other items: Even if the input items are minimized, it still occurs. -[Updating setuptools version](https://medium.com/@chezou/1%E8%A1%8C%E4%BF%AE%E6%AD%A3%E3%81%A7%E6%96% B0% E3% 81% 97% E3% 81% 84pypi% E3% 81% A7markdown% E3% 81% AE% E3% 83% 89% E3% 82% AD% E3% 83% A5% E3% 83% A1% E3% 83% B3% E3% 83% 88% E3% 81% 8C% E4% BD% BF% E3% 81% 88% E3% 81% 9F-14e40d90ff3f): setuptools supports Markdown from v38.6.0 That said, I'm using 45.2.0

Causes and countermeasures

So, when I looked at the beginning of the code, I didn't use setuptools in the first place. It's completely unexpected (even though it's my code) that I was using the old distutils.

https://github.com/toshihikoyanase/mong/blob/v0.0.1/setup.py#L1

from distutils.core import setup

You should replace it with setuptools.

https://github.com/toshihikoyanase/mong/blob/v0.0.2/setup.py#L1

from setuptools import setup

You can rest assured that the description will be rendered in Markdown. We have also released v0.0.2.

image.png

Recommended Posts

I was addicted to not being able to use Markdown on pypi's long_description
I was addicted to Flask on dotCloud
I was addicted to not being able to get an email address from google with django-allauth authentication
I was addicted to multiprocessing + psycopg2
The record I was addicted to when putting MeCab on Heroku
A note I was addicted to when making a beep on Linux
I was addicted to pip install mysqlclient
I want to use Linux on mac
What I was addicted to Python autorun
Two things I was addicted to building Django + Apache + Nginx on Windows
I was addicted to running tensorflow on GPU with NVIDIA driver 440 + CUDA 10.2
A story I was addicted to trying to install LightFM on Amazon Linux
Use Python from Java with Jython. I was also addicted to it.
[Python] I was addicted to not saving internal variables of lambda expressions
Log when I was worried that I could not connect to Wi-Fi on Linux
[Introduction to json] No, I was addicted to it. .. .. ♬
I was able to recurse in Python: lambda
I tried to use Resultoon on Mac + AVT-C875, but I was frustrated on the way.
Summary of points I was addicted to running Selenium on AWS Lambda (python)
Note that I was addicted to npm script not passing in the verification environment
Code memo that I was having trouble with not being on the discord.py site
I was addicted to scraping with Selenium (+ Python) in 2020
A story that I was addicted to at np.where
I want to use OpenJDK 11 on Ubuntu Linux 18.04 LTS / 18.10
I was able to repeat it in Python: lambda
I was addicted to trying logging.getLogger in Flask 1.1.x
What I was addicted to when using Python tornado
I want to use the Ubuntu desktop environment on Android for the time being (Termux version)
Memo (March 2020) that I was addicted to when installing Arch Linux on MacBook Air 11'Early 2015
I want to use Ubuntu's desktop environment on Android for the time being (UserLAnd version)
[IOS] GIF animation with Pythonista3. I was addicted to it.
What I was addicted to when migrating Processing users to Python
[Fixed] I was addicted to alphanumeric judgment of Python strings
I was a little addicted to installing Python3.3 + mod_wsgi3.4 on Sakura VPS (CentOS), so a retrospective memo
When I tried to use pip with python, I was told that XML_SetHashSalt could not be found.
The story of not being able to run pygame with pycharm
I want to use shortcut translation like DeepL app on Linux
What I was addicted to when introducing ALE to Vim for Python
What I was addicted to with json.dumps in Python base64 encoding
Note that I was addicted to sklearn's missing value interpolation (Imputer)
A note I was addicted to when creating a table with SQLAlchemy
When I try to use pip, SSL module is not available.
Python> Comprehension> cells> I was taught how to use double comprehension / itertools
I was addicted to confusing class variables and instance variables in Python
I really want to use GitHub Flavored Markdown (GFM) with Pelican!
Nonlocal that Python beginners (junior high school students) were addicted to (sorry for not being able to explain)
I want to use Ubuntu's desktop environment on Android for the time being (Termux version-Japanese input in desktop environment)
For the time being using FastAPI, I want to display how to use API like that on swagger