Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why are the classifiers for my Python package not appearing on test PyPI?

I'm learning how to publish a Python package by following the recommendations in the Python Packaging User Guide. I created a simple setup.py based on the example in the Basic Use section of the setuptools documentation:

from setuptools import setup, find_packages

setup(
    name="HelloWorld",
    version="0.1",
    packages=find_packages(),

    # metadata for upload to PyPI
    author="Me",
    author_email="[email protected]",
    description="This is an Example Package",
    url = "http://example.com/HelloWorld/",
    classifiers = [
        'Development Status :: 3 - Alpha',
        'Intended Audience :: Developers',
        'License :: OSI Approved :: Python Software Foundation License',
        'Operating System :: OS Independent',
        'Programming Language :: Python :: 2',
    ],
)

I built the source distribution, registered the HelloWorld package at the Test PyPI site, and uploaded the package's tarball to the Test PyPI site using twine. However, the classifiers do not appear on the package's page at Test PyPI. Furthermore, they are not in the release's PKG-INFO:

# https://testpypi.python.org/pypi?name=HelloWorld&version=0.1&:action=display_pkginfo

Metadata-Version: 1.1
Name: HelloWorld
Version: 0.1
Author: Me
Author-email: me at example com
Home-page: http://example.com/HelloWorld/
Summary: This is an Example Package
Platform: UNKNOWN
like image 413
Jimm Domingo Avatar asked Oct 09 '14 17:10

Jimm Domingo


People also ask

What does yanked mean in PyPI?

A yanked release is a release that is always ignored by an installer, unless it is the only release that matches a version specifier (using either == or === ).


1 Answers

I confirmed that the classifiers do appear in the PKG-INFO file that was created when I ran setup.py sdist:

$ cat HelloWorld.egg-info/PKG-INFO

Metadata-Version: 1.0
Name: HelloWorld
Version: 0.1
Summary: This is an Example Package
Home-page: http://example.com/HelloWorld/
Author: Me
Author-email: [email protected]
License: UNKNOWN
Description: UNKNOWN
Platform: UNKNOWN
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Python Software Foundation License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 2

But the first line shows that metadata version as 1.0 (PEP 241), but classifiers were added in metadata version 1.1 (PEP 314). The metadata version was not detected correctly, even though I was using the latest version of setuptools (6.0.2).

The cause of the problem is my system Python. I'm using OS X 10.8 (Mountain Lion) which comes with Python 2.7.2, as noted in this SO answer. This version has a bug in metadata version detection, which was fixed in 2.7.3 . By examining the bug patch, I figured out a workaround is to pass one of these keywords -- provides, requires, obsoletes -- to the setup function. For example, with this addition to the setup call:

setup(
    name="HelloWorld",
    version="0.2",
    # ...
    provides=['hours.of.debugging.fun'],
)

the generated local PKG-INFO file now has metadata version 1.1, and the classifiers now appear on the Test PyPI site.

like image 163
Jimm Domingo Avatar answered Oct 15 '22 20:10

Jimm Domingo