How to create a pip package?

Last updated: Sun, 02 Jun 2019 18:59:03 GMT 0 comments

In this first post you will find quick references to the commands needed to share your package through Pypi.

Pypi, available at, is the official repository for Python packages. Packages available on Pypi can be installed very easily using pip install <package_name>.

Registering your package and first upload

To make your Python package available on Pypi, you will need to:

  1. Create configuration files (including, setup.cfg) for your project, cf. for a full list.
  2. Build your package
python sdist
python bdist_wheel
  1. Register your project and upload to Pypi test server
python register -r
twine upload -r pypitest dist/*
  1. Check that the install works fine from Pypi test server
pip install -i <PACKAGE_NAME>
  1. Upload your package to Pypi!
twine upload -r pypi dist/*

Releasing a new version

To make a new version of your package available:

  1. Delete any previous built
rm -rf dist
rm -rf build
rm -rf *.egg-info
  1. Rebuild your package
python sdist
python bdist_wheel
  1. Send to Pypi test server and check the installation
twine upload --repository-url dist/*
pip install --index-url <PACKAGE_NAME>

Check that the version is the latest one:

pip freeze | grep <PACKAGE_NAME>
  1. Upload to Pypi!
twine upload -r pypi dist/*

For more information, the official documentation (with examples) is available at:

Edit on July 6, 2018: replacing '/pypi' by '/simple' when installing from pypi test. Edit on June 2, 2019: updated twine and pip install commands to upload and install from pypi test according to TestPypi documentation. Add info about checking version.