Home

How to publish python package to pypi

Create your account
https://pypi.org/

Create a .pypirc configuration file

[distutils]
index-servers =
  pypi
  pypitest

[pypi]
repository=https://pypi.python.org/pypi
username=your_username
password=your_password

Prepare your packet

  1. setup.cfg
[metadata]
description-file = README.md
  1. setup.py
from distutils.core import setup
setup(
  name = 'mypackage',
  packages = ['mypackage'], # this must be the same as the name above
  version = '0.1',
  description = 'A random test lib',
  author = 'Author',
  author_email = 'author@mail.com',
  url = 'https://github.com/repo/mypackage', # use the URL to the github repo
  download_url = 'https://github.com/repo/mypackage/archive/0.1.tar.gz', # I'll explain this in a second
  keywords = ['testing', 'logging', 'example'], # arbitrary keywords
  classifiers = [],
)
  1. Install twine
    pip install twine

  2. Create distribution
    python setup.py sdist bdist_wheel

  3. Upload to PyPI live
    twine upload dist/*

comments powered by Disqus