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
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 === ).
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With