Register distribution with PyPI
Date: January 28th 2016
Last updated: January 28th 2016
1) Register an account on PyPI following this link. This is easiest to do manually online.
2) Add Trove Classifiers to setup.py. Trove classifiers must be one or more from a specific list. Make sure you generate another sdist file containing Trove Classifiers.
# Trove classifiers are strings
setup(...,
classifiers=[
#'Development Status :: 1 - Planning',
#'Development Status :: 2 - Pre-Alpha',
'Development Status :: 3 - Alpha',
#'Development Status :: 4 - Beta',
#'...'
'Natural Language :: English',
'Programming Language :: Python :: 2.7',
#'Programming Language :: Python :: 2 :: Only',#
'Topic :: Scientific/Engineering',
'Topic :: Scientific/Engineering :: Visualization',
'Topic :: Scientific/Engineering :: Bio-Informatics',
],
)
Add backwards compatibility for python versions sub 2.3 by adding the following code to setup.py:
#...
from sys import version
if version < '2.2.3':
from distutils.dist import DistributionMetadata
DistributionMetadata.classifiers = None
DistributionMetadata.download_url = None
#setup(..., )
3) Registering a project on PyPI:
Go to the PyPI submission page and upload PK-INFO. After submitting add info, you are redirected to the project page.
4) Create ~/.pypirc file
# add repo content to this file
# This file sits in the home directory
[distutils]
index-servers=pypi
[pypi]
repository = https://pypi.python.org/pypi
username = rayblick
password = *********
5) Install twine and upload sdist
# Install
sudo pip install twine
# Secure upload
twine upload dist/*
# Insecure upload
python setup.py sdist upload
#python setup.py bdist_egg upload
Resources
- https://packaging.python.org/en/latest/distributing/#uploading-your-project-to-pypi
- https://wiki.python.org/moin/TestPyPI
- https://github.com/pypa/twine
- https://pythonhosted.org/an_example_pypi_project/setuptools.html#intermezzo-pypirc-file-and-gpg
- http://stackoverflow.com/questions/1569315/setup-py-upload-is-failing-with-upload-failed-401-you-must-be-identified-t/1569331#1569331