Minimal Python directory structure for PyPi
assume your package is named “joesprog”
setup.py joesprog/ __init__.py
setup.py for PyPi contains something like:
from setuptools import setup
setup(name='joesprog', packages=['joesprog'], version = '1.0', description='Joe says this program is cool.', author = 'Joe Doe', url = 'https://github.com/joe/joesprog', classifiers=[ 'Development Status :: 5 - Production/Stable', 'License :: OSI Approved :: BSD License', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', ], install_requires=['numpy'], )
You can find a list of classifiers here, pick the ones suitable for your project. At least you should have which Python version(s) your program is intended for.
Simple PyPi upload procedure
- Sign up for PyPi account. It may take several hours to get the confirmation email.
~/.pypircwith the content
[distutils] index-servers = pypi [pypi] repository=https://pypi.python.org/pypi username=<your pypi username>
Note that I did NOT save my password for security.
In your Python package directory that you want to upload
python setup.py sdist bdist_wheel upload
Now your package is live to the world on PyPi, and anyone can install it via
pip install joesprog
- you MUST increment the
versionnumber for each release, or PyPi will not let you upload
error: Upload failed (400): Binary wheel ‘*-cp36-cp36m-linux_x86_64.whl’ has an unsupported platform tag ‘linux_x86_64’.
You can workaround this by not uploading the wheel, just the source code and your users will compile it on their machine.
python setup.py sdist upload