Get startedGet started for free

Publishing your package

1. Publishing your package

Your package is now ready to be released online, congratulations on bringing it this far!

2. PyPI

When you install packages using pip, you are normally downloading them from the python package index, known as PyPI. This is an online code repository, and anyone anywhere can upload packages to it. You just need to register for a free account. It can be tempting to wait until your package is fully finished and polished before releasing it. But releasing early, just as soon as it might be useful to someone, means you can get feedback and you might attract other people to help you develop it.

3. Distributions

When you upload your package to PyPI you actually upload a package distribution. A distribution is just a bundled version of your code which is ready to be installed. There are two important kinds of distributions in Python. Source distributions and wheel distributions. Source distributions are basically just the Python files you have written. To install this distribution the files must be downloaded and then the setup script is run. A wheel distribution is a version of your package in a slightly processed format. It can be installed without running the setup script and so is faster for the user to install and is usually smaller in size, so is faster to download as well. The wheel distribution is the preferred Python distribution, and pip will install a package using this when it is available. However, when you upload distributions to PyPI, it is good practice to upload both the wheel and the source distribution.

4. How to build distributions

You can build source and wheel distributions from the terminal using this command. You run the setup script and pass sdist to make the source distribution and bdist-wheel to make the wheel distribution. This will create a dist directory and add wheel and source distributions inside. It will also create build and egg-info directories, but you can ignore these.

5. Getting your package out there

Now that you have built your distributions the only thing left to do is upload them. You can do this from the terminal using twine. Twine is a tool specifically made for uploading packages to PyPI. Here we upload all the distributions in the dist directory. You can also upload your distributions to the Test-PyPI repository, which is a version of the PyPI repository made for testing. It's a good place to start. In order to upload, you'll first have to go to either PyPI or Test-PyPI to register for an account.

6. How other people can install your package

Once you've done this, your package is live and anyone can install it using PIP. It is also possible to install your package from Test-PyPI using a longer command. You specify the index-url which is where the package is downloaded from, and the extra-index-url which is where PIP can search for your dependency packages.

7. Let's practice!

Alright, it's time build some distributions ready for upload. Let's practice!