python nonsense

uploading to pypi fails

You will see a 400 Client Error with the message that the description could not be rendered using reStructuredText. It doesn't matter if you are using markdown for your description or reST, you see the same error.

The sneaky thing is that the error might actually be caused by a problem in setup.py. If you scroll back to the output from that script you will hopefully see a warning about inconsistent metadata. In my case, I had defined the author_name and maintainer_email parameters to setuputils.setup. It turns out that maintainer_email must be accompanied by maintainer_name (ditto author_name must be accompanied by author_email).

import setuptools

setuptools.setup(
    name="fop",
    version="0.0.1",
    long_description=("the sound made by those killer robots" +
                      " in the Hitchiker's guide."),
    description="death and destruction are imminent",
    packages=setuptools.find_packages(),
    author="Will",
    maintainer_email="will@foo.com",
    url="git.foo.com/fop"
)

We run our setup script to build the packages.

wfvining@flathead:~/python/fop$ python3 setup.py sdist
running sdist
running egg_info
writing fop.egg-info/PKG-INFO
writing dependency_links to fop.egg-info/dependency_links.txt
writing top-level names to fop.egg-info/top_level.txt
reading manifest file 'fop.egg-info/SOURCES.txt'
writing manifest file 'fop.egg-info/SOURCES.txt'
running check
warning: check: missing meta-data: if 'author' supplied, 'author_email' must be supplied too

creating fop-0.0.0
creating fop-0.0.0/fop
creating fop-0.0.0/fop.egg-info
copying files to fop-0.0.0...
copying README.md -> fop-0.0.0
copying setup.py -> fop-0.0.0
copying fop/__init__.py -> fop-0.0.0/fop
copying fop.egg-info/PKG-INFO -> fop-0.0.0/fop.egg-info
copying fop.egg-info/SOURCES.txt -> fop-0.0.0/fop.egg-info
copying fop.egg-info/dependency_links.txt -> fop-0.0.0/fop.egg-info
copying fop.egg-info/top_level.txt -> fop-0.0.0/fop.egg-info
Writing fop-0.0.0/setup.cfg
Creating tar archive
removing 'fop-0.0.0' (and everything under it)

We get a lot of output telling so we know setuptools is working really hard. Buried in that useful1 output there is a warning:

running check
warning: check: missing meta-data: if 'author' supplied, 'author_email' must be supplied too

Because out package's metadata is inconsistent, the description cannot be rendered when we upload to pypi. The solution, of course is to fix the error.

import setuptools

setuptools.setup(
    name="fop",
    version="0.0.1",
    long_description=("the sound made by those killer robots" +
                      " in the Hitchiker's guide."),
    description="death and destruction are imminent",
    packages=setuptools.find_packages(),
    maintainer="Will",
    maintainer_email="will@foo.com",
    url="git.foo.com/fop"
)

Now we run setup.py again and this time it is successful. Finally, we can upload our package to pypi!

Footnotes:

1

There is this old Unix idea that tools should be quiet unless you ask them to be loud. Hiding the spray of useless informational output from setuptools would have let me see, and fix, the warnings immediately.

Published on 2020-02-27 Thu 20:24