Publish Library in PyPI

Often there is a need for Python developers to upload their work (code) in Python’s huge repository -PyPI. I had run into the same problem. But somehow, after some tweaking I was able to complete this simple but tricky task.

  1. Create a repository in Github to host the source code.
  2. Sign up for an account in PyPI —

3. Create a .pypirc config file with the following contents in home directory (~/.pypirc)

index-servers =


4. Change its permission so that only you can read/write it.

chmod 600 ~/.pypirc

5. To publish your code in PyPI, you ill need these three files in the root directory of your project : Mark down readme file.

LICENSE.txt : Describe your license.

setup.cfg and

description-file =

from distutils.core import setup
description='Package description',
author='Your Name',
download_url= '',
keywords = ['tag1', 'tag2'],
classifiers = [],

6. Commit the recent files and create a TAG. The tag will create a direct download link of your repository with the version. e.g.

git add -A
git commit -m “Project now compatible for deployment in PyPI”
git tag 1.0 -m “Add tag for version 1.0”
git push origin master
git push — tags origin master

7. Final Step : Deploy in PyPI

python register -r pypi
python sdist upload -r pypi

You should receive a response something similar to this

Response : 200 OK

Congrats, you have published your code in PyPI. It can be installed by pip

pip install package_name