This assumes you already have the
setup.py and structure below
- Sign up for PyPi account.
- Install Twine
python -m pip install twine
~/.pypircwith the content
Note that I did NOT save my password for security.
- In your Python package directory to upload
python setup.py sdist bdist_wheel twine upload dist/*
- Now your package is live to the world on PyPi. Anyone can install it via
python -m pip install myprogram
- assuming your package is named
myprogram, have a directory structure like
setup.py myprogram/ __init__.py
- A minimal
setup.pyfor PyPi contains something like:
#!/usr/bin/env python from setuptools import setup, find_packages setup(name='myprogram', packages=find_packages(), version = '0.1.0', description='My program is 2x faster and 1/3 the size of Hello World.', long_description=open('README.md').read(), long_description_content_type="text/markdown", author = 'Author Name', url = 'https://github.com/username/myprogram', classifiers=[ 'Development Status :: 4 - Beta', 'Programming Language :: Python', ], install_requires=['numpy','matplotlib>=2.1'], python_requires='>=3.6', )
Pick from the list of classifiers suitable for your project.
- you MUST increment the
versionnumber for each release, or PyPi will not let you upload
README.mdis enabled by
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 twine upload dist/*