Hi there. So we meet again. I just created a simple django package (django-session-notifier) and submitted it to PyPI. Therefore I want to share me experience on how you submit your python package to PyPI.
Let's say that our package has the name "awesome_pypi_package" and that it contains of a "utils.py" file. The structure of what we want to pack then should be something similar to the following:
└── awesome_pypi_package ├── __init__.py ├── utils.py └── setup.py └── setup.cfg └── LICENSE.txt └── MANIFEST.in └── README.md
1. Create the necessary files (see structure above)
2. Open setup.py and add the following lines:
# -*- coding: utf-8 -*- from distutils.core import setup from setuptools import find_packages setup( name='awesome-pypi-package', version='0.0.1', author=u'Will & Skill', firstname.lastname@example.org', packages=find_packages(), url='https://github.com/willandskill/awesome-pypi-package', license='MIT licence, see LICENCE.txt', description='My PyPI package is awesome', long_description=open('README.md').read(), zip_safe=False, include_package_data=True )
3. Open setup.cfg and add the following lines:
[metadata] description-file = README.md
4. Open MANIFEST.in and add the following lines:
include README.md LICENSE recursive-include awesome_pypi_package *.py *.html
The setup parameter include_package_data will only work if MANIFEST.in exists.
NOTE: Change awesomepypipackage to your package name and change includes to fit your needs
5. Register a PyPI account
6. Setup .pypirc configuration file
Add the following lines to .pypirc (Remember to change username and password to your PyPI credentials.
[distutils] index-servers = pypi pypitest [pypi] repository=https://pypi.python.org/pypi username=your_username password=your_password [pypitest] repository=https://testpypi.python.org/pypi username=your_username password=your_password
7. Register and upload package to PyPI Test
python setup.py register -r pypitest
python setup.py sdist upload -r pypitest
8. Register and upload package to PyPI Live
python setup.py register -r pypi
python setup.py sdist upload -r pypi
You should by now be able to install your package with pip.