PyPI — the Python Package Index
Create your accounts
Create a .pypirc configuration file
[distutils] # this tells distutils what package indexes you can push to
index-servers =
PyPI # the live PyPI
PyPI-test # test PyPI
[PyPI] # authentication details for live PyPI
repository: https://PyPI.python.org/PyPI
username: {{your_username}}
password: {{your_password}}
[PyPI-test] # authentication details for test PyPI
repository: https://testPyPI.python.org/PyPI
username: {{your_username}}
Prepare your package
root-dir/ # arbitrary working directory name
setup.py
setup.cfg
LICENSE.txt
README.md
mypackage/
__init__.py
foo.py
bar.py
baz.py
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 = 'Ajay',
author_email = 'aj@gmail.com',
url = 'https://github.com/ajkumar25/mypackage', # use the URL to the github repo
download_url = 'https://github.com/ajkumar25/mypackage/tarball/0.1', # I'll explain this in a second
keywords = ['testing', 'logging', 'example'], # arbitrary keywords
classifiers = [],
)
setup.cfg
[metadata]
description-file = README.md
Register your package
$ python setup.py register -r PyPI-test
Upload your package
$ python setup.py sdist upload -r PyPI-test
Upload to PyPI Live
$ python setup.py register -r PyPI
$ python setup.py sdist upload -r PyPI
References :
How to Create a Python Library | Pypix